/* Digital Chalking admin — Material 3 inspired, corporate SaaS. */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --line: #e1e6ee;
  --text: #1a2230;
  --muted: #5d6879;
  --primary: #1f5eff;
  --primary-ink: #ffffff;
  --primary-soft: #e8efff;
  --ok: #1b8a4b;  --ok-soft: #e4f5ea;
  --warn: #b26a00; --warn-soft: #fff3df;
  --err: #c62828; --err-soft: #fdeaea;
  --nav: #0f1b2d; --nav-ink: #c8d2e3; --nav-active: #1d2c45;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d121b; --surface: #151c28; --surface-2: #1b2433; --line: #283244;
    --text: #e6ebf3; --muted: #97a3b6; --primary: #6f9bff; --primary-ink: #0b1220; --primary-soft: #1b2a4a;
    --ok: #4cc386; --ok-soft: #12301f; --warn: #f0b04a; --warn-soft: #33270f; --err: #ff7a7a; --err-soft: #3a1717;
    --nav: #0a0f17; --nav-active: #172235; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d121b; --surface: #151c28; --surface-2: #1b2433; --line: #283244;
  --text: #e6ebf3; --muted: #97a3b6; --primary: #6f9bff; --primary-ink: #0b1220; --primary-soft: #1b2a4a;
  --ok: #4cc386; --ok-soft: #12301f; --warn: #f0b04a; --warn-soft: #33270f; --err: #ff7a7a; --err-soft: #3a1717;
  --nav: #0a0f17; --nav-active: #172235; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.ms { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1;
      display: inline-block; vertical-align: middle; font-variation-settings: "FILL" 0, "wght" 450, "GRAD" 0, "opsz" 24; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; color: #fff; font-weight: 650; font-size: 15px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg,#3d7bff,#22c1a6); display: grid; place-items: center; }
