:root {
  --ncr: #c9d7e6;
  --sheet: #eef2f6;
  --ink: #13233a;
  --rule: #c5ced8;
  --border: #c5ced8;
  --muted: #4d5f70;
  --ok: #1b6b48;
  --ok-fill: #c6e4d4;
  --mid: #b86a10;
  --mid-fill: #f3d7a6;
  --off: #8e3d38;
  --off-fill: #f0cfc9;
  --spine: #0f1c2e;
  --spine-ink: #e4edf5;
  --focus: #0b3d91;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* Placeholder standing in for a figure that depends on live fill data. Numbers
   are painted once, when every request has settled — never provisionally. */
.pending-num {
  color: var(--muted);
  opacity: 0.5;
  letter-spacing: 0.12em;
  animation: pending-pulse 1.4s ease-in-out infinite;
}

@keyframes pending-pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pending-num {
    animation: none;
  }
}

.live-notice {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--off);
  border-left-width: 4px;
  border-radius: 3px;
  background: var(--off-fill);
  color: var(--off);
  font-size: 0.86rem;
  line-height: 1.45;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  display: grid;
  grid-template-columns: 156px 1fr;
  font-family: var(--font);
  color: var(--ink);
  background: var(--spine);
}

body.spine-collapsed {
  grid-template-columns: 0 1fr;
}

/* The generator page carries no region spine, so its sheet takes the full width
   instead of landing in the 156px spine column. */
body.mode-gen {
  grid-template-columns: 1fr;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: #fff;
  padding: 0.5rem 1rem;
}

.skip:focus {
  left: 0;
  z-index: 10;
}

.spine {
  background: var(--spine);
  color: var(--spine-ink);
  padding: 0.85rem 0.4rem 1.4rem;
  min-height: 100vh;
  border-right: 6px solid #c45c2a;
  overflow: hidden;
  transition: width 0.18s ease, padding 0.18s ease, border-width 0.18s ease;
}

body.spine-collapsed .spine {
  width: 0;
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-width: 0;
  pointer-events: none;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: #f7f9fb;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem 0.35rem 0.4rem;
  cursor: pointer;
  border-radius: 6px;
  flex: 0 0 auto;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-toggle-icon {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 4px;
  background: #e8eef4;
  color: var(--focus);
}

.nav-toggle-icon svg {
  display: block;
}

.nav-toggle .icon-expand {
  display: none;
}

body.spine-collapsed .nav-toggle .icon-collapse {
  display: none;
}

body.spine-collapsed .nav-toggle .icon-expand {
  display: block;
}

.nav-toggle-label {
  color: var(--muted);
  font-weight: 600;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: #fff;
  border-color: #9eb0c3;
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.nav-toggle:hover .nav-toggle-icon,
.nav-toggle:focus-visible .nav-toggle-icon {
  background: #dce6f2;
}

.nav-backdrop {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  margin: 0 0 0.2rem;
  padding: 0.45rem 0.5rem 0.5rem 0.55rem;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  border-radius: 0 6px 6px 0;
}

.tab:hover,
.tab:focus-visible {
  background: #1a2d46;
  outline: 2px solid #e4edf5;
  outline-offset: 2px;
}

.tab.active {
  background: var(--ncr);
  color: var(--ink);
  border-left-color: #c45c2a;
}

.tab-meta {
  font-family: var(--font);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.sheet {
  background: var(--sheet);
  min-height: 100vh;
  padding: 1rem 1.15rem 1.6rem;
  min-width: 0;
}

.mast {
  max-width: 1180px;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
}

.mast-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem 0.75rem;
}

.update-status {
  margin: 0;
  max-width: 18rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
  text-align: right;
}

.update-status[data-state="missing"] {
  color: #9b2c2c;
}

.refresh-btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.refresh-btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--ink) 45%, transparent);
  background: color-mix(in srgb, var(--ink) 4%, #fff);
}

.refresh-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

