:root {
  --bg: #f3f5f8; --panel: #ffffff; --ink: #18212b; --muted: #627083; --line: #e1e6ee;
  --brand: #163a5f; --brand-2: #1f5487; --accent: #f2c14e;
  --sev-high: #d33f49; --sev-med: #e89b2c; --sev-low: #3f8fd2;
  --pci-good: #2f9e5e; --pci-fair: #b9b12a; --pci-poor: #e07b2a; --pci-vpoor: #c4303b;
  --ok: #2f9e5e; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f141a; --panel:#171e27; --ink:#e6ebf1; --muted:#93a1b3; --line:#263140; --brand:#0e2944; --brand-2:#3a79b8; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink);
  display: grid; grid-template-columns: 210px 1fr; grid-template-rows: 60px 1fr; grid-template-areas: "top top" "nav main"; }
.topbar { grid-area: top; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: var(--brand); font-weight: 800; display: grid; place-items: center; letter-spacing: -.5px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .78; }
.top-right { display: flex; gap: 14px; align-items: center; }
.badge-demo { background: rgba(242,193,78,.18); color: var(--accent); border: 1px solid rgba(242,193,78,.5); padding: 3px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.survey-pick { font-size: 12px; display: flex; gap: 8px; align-items: center; opacity: .95; }
.survey-pick select { background: #fff; color: #18212b; border: 0; border-radius: 6px; padding: 6px 8px; min-width: 250px; }
.sidenav { grid-area: nav; background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.sidenav button { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 8px; color: var(--muted); display: flex; gap: 10px; align-items: center; font-weight: 500; }
.sidenav button span { width: 18px; text-align: center; }
.sidenav button:hover { background: var(--bg); color: var(--ink); }
.sidenav button.active { background: color-mix(in srgb, var(--brand-2) 12%, transparent); color: var(--brand-2); font-weight: 600; }
main { grid-area: main; overflow: auto; padding: 18px 20px 40px; }
.view { display: none; flex-direction: column; gap: 16px; }
.view.active { display: flex; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-h h3 { margin: 0; font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }
.note { color: var(--muted); font-size: 12px; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpis.small .kpi { box-shadow: none; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
.map-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
#map { height: 540px; }
.map-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; user-select: none; }
.chip.off { opacity: .45; text-decoration: line-through; }
.chip b { font-weight: 600; margin-left: 4px; color: var(--muted); }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 8px 12px; font-size: 12px; border-top: 1px solid var(--line); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend .bar { display: inline-block; width: 18px; height: 5px; border-radius: 3px; margin-right: 5px; vertical-align: 2px; }
.legend .sep { width: 1px; height: 14px; background: var(--line); }
.side { max-height: 646px; overflow: auto; }
.chart-wrap { position: relative; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.table-wrap { overflow: auto; max-height: 560px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; white-space: nowrap; }
.tbl td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--bg); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.sev-High { background: color-mix(in srgb, var(--sev-high) 15%, transparent); color: var(--sev-high); }
.sev-Medium { background: color-mix(in srgb, var(--sev-med) 18%, transparent); color: #b06d08; }
.sev-Low { background: color-mix(in srgb, var(--sev-low) 15%, transparent); color: var(--sev-low); }
.band-Good { background: color-mix(in srgb, var(--pci-good) 15%, transparent); color: var(--pci-good); }
.band-Fair { background: color-mix(in srgb, var(--pci-fair) 20%, transparent); color: #857f12; }
.band-Poor { background: color-mix(in srgb, var(--pci-poor) 15%, transparent); color: var(--pci-poor); }
.band-Very { background: color-mix(in srgb, var(--pci-vpoor) 15%, transparent); color: var(--pci-vpoor); }
.st { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.st-verified { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.st-work_ordered { color: var(--brand-2); border-color: color-mix(in srgb, var(--brand-2) 40%, transparent); }
.st-repaired { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.st-rejected { text-decoration: line-through; }
.chg { font-size: 11px; font-weight: 600; }
.chg-new { color: var(--sev-high); } .chg-worsened { color: var(--pci-poor); } .chg-persisting { color: var(--muted); } .chg-repaired { color: var(--ok); }
.prio { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.prio i { display: inline-block; height: 6px; border-radius: 3px; background: var(--sev-high); }
.btn { all: unset; cursor: pointer; background: var(--brand-2); color: #fff; padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; text-align: center; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--brand-2); border: 1px solid var(--line); }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.green { background: var(--ok); } .btn.red { background: var(--sev-high); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
select, input { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.ev { position: relative; border-radius: 8px; overflow: hidden; background: #222; }
.ev img { display: block; width: 100%; }
.ev .box { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.5); border-radius: 2px; }
.ev .box span { position: absolute; top: -18px; left: -2px; background: var(--accent); color: #111; font-size: 10px; font-weight: 700; padding: 1px 4px; white-space: nowrap; }
.ev .box.other { border-color: rgba(255,255,255,.55); border-style: dashed; }
.ev .box.other span { display: none; }
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 5px 10px; font-size: 13px; margin: 12px 0; }
.kv div:nth-child(odd) { color: var(--muted); }
.detail h2 { font-size: 16px; margin: 0 0 2px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.timeline { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tl { flex: 0 0 110px; font-size: 11px; border: 1px solid var(--line); border-radius: 8px; padding: 5px; cursor: pointer; }
.tl.cur { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2); }
.tl img { width: 100%; border-radius: 4px; display: block; margin-bottom: 4px; }
.audit { font-size: 12px; color: var(--muted); padding-left: 16px; margin: 4px 0; }
h4 { margin: 14px 0 6px; font-size: 13px; }
.pairs { display: flex; flex-direction: column; gap: 10px; max-height: 560px; overflow: auto; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.pair .cap { font-size: 12px; margin-top: 4px; }
.pair .head { grid-column: 1 / -1; font-size: 12px; display: flex; justify-content: space-between; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form label.toggle { flex-direction: row; }
.form .row { display: flex; gap: 10px; }
.form .row > * { flex: 1; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); }
.drop.hover { border-color: var(--brand-2); background: color-mix(in srgb, var(--brand-2) 6%, transparent); }
.link { color: var(--brand-2); cursor: pointer; text-decoration: underline; display: inline !important; }
.insp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.insp-grid .card { box-shadow: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: zoom-in; }
.gallery figcaption { font-size: 12px; color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(10,15,25,.55); display: none; align-items: center; justify-content: center; z-index: 2000; }
.modal.open { display: flex; }
.modal-body { background: var(--panel); border-radius: 12px; width: min(560px, 94vw); max-height: 90vh; overflow: auto; padding: 18px; position: relative; }
.modal-body.wide { width: min(1100px, 96vw); }
.modal-x { all: unset; cursor: pointer; position: absolute; right: 12px; top: 8px; font-size: 24px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px); background: #18212b; color: #fff; padding: 10px 16px; border-radius: 8px; transition: transform .25s; z-index: 3000; font-size: 13px; }
.toast.show { transform: translateX(-50%) translateY(0); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.mini-charts { display: flex; flex-direction: column; gap: 14px; }
code { background: var(--bg); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand-2); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1100px) {
  .dash-grid, .two { grid-template-columns: 1fr; }
  .side { max-height: none; }
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "top" "nav" "main"; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; height: auto; }
  .brand-sub { display: none; }
  .survey-pick select { min-width: 0; }
  .sidenav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px; }
  .sidenav button { white-space: nowrap; }
  main { padding: 12px 16px 30px; }
  #map { height: 380px; }
}

/* sections & notices */
.sec-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.sec-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.sec-card.sel { border-color: var(--brand-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-2) 35%, transparent); }
.sec-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sec-code { background: var(--brand); color: #fff; font-weight: 700; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.sec-card .party { font-weight: 600; font-size: 13px; line-height: 1.3; }
.sec-card .nums { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.sec-card .nums b { display: block; font-size: 18px; color: var(--ink); }
.sec-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.dlp-on { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.dlp-off { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.overdue { background: color-mix(in srgb, var(--sev-high) 14%, transparent); color: var(--sev-high); }
.resp { border: 1px solid var(--line); border-left: 4px solid var(--brand-2); border-radius: 8px; padding: 8px 10px; margin: 10px 0; font-size: 13px; }
.resp .muted { font-size: 12px; }
.compose label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.compose input { width: 100%; }
.mailbody { border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 360px; overflow: auto; background: #fff; color: #111; }
.mailbody table { font-size: 12px; }
.sec-label { background: var(--brand); color: #fff; font: 700 11px/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 4px; border: 2px solid #fff; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
@media (max-width: 1100px) { .sec-grid { grid-template-columns: 1fr; } }
#noticeLog td { white-space: nowrap; font-size: 12px; }
#noticeLog td:nth-child(4) { white-space: normal; word-break: break-all; min-width: 120px; }
