/* =====================================================================
   Gazette Plus - Digital Media Oversight Console
   Palette: ink #14232E · console #0E1A23 · paper #EDF0F2 · seal #146B5C
   Type: IBM Plex Sans + IBM Plex Sans Ethiopic, Plex Mono for references
   ===================================================================== */

:root {
  --ink: #14232E;
  --ink-soft: #4A5D6B;
  --ink-faint: #7B8B96;
  --console: #0E1A23;
  --console-2: #172833;
  --paper: #EDF0F2;
  --surface: #FFFFFF;
  --hairline: #D3DBE0;
  --seal: #146B5C;
  --seal-dark: #0F5346;
  --seal-wash: #E6F0ED;
  --clear: #2F7A4F;
  --amber: #B5811C;
  --alert: #A62B3E;
  --alert-wash: #FBEBEE;
  --amber-wash: #FBF2E0;
  --radius: 3px;
  --rail: 232px;
  --shadow: 0 1px 2px rgba(20, 35, 46, .08);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "IBM Plex Sans Ethiopic", "Noto Sans Ethiopic", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  padding-top: env(safe-area-inset-top, 0px);
}

a { color: var(--seal); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; max-width: 72ch; }

.ref, .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .85em; }
.muted { color: var(--ink-faint); }
.small { font-size: .82rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }

