: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;
}

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;
}

.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;
}

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,
body.mode-summary .footnote {
  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;
}

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

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

.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;
}

.remarks-table th {
  font-size: 0.78rem;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  color: var(--muted);
}

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

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

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

body.mode-summary .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 {
  padding: 0.7rem 0.9rem;
  gap: 0.55rem;
}

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

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

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

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

body.mode-summary .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;
}

.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
  );
}

.stamp.complete_partial,
.cell.complete_partial {
  background: repeating-linear-gradient(
    -45deg,
    var(--off-fill),
    var(--off-fill) 4px,
    #faeeeb 4px,
    #faeeeb 8px
  );
  color: var(--off);
}

.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);
}

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);
}

.footnote {
  max-width: 1180px;
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

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;
}

.empty {
  padding: 1.2rem;
}

@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;
  }
}

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