h1 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

body.mode-summary #ledger-chrome,
body.mode-summary #register {
  display: none;
}

body.mode-remarks #ledger-chrome,
body.mode-remarks #register,
body.mode-remarks #summary,
body.mode-remarks #kpis,
body.mode-remarks .filter-bar,
body.mode-remarks .footnote {
  display: none;
}

body.mode-ledger #summary,
body.mode-ledger #remarks {
  display: none;
}

body.mode-summary #remarks {
  display: none;
}

/* ---- Data-quality modes (quality.js) -------------------------------------
   overview = Overall summary; dq = one data-quality dimension on a single page.
   The completeness legend and note belong to the completeness pages; the
   data-quality ones to the dimension pages. */
body:not(.mode-dq) #dq-filter,
body:not(.mode-dq) .dq-note {
  display: none;
}

body.mode-overview #ledger-chrome,
body.mode-overview #register,
body.mode-overview #remarks,
body.mode-overview #kpis,
body.mode-overview #status-filter,
body.mode-overview .footnote {
  display: none;
}

body.mode-dq #status-filter,
body.mode-dq .footnote,
body.mode-dq #ledger-chrome,
body.mode-dq #register,
body.mode-dq #remarks {
  display: none;
}

body.mode-summary .sheet,
body.mode-remarks .sheet,
body.mode-overview .sheet,
body.mode-dq .sheet {
  padding: 1.15rem 1.4rem 1.6rem;
}

.remarks-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Shown only when DHIS2's woreda set has drifted from the pinned scope. */
.remarks-alert {
  margin: 0 0 1.4rem;
  padding: 0.85rem 1rem;
  max-width: 52rem;
  border: 1px solid #e0b354;
  border-left-width: 4px;
  border-radius: 6px;
  background: #fdf6e3;
}

.remarks-alert-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
  color: #8a5a00;
}

.remarks-alert p {
  margin: 0;
}

.remarks-alert ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.remarks-alert li {
  margin-top: 0.25rem;
}

.remarks-alert code {
  padding: 0 0.25rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
}

.remarks-note {
  margin: 0 0 1rem;
  max-width: 52rem;
}

.remarks-table {
  width: 100%;
  max-width: 52rem;
  border-collapse: collapse;
}

.remarks-table th,
.remarks-table td {
  text-align: left;
  padding: 0.45rem 0.6rem 0.45rem 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

/* Headers are sticky (see th), so they need a solid fill or rows show through on scroll. */
.remarks-table th {
  background: var(--sheet);
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  color: var(--muted);
}

body.mode-summary h1,
body.mode-overview h1,
body.mode-dq h1 {
  font-size: 1.35rem;
}

body.mode-summary .thesis,
body.mode-overview .thesis,
body.mode-dq .thesis {
  margin: 0.45rem 0 0.9rem;
  font-size: 0.88rem;
}

body.mode-summary .legend,
body.mode-dq .legend {
  margin: 0;
  font-size: 0.78rem;
  gap: 0.45rem 0.65rem;
}

body.mode-summary .filter-bar,
body.mode-overview .filter-bar,
body.mode-dq .filter-bar {
  margin: 0 0 1.1rem;
}

.boards-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  max-width: 1180px;
}

.boards-month {
  margin-top: 1.1rem;
  max-width: 1180px;
}

body.mode-summary .board-head,
body.mode-dq .board-head {
  padding: 0.7rem 0.9rem;
  gap: 0.55rem;
}

body.mode-summary .board-head h2,
body.mode-dq .board-head h2 {
  font-size: 1rem;
}

body.mode-summary .board .seg button,
body.mode-dq .board .seg button,
body.mode-overview .overview-bar .seg button {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.32rem 0.6rem;
}

body.mode-summary table,
body.mode-dq table {
  font-size: 0.82rem;
}

body.mode-summary th,
body.mode-summary td,
body.mode-dq th,
body.mode-dq td {
  border-bottom: 0;
  padding: 0.35rem 0.45rem;
}