/* ------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--console);
  color: #C8D6DE;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top, 0px);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.rail-brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 2px; background: #fff; }
.rail-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  background: var(--seal); color: #fff;
  font-weight: 600; border-radius: 2px;
}
.rail-brand b { display: block; color: #fff; font-size: .95rem; font-weight: 600; }
.rail-brand span { display: block; font-size: .72rem; color: #7E95A2; }

.rail-nav { padding: 10px 0 24px; flex: 1; }
.rail-group { margin-top: 14px; }
.rail-group > p {
  margin: 0 16px 6px;
  font-size: .72rem;
  color: #61798A;
  letter-spacing: .02em;
}
.rail-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 16px;
  color: #C8D6DE;
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.rail-nav a:hover { background: rgba(255, 255, 255, .05); text-decoration: none; color: #fff; }
.rail-nav a.on { background: rgba(20, 107, 92, .28); border-left-color: var(--seal); color: #fff; font-weight: 500; }
.rail-nav .tally {
  font-size: .72rem;
  background: var(--alert);
  color: #fff;
  border-radius: 9px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
}
.rail-nav .tally.quiet { background: rgba(255, 255, 255, .14); color: #C8D6DE; }

.rail-foot {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .78rem;
  color: #7E95A2;
}
.rail-foot a { color: #C8D6DE; }

/* ------------------------------------------------------------- main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.topbar .who { text-align: right; line-height: 1.2; font-size: .8rem; }
.topbar .who b { display: block; font-size: .88rem; font-weight: 600; }

.burger {
  display: none;
  background: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  width: 36px; height: 34px;
  cursor: pointer;
}
.burger span { display: block; width: 16px; height: 2px; background: var(--ink); margin: 3px auto; }

.content { padding: 20px; flex: 1; }
.content > section { margin-bottom: 22px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 2px 0 0; color: var(--ink-soft); font-size: .9rem; }

/* ------------------------------------------------------------ panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: .98rem; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--hairline); background: #F8FAFB; }

.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* --------------------------------------------------- the ledger strip */
/* The one loud element: standing risk counters across the dashboard top. */
.ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}
.ledger > div {
  padding: 14px 16px;
  border-right: 1px solid var(--hairline);
  border-top: 3px solid transparent;
}
.ledger > div:last-child { border-right: 0; }
.ledger .n { font-size: 1.9rem; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.ledger .k { font-size: .82rem; color: var(--ink-soft); margin-top: 4px; }
.ledger .sub { font-size: .75rem; color: var(--ink-faint); }
.ledger > div.warn { border-top-color: var(--amber); }
.ledger > div.warn .n { color: var(--amber); }
.ledger > div.bad { border-top-color: var(--alert); background: var(--alert-wash); }
.ledger > div.bad .n { color: var(--alert); }
.ledger > div.good { border-top-color: var(--clear); }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.reg { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.reg th {
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  color: var(--ink-soft);
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  background: #F8FAFB;
  white-space: nowrap;
}
table.reg td { padding: 10px 12px; border-bottom: 1px solid #E8EDF0; vertical-align: top; }
table.reg tbody tr:hover { background: #F6F9FA; }
table.reg tbody tr { border-left: 3px solid transparent; }
table.reg tr.s-low { border-left-color: var(--clear); }
table.reg tr.s-medium { border-left-color: #6E8CA0; }
table.reg tr.s-high { border-left-color: var(--amber); }
table.reg tr.s-critical { border-left-color: var(--alert); }
table.reg tr.s-off { border-left-color: var(--hairline); opacity: .72; }
table.reg td .sub { display: block; font-size: .78rem; color: var(--ink-faint); }
table.reg .acts { white-space: nowrap; text-align: right; }

.empty { padding: 34px 20px; text-align: center; color: var(--ink-soft); }
.empty b { display: block; margin-bottom: 4px; color: var(--ink); }

/* ------------------------------------------------------------- chips */
.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: .76rem;
  border: 1px solid var(--hairline);
  background: #F3F6F8;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip.ok { background: #EAF4EE; border-color: #BFDCC9; color: var(--clear); }
.chip.warn { background: var(--amber-wash); border-color: #E6CE9A; color: #8A6112; }
.chip.bad { background: var(--alert-wash); border-color: #EDC2CA; color: var(--alert); }
.chip.info { background: var(--seal-wash); border-color: #B8D6CE; color: var(--seal-dark); }

.risk-low { color: var(--clear); }
.risk-medium { color: #4A6C86; }
.risk-high { color: var(--amber); }
.risk-critical { color: var(--alert); font-weight: 600; }

.bar { height: 6px; background: #E4EAEE; border-radius: 3px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--seal); }
.bar > i.warn { background: var(--amber); }
.bar > i.bad { background: var(--alert); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #F2F6F8; text-decoration: none; }
.btn.primary { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn.primary:hover { background: var(--seal-dark); }
.btn.danger { color: var(--alert); border-color: #E7C3CB; background: #fff; }
.btn.danger:hover { background: var(--alert-wash); }
.btn.small { padding: 4px 9px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------- forms */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .84rem; color: var(--ink-soft); margin-bottom: 4px; }
.field > span em { color: var(--alert); font-style: normal; }
input[type=text], input[type=password], input[type=email], input[type=url],
input[type=number], input[type=date], input[type=datetime-local], input[type=search],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: #fff;
  font: inherit;
  font-size: .9rem;
  color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--seal); outline: none; box-shadow: 0 0 0 2px rgba(20, 107, 92, .14); }
.checkline { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.checkline input { width: auto; }
.field-group { border-top: 1px solid var(--hairline); margin-top: 16px; padding-top: 14px; }
.field-group-title { font-size: .84rem; color: var(--ink-soft); margin: 0 0 10px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  background: #F8FAFB;
}
.filters .field { margin: 0; min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }

/* ------------------------------------------------------------ notices */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  margin-bottom: 14px;
  border-left: 3px solid var(--seal);
  font-size: .9rem;
}
.notice.success { border-left-color: var(--clear); background: #F1F8F4; }
.notice.error { border-left-color: var(--alert); background: var(--alert-wash); }
.notice.warning { border-left-color: var(--amber); background: var(--amber-wash); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ------------------------------------------------------------ dialogs */
dialog {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0;
  width: min(620px, 94vw);
  box-shadow: 0 14px 40px rgba(14, 26, 35, .22);
  color: var(--ink);
}
dialog::backdrop { background: rgba(14, 26, 35, .45); }
dialog .panel-body { max-height: 70vh; overflow-y: auto; }

/* ---------------------------------------------------------- pagination */
.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.pager a, .pager span {
  padding: 4px 9px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink-soft);
}
.pager .on { background: var(--seal); border-color: var(--seal); color: #fff; }

/* ------------------------------------------------------------- charts */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .82rem; margin-top: 10px; }
.legend i { width: 10px; height: 10px; display: inline-block; border-radius: 2px; margin-right: 5px; }

/* ------------------------------------------------------- audit survey */
.survey-item { border: 1px solid var(--hairline); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.survey-item h3 { font-size: .95rem; margin-bottom: 2px; }
.survey-item .desc { font-size: .84rem; color: var(--ink-soft); white-space: pre-line; margin: 4px 0 10px; }
.responses { display: flex; flex-wrap: wrap; gap: 6px; }
.responses label {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: .85rem;
  cursor: pointer;
  background: #fff;
}
.responses input { position: absolute; opacity: 0; width: 0; }
.responses input:focus-visible + span { outline: 2px solid var(--seal); }
.responses label:has(input[value=Pass]:checked) { background: #EAF4EE; border-color: var(--clear); color: var(--clear); }
.responses label:has(input[value=Warning]:checked) { background: var(--amber-wash); border-color: var(--amber); color: #8A6112; }
.responses label:has(input[value=Fail]:checked) { background: var(--alert-wash); border-color: var(--alert); color: var(--alert); }
.responses label:has(input[value="N/A"]:checked) { background: #EEF1F3; border-color: var(--ink-faint); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--hairline); padding: 0 0 14px 14px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--seal);
}
.timeline .when { font-size: .78rem; color: var(--ink-faint); }

.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 6px 14px; font-size: .9rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }

/* ------------------------------------------------------------ matrix */
.matrix { width: 100%; border-collapse: collapse; font-size: .86rem; }
.matrix th, .matrix td { border: 1px solid var(--hairline); padding: 7px 9px; }
.matrix thead th { background: #F8FAFB; position: sticky; top: 0; }
.matrix td.mid { text-align: center; }
.matrix tr.group td { background: #F1F5F7; font-weight: 600; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .rail {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  body.nav-open .rail { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(14, 26, 35, .4); z-index: 50;
  }
  .burger { display: block; }
  .content { padding: 14px; }
  table.reg { font-size: .86rem; }
  table.reg td, table.reg th { padding: 8px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --------------------------------------------------------------- print */
@media print {
  .rail, .topbar, .filters, .btn, .pager, .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .panel { border: 1px solid #999; box-shadow: none; page-break-inside: avoid; }
  .content { padding: 0; }
  a { color: #000; }
}