.brand small { display: block; font-weight: 450; font-size: 11.5px; color: var(--nav-ink); opacity: .8; }
.nav a { display: flex; align-items: center; gap: 12px; color: var(--nav-ink); padding: 9px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: var(--nav-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--nav-active); color: #fff; }
.nav a.active .ms { color: #7ea6ff; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 16px 12px 6px; }
.nav .spacer { flex: 1; }
.nav .who { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 10px 0; font-size: 12.5px; }
.nav .who b { color: #fff; font-weight: 600; display: block; }
.nav .who form { margin-top: 10px; }
.nav .who button { background: none; border: 1px solid rgba(255,255,255,.18); color: var(--nav-ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; display: inline-flex; gap: 6px; align-items: center; }
.nav .who button:hover { color: #fff; border-color: rgba(255,255,255,.35); }
.badge-role { display: inline-block; font-size: 10.5px; font-weight: 650; letter-spacing: .06em; padding: 2px 7px; border-radius: 99px; background: #3d2a00; color: #ffcf66; margin-top: 4px; }
.badge-role.council { background: #12305a; color: #9cc0ff; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 32px 0; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.content { padding: 20px 32px 48px; max-width: 1280px; }
.mobile-bar { display: none; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.side { grid-template-columns: minmax(0,2fr) minmax(300px,1fr); align-items: start; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; gap: 6px; align-items: center; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 20px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-top: 0; padding-top: 4px; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ms { font-size: 40px; display: block; margin: 0 auto 8px; opacity: .5; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.info { background: var(--primary-soft); color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: -2px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin-bottom: 14px; }
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 9px 16px; cursor: pointer;
       border: 1px solid transparent; background: var(--primary); color: var(--primary-ink); white-space: nowrap; text-decoration: none !important; }
.btn:hover { filter: brightness(1.06); }
.btn .ms { font-size: 18px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); filter: none; }
.btn.ghost { background: none; color: var(--primary); padding: 7px 10px; }
.btn.danger { background: var(--err); color: #fff; }
.btn.danger-outline { background: none; color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- flashes / callouts ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--err-soft); color: var(--err); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.callout { border: 1px dashed var(--line); border-radius: 10px; padding: 14px; background: var(--surface-2); }
.keybox { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 18px; font-weight: 600; letter-spacing: .04em; padding: 14px 16px; border-radius: 10px;
          background: var(--surface); border: 2px solid var(--primary); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; word-break: break-all; }
.newkey { border: 1px solid var(--primary); background: var(--primary-soft); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
details.danger { border: 1px solid color-mix(in srgb, var(--err) 30%, var(--line)); border-radius: 10px; padding: 12px 16px; margin-top: 16px; }
details.danger summary { cursor: pointer; color: var(--err); font-weight: 600; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: radial-gradient(1200px 600px at 10% 10%, #2a5bff 0%, #0f1b2d 55%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h1 { font-size: 36px; line-height: 1.15; max-width: 480px; margin-top: 28px; }
.login-hero p { color: #c8d2e3; max-width: 460px; font-size: 15px; }
.login-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; color: #dfe6f3; }
.login-hero li { display: flex; gap: 10px; align-items: center; }
.login-form { display: grid; place-items: center; padding: 32px 16px; }
.login-form .card { width: 100%; max-width: 420px; padding: 32px; }
.login-form input { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 16px; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- map ---------- */
.map-shell { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 82px); border-top: 1px solid var(--line); }
.map-panel { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.map-panel .pane { padding: 16px; border-bottom: 1px solid var(--line); }
#map { height: 100%; width: 100%; background: var(--surface-2); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tabs button { flex: 1; font: inherit; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 7px 8px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.flist { list-style: none; margin: 0; padding: 0; }
.flist li { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.flist li:hover { background: var(--surface-2); }
.flist li.sel { border-color: var(--primary); background: var(--primary-soft); }
.flist .meta { flex: 1; min-width: 0; }
.flist .meta b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-line { width: 22px; height: 5px; border-radius: 3px; display: inline-block; }
.legend-line.dash { background-image: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px) !important; background-color: transparent !important; height: 4px; }
.savebar { position: sticky; bottom: 0; background: var(--surface); padding: 14px 16px; border-top: 1px solid var(--line); margin-top: auto; display: flex; gap: 8px; align-items: center; }
.savebar .status { flex: 1; font-size: 12.5px; color: var(--muted); }
.search-results { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.search-results:empty { display: none; }
.search-results li { padding: 9px 12px; cursor: pointer; border-top: 1px solid var(--line); }
.search-results li:first-child { border-top: 0; }
.search-results li:hover { background: var(--surface-2); }
.modal-bg { position: fixed; inset: 0; background: rgba(10,15,25,.5); display: none; place-items: center; z-index: 2000; padding: 16px; }
.modal-bg.open { display: grid; }
.modal { background: var(--surface); border-radius: 16px; padding: 24px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { display: flex; gap: 8px; align-items: center; }

/* ---------- infringement evidence ---------- */
.evidence { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.shot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shot .hd { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.shot img.frame { display: block; width: 100%; aspect-ratio: 3/4; object-fit: contain; background: #000; cursor: zoom-in; }
.shot .crop { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.shot .crop img { height: 54px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.plate { font-family: "Roboto Mono", ui-monospace, monospace; font-weight: 700; letter-spacing: .08em; font-size: 15px; background: #fff; color: #111; border: 2px solid #111; border-radius: 6px; padding: 1px 8px; display: inline-block; }
.plate.lg { font-size: 26px; padding: 4px 14px; border-width: 3px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 500; }
.noimg { aspect-ratio: 3/4; display: grid; place-items: center; color: var(--muted); background: var(--surface-2); }
.timeline { display: flex; align-items: center; gap: 10px; padding: 16px 0 4px; }
.timeline .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); position: relative; overflow: hidden; }
.timeline .bar span { position: absolute; inset: 0 auto 0 0; background: var(--ok); }
.timeline .bar span.over { background: var(--err); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: none; z-index: 3000; cursor: zoom-out; }
.lightbox.open { display: grid; place-items: center; }
.lightbox img { max-width: 96vw; max-height: 96vh; }
.minimap { height: 220px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }

/* ---------- phone card (print) ---------- */
.print-card { max-width: 640px; margin: 32px auto; background: #fff; color: #111; border-radius: 16px; border: 1px solid #ddd; padding: 32px; }
.print-card .qr svg { width: 260px; height: 260px; display: block; }
@media print { .no-print { display: none !important; } body { background: #fff; } .print-card { border: 0; margin: 0 auto; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid.side { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 1500; transform: translateX(-100%); transition: transform .2s; }
  .nav.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--nav); color: #fff; position: sticky; top: 0; z-index: 1000; }
  .mobile-bar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
  .topbar { padding: 16px 16px 0; }
  .content { padding: 16px 16px 40px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .evidence { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 32px 20px; }
  .login-hero h1 { font-size: 26px; }
  .map-shell { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .map-panel { order: 2; border-right: 0; }
  #map { order: 1; min-height: 55vh; }
  .table-wrap { margin: 0 -20px; }
  th, td { padding: 10px 14px; }
}

/* grid children must be allowed to shrink, or wide tables push the page sideways on phones */
.grid > *, .row > * { min-width: 0; }
.card { min-width: 0; }
.tabs .opt.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs .opt { color: var(--muted); display: inline-flex; gap: 6px; align-items: center; justify-content: center; }

/* ---------- nav: collapsible Setup group ---------- */
.nav-group summary { list-style: none; display: flex; align-items: center; gap: 12px; color: var(--nav-ink); padding: 9px 12px; border-radius: 10px; font-weight: 500; cursor: pointer; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: var(--nav-active); color: #fff; }
.nav-group summary .chev { margin-left: auto; font-size: 18px; transition: transform .15s; }
.nav-group[open] summary .chev { transform: rotate(180deg); }
.nav-group a { padding-left: 28px; }

/* ---------- routes ---------- */
.route-phone { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 10px; }
.route-phone .sw { width: 14px; height: 14px; border-radius: 4px; margin-top: 3px; flex: none; }
.route-phone b { display: block; }
.cov-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.cov-bar span { display: block; height: 100%; }
.seg-btns { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.seg-btns button { flex: 1; font: inherit; font-size: 13px; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.seg-btns button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; }
[hidden] { display: none !important; }
.grid > .card + .card { margin-top: 0; }
