/* Water level dashboard (SYS-011). Plain CSS, no build step. */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #18212b;
  --muted: #637083;
  --line: #dfe4ea;
  --accent: #1f6fb2;
  --accent-ink: #ffffff;
  --green: #1e8a4c;
  --green-bg: #e3f4ea;
  --yellow: #a26a00;
  --yellow-bg: #fdf1d6;
  --red: #c0392b;
  --red-bg: #fbe5e2;
  --blue-bg: #e3eefa;
  --grey-bg: #eceff3;
  --side: #14324f;
  --side-ink: #d7e3ef;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --panel: #17202a; --ink: #e4ebf2; --muted: #93a1b2; --line: #2a3644;
    --accent: #4c9be0; --green: #4cc27f; --green-bg: #173326; --yellow: #e2b04a;
    --yellow-bg: #362c14; --red: #ef7b6e; --red-bg: #3a1e1b; --blue-bg: #1a2b3d;
    --grey-bg: #222c37; --side: #0b1825; --side-ink: #c4d3e2; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --panel: #17202a; --ink: #e4ebf2; --muted: #93a1b2; --line: #2a3644;
  --accent: #4c9be0; --green: #4cc27f; --green-bg: #173326; --yellow: #e2b04a;
  --yellow-bg: #362c14; --red: #ef7b6e; --red-bg: #3a1e1b; --blue-bg: #1a2b3d;
  --grey-bg: #222c37; --side: #0b1825; --side-ink: #c4d3e2; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 15px; padding: 0 8px 18px; color: #fff; }
.brand svg { flex: none; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; padding: 0 7px; border-radius: 9px; }
.side-foot { border-top: 1px solid rgba(255,255,255,.12); margin-top: 16px; padding: 14px 10px 0; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot button { margin-top: 10px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-102%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 4px; }
  .main { padding: 16px 16px 60px; }
}

/* ---- panels ---- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .g3, .g-side { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .g2 { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 16px 16px 0; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: block; color: var(--ink); }
.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .v { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.warn .v { color: var(--yellow); }
.kpi.bad .v { color: var(--red); }
.kpi.good .v { color: var(--green); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--grey-bg); white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--blue-bg); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---- badges ---- */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--grey-bg); color: var(--muted); }
.b-live, .b-done, .b-green, .b-ok { background: var(--green-bg); color: var(--green); }
.b-commissioning, .b-submitted, .b-yellow, .b-warning, .b-maintenance { background: var(--yellow-bg); color: var(--yellow); }
.b-planned, .b-open, .b-ready, .b-registered { background: var(--blue-bg); color: var(--accent); }
.b-red, .b-critical, .b-retired, .b-cancelled, .b-suspended { background: var(--red-bg); color: var(--red); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--green); }
.dot.off { background: var(--red); }
.flag { color: var(--red); font-weight: 600; }

/* ---- forms ---- */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--red); }
button.go { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; }
.seg button.on { background: var(--accent); color: #fff; }
.hint { font-size: 12px; color: var(--muted); margin-top: -6px; margin-bottom: 12px; }
.err { color: var(--red); margin: 8px 0; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #14324f, #1f6fb2); }
.login form { background: var(--panel); padding: 28px; border-radius: 14px; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login h1 { margin-bottom: 4px; display: flex; gap: 10px; align-items: center; }
.login p { margin: 0 0 20px; color: var(--muted); }
.login button { width: 100%; justify-content: center; padding: 10px; }

/* ---- modal / toast ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 20, 30, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h2 { margin-bottom: 16px; }
.modal .btn-row { justify-content: flex-end; margin-top: 8px; }
#toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: grid; gap: 8px; }
.toast { background: #1b2733; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.bad { background: var(--red); }

/* ---- map / chart ---- */
.map { height: 340px; border-radius: 8px; z-index: 0; }
.map.small { height: 220px; }
.chart-box { position: relative; height: 300px; }
.leaflet-popup-content { font: 13px/1.4 system-ui, sans-serif; }

/* ---- lists ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.timeline li { font-size: 13px; }
.timeline .when { color: var(--muted); white-space: nowrap; min-width: 92px; font-size: 12px; }

/* ---- checklist ---- */
.check { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.check:last-child { border-bottom: 0; }
.check .cid { font-weight: 700; color: var(--muted); }
.check .lbl { font-weight: 600; }
.check .det { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

/* ---- technician steps ---- */
.step { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 12px; box-shadow: var(--shadow); }
.step > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.step > header .n { width: 26px; height: 26px; border-radius: 50%; background: var(--grey-bg); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.step.ok > header .n { background: var(--green); color: #fff; }
.step.bad > header .n { background: var(--red); color: #fff; }
.step > header h2 { margin: 0; flex: 1; font-size: 15px; }
.step > div { padding: 14px 16px; }
.result { padding: 10px 12px; border-radius: 8px; margin-top: 4px; font-size: 13px; }
.result.ok { background: var(--green-bg); color: var(--green); }
.result.bad { background: var(--red-bg); color: var(--red); }
.result.warn { background: var(--yellow-bg); color: var(--yellow); }
.photos { display: flex; flex-wrap: wrap; gap: 10px; }
.photo { width: 120px; }
.photo img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; background: var(--grey-bg); }
.photo .cap { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-top: 2px; }
.photo .cap button { padding: 0 6px; font-size: 11px; }

.job-card { display: block; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 10px; }
.job-card:hover { border-color: var(--accent); text-decoration: none; }
.job-card .t { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--muted); border: 1px solid var(--line); background: var(--panel); }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs a:hover { text-decoration: none; }
.lab-res { font-size: 12px; }
.lab-res span { margin-right: 8px; }
.pass { color: var(--green); font-weight: 600; }
.fail { color: var(--red); font-weight: 600; }
.pending { color: var(--muted); }

/* ---- accounts (SYS-011 follow-up) ---- */
.b-role-superuser { background: #efe4fb; color: #6b3fa0; }
.b-role-admin { background: var(--blue-bg); color: var(--accent); }
.b-role-installer { background: var(--yellow-bg); color: var(--yellow); }
.b-role-measurer { background: var(--green-bg); color: var(--green); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .b-role-superuser { background: #2e2140; color: #c6a5ef; } }
:root[data-theme="dark"] .b-role-superuser { background: #2e2140; color: #c6a5ef; }
.kpi.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
table.perm td.c, table.perm th:not(:first-child) { text-align: center; }
table.perm td:first-child { min-width: 220px; }
