:root {
  --ink: #14202b;
  --muted: #5b6b78;
  --line: #d6dee5;
  --bg: #f3f6f8;
  --card: #ffffff;
  --brand: #0b4f6c;
  --brand-2: #127aa6;
  --danger: #b3261e;
  --ok: #1e7a3c;
  /* Condition categories: diverging blue <-> red with a gray midpoint (validated for
     red-green colour blindness; categories are always labelled as well). */
  --vg: #1757ac;
  --g: #6aabf1;
  --f: #7a7a7a;
  --p: #f08a5d;
  --vp: #b71c1c;
  --none: #c5cfd6;
  --radius: 10px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 72px; scroll-padding-bottom: 96px; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.4; }
a { color: var(--brand-2); }
.hidden { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .6rem .9rem; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: baseline; gap: .5rem; color: #fff; text-decoration: none; }
.brand-mark { font-weight: 800; letter-spacing: .06em; }
.brand-text { font-size: .9rem; opacity: .9; }
.who { font-size: .8rem; text-align: right; opacity: .95; }
.who button { margin-left: .4rem; }

main { max-width: 760px; margin: 0 auto; padding: .9rem .8rem 5rem; }
h1 { font-size: 1.3rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
.sub { color: var(--muted); font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin: .6rem 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }

button, .btn { font: inherit; border: 1px solid var(--brand-2); background: #fff; color: var(--brand);
  border-radius: 8px; padding: .55rem .9rem; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; }
button.primary, .btn.primary { background: var(--brand-2); color: #fff; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.small { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
.wide { width: 100%; }

label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { font: inherit; width: 100%; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  min-height: 44px; }
textarea { min-height: 70px; }

.banner { padding: .5rem .9rem; background: #fff4d6; color: #6b4e00; font-size: .9rem; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); max-width: 92vw; padding: .7rem 1rem;
  border-radius: 8px; background: var(--ink); color: #fff; z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.toast.error { background: var(--danger); }

.list-item { display: block; color: inherit; text-decoration: none; }
.chip { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #e6eef3; color: var(--brand); }
.status-DRAFT { background: #eceff1; color: #455a64; }
.status-SUBMITTED { background: #fff1d6; color: #8a5a00; }
.status-APPROVED { background: #dcf3e3; color: var(--ok); }

.legend { font-size: .8rem; color: var(--muted); }
.defect h3 { font-size: 1rem; margin: 0; }
.defect .code { font-size: .72rem; color: var(--muted); }
.defect.unsaved { border-color: var(--brand-2); box-shadow: 0 0 0 2px rgba(18,122,166,.15); }
.defect.missing { border-left: 4px solid var(--p); }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; margin-top: .35rem; }
.scale button { min-height: 44px; padding: .2rem; font-weight: 700; }
.scale button[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.scale-label { font-size: .78rem; color: var(--muted); margin-top: .5rem; }
.absent { margin-top: .5rem; }
.absent[aria-pressed="true"] { background: var(--ok); color: #fff; border-color: var(--ok); }
.result-line { font-size: .82rem; color: var(--muted); margin-top: .4rem; }

.indices { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.index { border-radius: 8px; padding: .45rem .2rem; text-align: center; color: #fff; background: #90a4ae; }
.index .name { font-size: .72rem; font-weight: 700; letter-spacing: .04em; }
.index .score { font-size: 1.35rem; font-weight: 800; }
.index .cat { font-size: .62rem; }
.cat-VERY-GOOD { background: var(--vg); color: #fff; }
.cat-GOOD { background: var(--g); color: #0b0b0b; }
.cat-FAIR { background: var(--f); color: #fff; }
.cat-POOR { background: var(--p); color: #0b0b0b; }
.cat-VERY-POOR { background: var(--vp); color: #fff; }
.flags { margin: .5rem 0 0; padding-left: 1.1rem; }
.flags li { margin: .2rem 0; }
.flags .alert { color: var(--danger); font-weight: 600; }

.actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: .8rem 0 .4rem; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .35rem .3rem; border-bottom: 1px solid var(--line); text-align: left; }
td.num, th.num { text-align: right; }
.history li { font-size: .85rem; margin: .2rem 0; }
.password-box { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.35rem; letter-spacing: .06em;
  padding: .6rem; margin: .5rem 0; background: #f6fbf7; border: 1px dashed var(--ok); border-radius: 8px; text-align: center;
  user-select: all; word-break: break-all; }

/* ------------------------------------------------------------------ office screens (dashboard, MCA) */
body[data-view="dashboard"] main, body[data-view="mca"] main, body[data-view="gharama"] main { max-width: 1280px; }
.tip { position: fixed; z-index: 60; max-width: 320px; padding: .45rem .6rem; border-radius: 8px; background: #191919; color: #efefef;
  font-size: .8rem; line-height: 1.35; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.tip-title { font-weight: 600; color: #fff; }
.dash-head h1 { margin-bottom: .1rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; margin: .7rem 0; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.panel-head h2 { margin: 0; font-size: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin: .4rem 0 .2rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .8rem; }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.55rem; font-weight: 650; line-height: 1.2; margin-top: .15rem; }
.stat-sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.stat-chip { margin-top: .3rem; }
.meter { height: 8px; border-radius: 4px; background: #d7e6f5; margin-top: .45rem; overflow: hidden; }
.meter > div { height: 100%; background: #257de0; border-radius: 4px; }
.chip-cat { display: inline-block; min-width: 2.1em; text-align: center; font-size: .72rem; font-weight: 700; padding: .08rem .35rem; border-radius: 4px; }
.cat-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .8rem; color: var(--ink); margin: .2rem 0 .5rem; }
.cat-legend .key { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.swatch.line { width: 18px; height: 4px; border-radius: 2px; }
.swatch.none { background: var(--none); }
.profile { display: grid; gap: .45rem; }
.profile-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) 76px minmax(200px, 4fr) 70px; gap: .6rem; align-items: center; }
.profile-row.small { grid-template-columns: 1fr auto; gap: .25rem .6rem; }
.profile-row.small .seg-bar { grid-column: 1 / -1; }
.profile-name { font-size: .88rem; }
.profile-score { font-size: .95rem; white-space: nowrap; }
.profile-pv { text-align: right; white-space: nowrap; }
.seg-bar { display: flex; gap: 2px; height: 22px; }
.seg { display: flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 700; min-width: 2px; }
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:only-child { border-radius: 4px; }
.seg.empty { flex: 1; background: #eef2f5; color: var(--muted); font-weight: 400; border-radius: 4px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 0 .7rem; align-items: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .7rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 0 .7rem; align-items: start; }
.grid-2-1 > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
@media (max-width: 980px) { .grid-2-1, .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .profile-row, .profile-row.small { grid-template-columns: 1fr auto; }
  .profile-row .seg-bar { grid-column: 1 / -1; }
  .profile-row .profile-pv { display: none; }
}
.table-scroll { overflow-x: auto; }
.table-scroll table { font-variant-numeric: tabular-nums; }
.map-wrap { position: relative; }
.map-box { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; overflow: hidden; touch-action: none; }
.map { display: block; width: 100%; height: auto; max-height: 620px; cursor: grab; }
.map path.road { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.map path.road.assessed { stroke-width: 2.6px; }
.map path.road.none { stroke-width: 1.2px; stroke-dasharray: 3 3; }
.map path.road.hover { stroke-width: 5px; }
.map path.road-hit { fill: none; stroke: transparent; stroke-width: 10px; vector-effect: non-scaling-stroke; cursor: pointer; }
.map-tools { position: absolute; top: .4rem; right: .4rem; display: flex; gap: .25rem; }
.map-tools button { background: rgba(255,255,255,.92); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e7e7e7; stroke-width: 1; }
.chart .axis { stroke: #c2c2c2; stroke-width: 1; }
.chart .tick { font-size: 11px; fill: #666; font-variant-numeric: tabular-nums; }
.chart .col { fill: #257de0; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(37,125,224,.08); }
.flag-list { list-style: none; margin: 0; padding: 0; }
.flag-list li { display: flex; gap: .6rem; align-items: flex-start; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.flag-list li:last-child { border-bottom: 0; }
.flag-n { min-width: 2.2rem; text-align: center; font-weight: 700; border-radius: 6px; padding: .15rem .3rem; background: #eef2f5; color: var(--muted); }
.flag-list li.on .flag-n { background: #fde3e3; color: #8e1b1b; }
.activity { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
.activity li { padding: .3rem 0; border-bottom: 1px solid var(--line); }
@media print {
  .topbar, .no-print, .map-tools, #toast, #tip { display: none !important; }
  body, main { background: #fff; }
  main { max-width: none !important; padding: 0; }
  .panel, .stat { break-inside: avoid; }
  .grid-2-1, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: .3rem 0 .6rem; }
.tabs .tab { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-size: .92rem; }
.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand-2); font-weight: 600; }
.ahp-sub { margin: .2rem 0 .4rem; }
.notice { background: #fff4d6; border: 1px solid #f0d58a; color: #5b4300; border-radius: 8px; padding: .55rem .7rem; font-size: .88rem; }
.notice.muted { background: #eef2f5; border-color: var(--line); color: var(--ink); }
.list-code { display: inline-block; min-width: 2.6em; text-align: center; padding: .05rem .35rem; border-radius: 4px; background: var(--brand); color: #fff; font-size: .8rem; }
.mca-list table td.score { cursor: help; }
.tie { display: inline-block; margin-left: .2rem; color: var(--danger); font-weight: 700; cursor: help; }
.alert { color: var(--danger); }
.sens li { margin: .25rem 0; font-size: .88rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: var(--ink); }
table.mca-input select, table.mca-input input { min-height: 36px; padding: .3rem .4rem; }
table.mca-input td { vertical-align: top; }
table.mca-input td:nth-child(3), table.mca-input td:nth-child(6) { width: 64px; }
table.mca-input td:nth-child(4), table.mca-input td:nth-child(5) { width: 92px; }
table.mca-input tr.dirty td { background: #f2f8fd; }
table.ahp th, table.ahp td { text-align: center; }
table.ahp th.rowhead { text-align: left; white-space: nowrap; }
table.ahp select { min-height: 34px; padding: .2rem; width: 4.2rem; }
table.ahp td.diag { color: var(--muted); background: #f4f6f8; }
table.ahp td.recip { color: var(--muted); }
.weights { display: grid; gap: .4rem; }
.wrow { display: grid; grid-template-columns: minmax(150px, 1.4fr) 2fr 92px; gap: .6rem; align-items: center; font-size: .88rem; }
.wrow .num { text-align: right; }
.wbar { height: 14px; background: #eef2f5; border-radius: 0 4px 4px 0; }
.wbar > div { height: 100%; background: #257de0; border-radius: 0 4px 4px 0; }
.small-note { font-size: .72rem; }

/* road sections (Hatua 30) */
.btn.disabled { opacity: .45; pointer-events: none; }
.btn.small { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
.alert { color: var(--danger); }
.sec-strip { display: flex; gap: 2px; margin: .6rem 0 .2rem; height: 26px; border-radius: 6px; overflow: hidden; }
.sec-piece { display: flex; align-items: center; justify-content: center; min-width: 4px; font-size: .72rem; color: #fff;
  background: var(--none); white-space: nowrap; overflow: hidden; }
.sec-piece.surf-BITUMINOUS { background: #2b2f33; }
.sec-piece.surf-CONCRETE { background: #7d8a96; }
.sec-piece.surf-GRAVEL { background: #a8742a; }
.sec-piece.surf-EARTH { background: #6b4a2b; }
.piece-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: .6rem; align-items: center;
  border-top: 1px solid var(--line); padding-top: .6rem; }
.break-row .row { align-items: center; }
.break-row .row > button { flex: none; }

/* interventions and costs (Hatua 31) */
table.cost-table tr.detail > td { background: #f7f9fb; padding: .2rem .4rem .6rem 2rem; }
table.cost-table td .chip-cat { margin-right: .25rem; }
button.linkish { border: 0; background: none; color: var(--brand-2); min-height: 0; padding: 0 .2rem; font-size: .95rem; cursor: pointer; }
table.sub-table { width: 100%; font-size: .85rem; }
table.sub-table th { font-weight: 600; color: var(--muted); }
table.sub-table.edit input { min-height: 34px; padding: .25rem .4rem; }
.recipe-card { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin: .4rem 0; min-width: 0; }
.recipe-card .row.spread { margin-bottom: .3rem; }
table.rates td:nth-child(2) { min-width: 16rem; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink); }
.nowrap { white-space: nowrap; }
.backup-ok { margin: .2rem 0 .4rem; color: var(--ok); }