body.mode-summary .board,
body.mode-dq .board {
  background: #f7f9fb;
}

.rate-high {
  color: var(--ok);
  font-weight: 700;
}

.rate-mid {
  color: var(--mid);
  font-weight: 700;
}

.rate-low {
  color: var(--off);
  font-weight: 700;
}

@media (max-width: 860px) {
  .boards-top {
    grid-template-columns: 1fr;
  }
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
  max-width: 1180px;
  margin: 0 0 1rem;
}

.kpi {
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem 0.5rem;
  background: #f7f9fb;
}

/* Direct child only: a rate inside the figure (pctLabel's span) must keep the
   figure's size, not shrink to the label's. */
.kpi > span {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  color: var(--muted);
}

.kpi b {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.boards {
  display: grid;
  gap: 1.25rem;
  max-width: 1180px;
}

.board {
  border: 1px solid var(--border);
  background: #f7f9fb;
}

.board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.board-head h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
}

.board .seg {
  margin: 0;
}

.board table {
  background: transparent;
}

@media (max-width: 860px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.thesis {
  margin: 0.35rem 0 0.7rem;
  max-width: 46rem;
  font-size: 0.92rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-bottom: 0.9rem;
}

.seg {
  display: flex;
  border: 1px solid var(--border);
  background: #f7f9fb;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}

.seg button[aria-selected="true"] {
  background: var(--ink);
  color: #f4f7fa;
}

.seg button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.picker {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.picker.grow {
  flex: 1;
  min-width: 180px;
}

.picker select,
.picker input {
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--border);
  background: #f7f9fb;
  padding: 0.42rem 0.55rem;
  flex: 1;
  min-width: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  color: var(--muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1.15rem;
}

.filter-bar .seg {
  flex: 0 0 auto;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
}

.legend-btn:hover,
.legend-btn:focus-visible {
  border-color: var(--border);
  color: var(--ink);
  outline: none;
}

.legend-btn.is-active {
  border-color: var(--focus);
  background: #e8eef8;
  color: var(--ink);
  font-weight: 600;
}

.stamp {
  display: inline-block;
  width: 1.05rem;
  height: 0.85rem;
  border: 1px solid var(--border);
}

.stamp.complete {
  background: var(--ok-fill);
  outline: 2px solid var(--ok);
  outline-offset: -3px;
}

.stamp.in_progress {
  background: repeating-linear-gradient(
    -45deg,
    var(--mid-fill),
    var(--mid-fill) 3px,
    #f8ecd2 3px,
    #f8ecd2 6px
  );
}

/* complete_partial and complete_unmarked have no colour of their own: statusClass()
   in app.js folds them into in_progress and complete, so the table paints only the
   three statuses the legend offers. */

.stamp.not_started {
  background: #f4f7fa;
}

.stamp.no_expected {
  background: #d5dde6;
}

.register {
  max-width: 1180px;
  overflow-x: auto;
  background: #f7f9fb;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  border-bottom: 0;
  padding: 0.38rem 0.5rem;
  vertical-align: middle;
}

th {
  text-align: left;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  color: var(--muted);
  background: #f4f7fa;
  position: sticky;
  top: 0;
}

.sort-btn {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  padding: 0;
  text-align: inherit;
  width: 100%;
}

.sort-btn:hover,
.sort-btn:focus-visible,
.sort-btn[aria-pressed="true"] {
  color: var(--ink);
}

th.num .sort-btn {
  text-align: right;
}

th.num,
td.num {
  text-align: right;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.name-btn {
  border: 0;
  background: none;
  color: var(--focus);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.name-btn .muted {
  display: block;
  font-weight: 400;
}

.name-btn:focus-visible,
.cell:focus-visible {
  outline: 2px solid var(--focus);
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.cell {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  padding: 0.28rem 0.35rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  cursor: default;
  color: var(--ink);
}

.cell.drill {
  cursor: pointer;
}

.cell.complete {
  background: var(--ok-fill);
}

.cell.in_progress {
  background: repeating-linear-gradient(
    -45deg,
    var(--mid-fill),
    var(--mid-fill) 4px,
    #f8ecd2 4px,
    #f8ecd2 8px
  );
}

.cell.not_started {
  background: #f4f7fa;
  color: var(--off);
}

.cell.no_expected {
  background: #d5dde6;
  color: var(--muted);
}

/* Live fill data still loading: stay neutral rather than show a status colour
   that is about to be corrected. */
.cell.pending {
  background: #e7ecf2;
  color: var(--muted);
}

tr.is-woreda-office td:first-child {
  font-weight: 600;
}

.capture {
  display: inline-block;
  margin-left: 0.4rem;
  border: 1px solid var(--rule);
  padding: 0 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

/* ---- /gen_status: build a standalone report from the snapshot ---- */

.gen-panel {
  max-width: 1180px;
  margin: 1.2rem 0 0;
  padding: 1.2rem 1.3rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fb;
}

.gen-meta {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.gen-meta strong,
.gen-panel .warn {
  color: var(--ink);
}

.gen-panel .warn {
  color: #8a2d2d;
  font-weight: 600;
}

.gen-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem;
}

/* A picker never outgrows the row: a long option shrinks its select on a phone. */
.gen-controls .picker {
  max-width: 100%;
}

.gen-btn {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border: 1px solid #1f4e79;
  border-radius: 6px;
  background: #1f4e79;
  color: #fff;
  cursor: pointer;
}

a.gen-btn {
  display: inline-block;
  text-decoration: none;
}

.gen-btn:hover {
  background: #17608f;
  border-color: #17608f;
}

.gen-btn-ghost {
  background: transparent;
  color: #1f4e79;
}

.gen-btn-ghost:hover {
  background: #e8eef8;
  color: #17608f;
}

.gen-note {
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.gen-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

/* display:flex would otherwise override the hidden attribute before Generate. */
.gen-actions[hidden] {
  display: none;
}

.gen-size {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Multi-select lists on the Bulk Load template page. */
.pick-group {
  margin: 1rem 0 0;
  padding: 0.7rem 0.9rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.pick-group legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.pick-toggle {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: #1f4e79;
  cursor: pointer;
}

.pick-toggle:hover {
  background: #e8eef8;
}

.pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.3rem 1rem;
}

.pick-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.pick-note {
  font-size: 0.75rem;
  color: var(--muted);
}

.gen-result {
  max-width: 1180px;
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.gen-result li {
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--rule);
}

.gen-result .skipped {
  color: var(--muted);
}

.gen-preview {
  max-width: 1180px;
  margin-top: 1.4rem;
}

.gen-preview-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.gen-preview iframe {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.footnote,
.dq-note {
  max-width: 1180px;
  margin: 1.4rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--muted);
}

.footnote p,
.dq-note p {
  margin: 0 0 0.6rem;
}

.footnote p:last-child,
.dq-note p:last-child {
  margin-bottom: 0;
}

.footnote-lead {
  font-weight: 600;
  color: var(--ink);
}

.footnote-status {
  margin: 0 0 0.7rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.footnote-status li {
  display: grid;
  grid-template-columns: 1.05rem 1fr;
  gap: 0.5rem;
  align-items: start;
}

.footnote-status .stamp {
  margin-top: 0.2rem;
}

.footnote-status strong {
  color: var(--ink);
}

body.entry-open {
  overflow: hidden;
}

.entry-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.4rem 1.1rem;
}

.entry-modal[hidden] {
  display: none;
}

.entry-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(15, 28, 46, 0.72);
  cursor: pointer;
}

.entry-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1040px, 100%);
  max-height: min(86vh, 920px);
  background: #f7f9fb;
  border: 1px solid var(--border);
  border-left: 8px solid #c45c2a;
  box-shadow: 0 22px 56px rgba(9, 16, 28, 0.42);
}

.entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  flex: 0 0 auto;
  padding: 0.9rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.close-entry {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: #eef2f6;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.close-entry:focus-visible,
.entry-backdrop:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

tr.is-open td {
  background: rgba(198, 228, 212, 0.45);
}

.entry-head h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 700;
}

.entry-head p {
  margin: 0.2rem 0 0;
}

.entry-table {
  flex: 1 1 auto;
  overflow: auto;
}

.entry-table thead th {
  z-index: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .entry-modal:not([hidden]) .entry-panel {
    animation: entry-in 0.16s ease-out;
  }
}

@keyframes entry-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-row th {
  background: var(--ncr);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.req {
  color: var(--off);
  font-weight: 700;
}

.val.missing {
  color: var(--off);
  font-style: italic;
}

.val.filled {
  color: var(--ink);
  font-weight: 500;
}

/* Not expected because the form's gating question was answered No — distinct
   from Missing, which is a field that should have been filled. */
.val.na {
  color: var(--off);
  opacity: 0.65;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  cursor: help;
}

.empty {
  padding: 1.2rem;
}

/* ---- Spine: Overall summary + one group per data-quality dimension ---- */

.tab.overview {
  margin-bottom: 0.45rem;
  font-weight: 600;
}

.dim-group {
  margin: 0 0 0.15rem;
  padding-top: 0.3rem;
  border-top: 1px solid rgba(228, 237, 245, 0.12);
}

.dim-head {
  display: grid;
  grid-template-columns: 1.35rem 1fr;
  column-gap: 0.35rem;
  align-items: start;
  width: 100%;
  margin: 0 0 0.15rem;
  padding: 0.4rem 0.45rem 0.45rem 0.4rem;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.dim-head .tab-meta {
  grid-column: 2;
  font-weight: 400;
}

.dim-head:hover,
.dim-head:focus-visible {
  background: #1a2d46;
  outline: 2px solid #e4edf5;
  outline-offset: 2px;
}

.dim-group.is-active .dim-head {
  border-left-color: #c45c2a;
}

.dim-code {
  display: inline-grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.85;
}

.dim-tabs {
  display: none;
  padding-left: 0.55rem;
}

.dim-group.is-open .dim-tabs {
  display: block;
}

/* ---- Overall summary ---- */

.overview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  max-width: 1180px;
  margin: 0 0 1rem;
}

.overview-hint {
  margin: 0;
  font-size: 0.82rem;
}

.dim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 1rem;
  max-width: 1180px;
}

.dim-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 0.95rem 0.9rem;
  border: 1px solid var(--border);
  background: #f7f9fb;
}

.dim-card-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.dim-card-head .dim-code {
  background: var(--ink);
  border-color: var(--ink);
  color: #f4f7fa;
  opacity: 1;
}

.dim-card-head h2 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.open-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--focus);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
}

.open-btn:hover,
.open-btn:focus-visible {
  border-color: var(--focus);
  outline: none;
}

.dim-score {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
}

.dim-score b {
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dim-score > span {
  font-size: 0.8rem;
  color: var(--muted);
}

.meter {
  display: flex;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e7ecf2;
}

.meter-pass {
  background: var(--ok);
}

.meter-flag {
  background: var(--off);
}

.meter-miss {
  background: #b9c4cf;
}

.sub-list {
  display: grid;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.sub-list li {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  gap: 0.4rem;
  align-items: baseline;
  padding: 0.22rem 0;
  border-top: 1px solid var(--rule);
}


.sub-code {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sub-metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 560px) {
  /* Too narrow for name and figure side by side: the figure goes under the name. */
  .sub-list li {
    grid-template-columns: 2.2rem 1fr;
  }

  .sub-metric {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }
}






.overview-note {
  max-width: 1180px;
  margin: 1rem 0 0;
  font-size: 0.82rem;
}

.flag-ink {
  color: var(--off);
  font-weight: 700;
}

/* ---- Dimension summary ---- */

.boards-top.single {
  grid-template-columns: 1fr;
}

.board-sub {
  font-size: 0.78rem;
  font-weight: 400;
}

/* ---- Dimension page: checks × regions ---- */

body.mode-dq .overview-bar .seg button {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.32rem 0.6rem;
}

.dq-matrix {
  max-width: 1180px;
}

.dq-sub-title {
  margin: 0;
  padding: 0.65rem 0.75rem 0;
  font-weight: 700;
}

.dq-matrix-scroll {
  overflow-x: auto;
}

.dq-matrix table {
  min-width: 760px;
}

.dq-matrix td {
  vertical-align: top;
}

.dq-check-name {
  display: block;
  font-weight: 700;
}

.dq-check-sub {
  display: block;
  font-size: 0.76rem;
}

.dq-period {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8rem;
}

.cell.is-open {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.cell.dq-total {
  cursor: default;
  font-weight: 700;
}

.dq-drill-row > td {
  padding: 0 0.45rem 0.7rem;
}

.dq-drill {
  border: 1px solid var(--border);
  border-left: 4px solid var(--focus);
  border-radius: 4px;
  background: #fff;
}

.dq-drill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.dq-drill-head p {
  margin: 0;
  font-size: 0.84rem;
}

.dq-drill-table {
  width: 100%;
}

.dq-drill-table td:last-child,
.dq-drill-table th:last-child {
  width: 16rem;
}

.dq-site-row td:first-child {
  padding-left: 1.6rem;
}

.dq-drill .dq-caption {
  padding: 0.3rem 0.7rem 0.55rem;
}

.dim-head.active {
  background: var(--ncr);
  color: var(--ink);
}


.dq-notice {
  max-width: 1180px;
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid #e0b354;
  border-left-width: 4px;
  border-radius: 6px;
  background: #fdf6e3;
  color: #6b4500;
  font-size: 0.86rem;
}

/* ---- Region pages ---- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.35rem;
  font-weight: 600;
}

.crumb {
  border: 0;
  background: none;
  color: var(--focus);
  font: inherit;
  padding: 0;
  cursor: pointer;
}

.crumb:hover,
.crumb:focus-visible {
  text-decoration: underline;
  outline: none;
}

.crumb-sep {
  color: var(--muted);
}

.thesis-line {
  display: block;
  margin-top: 0.2rem;
}

.dq-caption {
  margin: 0;
  padding: 0.5rem 0.6rem 0.2rem;
  font-size: 0.78rem;
}

.stamp.dq-flag {
  background: var(--off-fill);
  outline: 2px solid var(--off);
  outline-offset: -3px;
}

.stamp.dq-pass {
  background: var(--ok-fill);
}

.stamp.dq-miss {
  background: #f4f7fa;
}

.cell.dq-flag {
  background: var(--off-fill);
  color: var(--off);
  font-weight: 700;
}

.cell.dq-pass {
  background: var(--ok-fill);
}

.cell.dq-miss {
  background: #f4f7fa;
  color: var(--muted);
  font-style: italic;
}

.cell.dq-na {
  background: #d5dde6;
  color: var(--muted);
}

/* ---- Site detail ---- */

.dq-detail {
  padding: 0 0 0.8rem;
}

.dq-rule {
  display: grid;
  gap: 0.35rem;
  margin: 0.8rem 1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.dq-side {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  column-gap: 0.5rem;
  font-size: 0.86rem;
}

/* Data-quality controls beside All / Pilot / Scale-up; only on the quality pages. */
.dq-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

body:not(.mode-overview):not(.mode-dq) .dq-bar {
  display: none;
}

/* What the checks are on: set apart from the other switches, so it is obvious which
   set of checks the page shows. */
.view-seg {
  border-color: var(--mid);
  background: #fff;
}

.view-seg button {
  color: var(--mid);
}

.view-seg button[aria-selected="true"] {
  background: var(--mid);
  color: #fff;
}

/* Remarks: one tab at a time. */
.remarks-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.def-card {
  max-width: 1180px;
  margin: 0 0 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  background: #fff;
}

.def-card h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.def-card p {
  margin: 0 0 0.45rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.def-subs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.5rem 1.5rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
}

.def-subs h4 {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.def-subs ul,
.def-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
  line-height: 1.5;
}

.def-subs p {
  margin: 0;
  font-size: 0.84rem;
}

.def-list {
  max-width: 1180px;
}

.def-list li {
  margin: 0 0 0.35rem;
}

/* An indicator flag's possible cause: the value to look at first. */
.dq-cause {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--off);
  text-align: left;
}

.dq-cause-row td {
  text-align: left;
  padding-top: 0;
}

.dq-cause b {
  font-weight: 700;
}

/* Indicator formulas: "Numerator" / "Denominator" need a wider label column. */
.dq-side.dq-side-wide {
  grid-template-columns: 6.6rem 1fr;
}

.ind-note {
  margin: 0 0 1rem;
}

.dq-side > :not(.dq-side-label) {
  grid-column: 2;
}

.dq-side-label {
  grid-row: span 3;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.dq-side-ds {
  font-weight: 700;
}

.dq-op {
  padding-left: 3.7rem;
  font-size: 0.86rem;
}

.dq-rule-note {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
}

.dq-detail table {
  margin: 0;
}

.dq-rel {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.verdict {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.verdict.v-flagged {
  background: var(--off-fill);
  color: var(--off);
}

.verdict.v-passed {
  background: var(--ok-fill);
  color: var(--ok);
}

.verdict.v-missing {
  background: #eef2f6;
  color: var(--muted);
}

.val.out {
  padding: 0 0.3rem;
  border-radius: 3px;
  background: var(--off-fill);
  color: var(--off);
  font-weight: 700;
}

.dq-facs td {
  padding-top: 0;
}

.dq-facs summary {
  cursor: pointer;
  color: var(--focus);
  font-size: 0.8rem;
}

.dq-facs ul {
  margin: 0.3rem 0 0.2rem;
  padding-left: 1.1rem;
  columns: 2;
  font-size: 0.8rem;
}

.dq-result-row td {
  border-top: 1px solid var(--border);
}

.dq-detail-note {
  margin: 0.8rem 1rem 0;
  font-size: 0.8rem;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  body.spine-collapsed {
    grid-template-columns: 1fr;
  }

  .spine {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    width: min(78vw, 240px);
    min-height: 100vh;
    padding: 0.85rem 0.5rem 1.2rem;
    border-right: 6px solid #c45c2a;
    border-bottom: 0;
    display: block;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    pointer-events: auto;
    overflow-y: auto;
  }

  body.spine-collapsed .spine {
    width: min(78vw, 240px);
    padding: 0.85rem 0.5rem 1.2rem;
    border-right-width: 6px;
    transform: translateX(-105%);
    pointer-events: none;
  }

  body:not(.spine-collapsed) .spine {
    transform: translateX(0);
    pointer-events: auto;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(15, 28, 46, 0.45);
  }

  .nav-backdrop[hidden] {
    display: none;
  }

  .tab {
    width: 100%;
    border-left: 3px solid transparent;
    border-bottom: 0;
  }

  .tab.active {
    border-left-color: #c45c2a;
    border-bottom-color: transparent;
  }

  .sheet {
    padding: 0.85rem 0.85rem 1.3rem;
  }

  h1 {
    font-size: 1.2rem;
  }

  .nav-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .nav-toggle {
    padding: 0.4rem;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .boards-top {
    grid-template-columns: 1fr;
  }

  .mast-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .update-status {
    max-width: none;
    text-align: left;
  }
}

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