/* AquaPoint — field-tool styling. Deep pipe blue, cool slate, and a meter-dial readout as the signature element. */
:root {
  --ink: #10303c;
  --muted: #587180;
  --bg: #eaf0f2;
  --panel: #ffffff;
  --line: #d3dfe3;
  --primary: #0a6a8f;
  --primary-dark: #07506d;
  --primary-soft: #e2f0f6;
  --ok: #1f7a4b;
  --ok-soft: #e3f3ea;
  --warn: #9a6a14;
  --warn-soft: #fbf1dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --drum: #17262c;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(16, 48, 60, .08);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", var(--font);
  --fs: 15px;
}
html[data-font="small"] { --fs: 13.5px; }
html[data-font="large"] { --fs: 17px; }
html[data-font="xlarge"] { --fs: 19px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: var(--fs); line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.num, .tab { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */
.shell { min-height: 100%; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff;
  padding: env(safe-area-inset-top, 0) 8px 0; display: flex; align-items: center; gap: 4px; min-height: 52px;
}
.topbar h1 { font-size: 1.15em; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.topbar .iconbtn { color: #fff; }
.topbar .spacer { width: 40px; flex: none; }
.content { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 14px 14px 90px; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--panel); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px;
  font-size: .76em; color: var(--muted); text-decoration: none;
}
.bottomnav a.on { color: var(--primary); font-weight: 600; }
.bottomnav svg { width: 22px; height: 22px; }

@media (min-width: 900px) {
  .side {
    display: flex; flex-direction: column; width: 232px; flex: none; background: var(--ink); color: #cfe0e6;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 10px;
  }
  .side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: #fff; }
  .side .brand img { width: 34px; height: 34px; border-radius: 8px; }
  .side .brand b { font-family: var(--display); font-size: 1.2em; display: block; }
  .side .brand small { color: #9fb9c3; font-size: .78em; }
  .side a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-s); color: #cfe0e6;
    text-decoration: none; font-size: .95em;
  }
  .side a svg { width: 19px; height: 19px; opacity: .85; }
  .side a:hover { background: rgba(255,255,255,.06); }
  .side a.on { background: var(--primary); color: #fff; }
  .side .grp { margin: 14px 10px 4px; font-size: .78em; color: #86a4ae; }
  .side .foot { margin-top: auto; padding: 12px 10px 0; font-size: .8em; color: #86a4ae; }
  .bottomnav { display: none; }
  .content { padding: 22px 26px 40px; }
  .topbar { background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line); padding: 0 18px; }
  .topbar h1 { text-align: left; font-size: 1.3em; }
  .topbar .iconbtn { color: var(--ink); }
}

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; border-radius: var(--radius-s); padding: 9px 16px; font-weight: 600; cursor: pointer;
  min-height: 42px; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--panel); color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .88em; }
.btn.block { width: 100%; }
.iconbtn { background: none; border: 0; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: var(--ink); flex: none; }
.iconbtn:hover { background: rgba(127,127,127,.15); }
.iconbtn svg { width: 22px; height: 22px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .88em; color: var(--muted); margin-bottom: 5px; }
.field > span .req { color: var(--bad); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-s); padding: 10px 12px; min-height: 44px;
}
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: .84em; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }
.grid2 { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search input { padding-left: 38px; border-radius: 22px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; flex: 1; min-width: 140px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 16px; padding: 5px 12px; font-size: .86em; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Panels & lists ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.panel h2 { font-size: 1.05em; margin-bottom: 10px; }
.section-title { font-family: var(--display); font-size: 1.05em; margin: 18px 2px 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 4px; height: 16px; background: var(--primary); border-radius: 2px; }
.kv { display: grid; grid-template-columns: minmax(110px, 42%) 1fr; gap: 6px 12px; font-size: .94em; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .cards.three { grid-template-columns: 1fr 1fr 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 13px 14px; box-shadow: var(--shadow); }
.card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.card .head b { font-family: var(--display); font-size: 1.08em; }
.card .sub { color: var(--muted); font-size: .86em; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.card .actions .btn { flex: 1; min-width: 90px; }
.card.link { cursor: pointer; }
.card.link:hover { border-color: var(--primary); }
.more { text-align: center; color: var(--muted); font-size: .86em; padding: 12px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty svg { width: 46px; height: 46px; color: #9bb3bd; margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .8em; padding: 2px 9px; border-radius: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-info { background: var(--primary-soft); color: var(--primary-dark); }
.b-mute { background: #edf1f2; color: var(--muted); }
.pos { color: var(--ok); } .neg { color: var(--bad); }

table.tbl { width: 100%; border-collapse: collapse; font-size: .92em; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .86em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #e8eef0; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.scrollx { overflow-x: auto; }

/* ---------- Home ---------- */
.hello { margin: 2px 2px 14px; }
.hello h2 { font-size: 1.5em; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
.stat small { color: var(--muted); font-size: .84em; display: block; }
.stat strong { font-family: var(--display); font-size: 1.75em; font-weight: 600; font-variant-numeric: tabular-nums; display: block; line-height: 1.2; }
.stat .bar { height: 5px; background: #e1eaed; border-radius: 3px; margin-top: 8px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--primary); }
.stat.alert strong { color: var(--bad); }
.stat strong.m { font-size: 1.35em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .stat strong.m { font-size: 1.05em; } }
.stat.lead { grid-column: span 2; background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.lead small { color: #a9c3cc; }
.stat.lead .bar { background: rgba(255,255,255,.15); }
.stat.lead .bar i { background: #5fc3e4; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 6px 11px; text-align: center;
  text-decoration: none; color: var(--ink); font-size: .86em; display: flex; flex-direction: column; align-items: center; gap: 8px; line-height: 1.25;
}
.tile:hover { border-color: var(--primary); }
.tile .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--primary); }
.tile .ic svg { width: 24px; height: 24px; }
.tile .ic.c2 { background: #2b8a6e; } .tile .ic.c3 { background: #9a6a14; } .tile .ic.c4 { background: #4a5f9e; } .tile .ic.c5 { background: #587180; } .tile .ic.c6 { background: #b3261e; }

/* ---------- Meter dial readout (signature element) ---------- */
.dial { display: inline-flex; align-items: stretch; gap: 2px; padding: 4px; background: #0d1a1f; border-radius: 6px; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
.dial span {
  font-family: var(--display); font-variant-numeric: tabular-nums; font-weight: 600; color: #f4f7f8; background: linear-gradient(#25363c, var(--drum) 45%, #0f1b20);
  width: 1.05em; text-align: center; border-radius: 2px; font-size: 1.35em; line-height: 1.45;
}
.dial span.l { background: linear-gradient(#c8473f, #a3221b 45%, #7c1712); }
.dial em { font-style: normal; color: #9fb3ba; font-size: .78em; align-self: flex-end; padding: 0 3px 2px 4px; font-family: var(--display); }
.dial.sm span { font-size: 1.02em; }
.dial.lg span { font-size: 2em; }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 15px; font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .86em; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.donutwrap { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: center; }
@media (min-width: 560px) { .donutwrap { grid-template-columns: 200px 1fr; } }

/* ---------- Dialogs, toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 28, 35, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.dialog {
  background: var(--panel); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; border-radius: 14px 14px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0)); animation: up .18s ease-out;
}
@media (min-width: 640px) { .overlay { align-items: center; } .dialog { border-radius: 14px; } }
.dialog h3 { font-size: 1.15em; margin-bottom: 12px; }
.dialog .btns { display: flex; gap: 8px; margin-top: 14px; }
.dialog .btns .btn { flex: 1; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dialog { animation: none; } }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 82px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); }
.toast { background: var(--ink); color: #fff; border-radius: 8px; padding: 11px 14px; box-shadow: 0 4px 16px rgba(0,0,0,.2); font-size: .94em; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.offline-bar { background: var(--warn); color: #fff; text-align: center; font-size: .86em; padding: 5px 10px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: sp 0.8s linear infinite; margin: 0 auto 10px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; box-sizing: border-box; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login .box { width: 100%; max-width: 380px; background: var(--panel); border-radius: 14px; padding: 26px 22px; }
.login .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login .logo img { width: 48px; height: 48px; border-radius: 10px; }
.login .logo b { font-family: var(--display); font-size: 1.6em; display: block; line-height: 1.1; }
.login .logo small { color: var(--muted); }
.login .demo { margin-top: 18px; font-size: .84em; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.login .demo button { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 2px 0; text-decoration: underline; }
.err { color: var(--bad); font-size: .9em; margin: -4px 0 12px; }

/* ---------- Misc ---------- */
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.presets button { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-s); padding: 12px 0; font-family: var(--display); font-size: 1.25em; cursor: pointer; }
.presets button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.token { font-family: var(--display); font-size: clamp(1.05em, 5.4vw, 1.55em); white-space: nowrap; letter-spacing: .04em; text-align: center; background: var(--drum); color: #fff; padding: 12px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.receipt { max-width: 460px; margin: 0 auto; }
.photo-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-pick .ph { width: 96px; height: 96px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--muted); cursor: pointer; background: #f6f9fa; overflow: hidden; position: relative; }
.photo-pick .ph img { width: 100%; height: 100%; object-fit: cover; }
.split { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1fr; } }
.cmdlist { display: grid; gap: 8px; }
.cmdlist button { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-s); padding: 11px 13px; cursor: pointer; font-weight: 600; }
.cmdlist button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.tiers .tier { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 8px; align-items: end; margin-bottom: 8px; }
.installbar { display: flex; align-items: center; gap: 10px; background: var(--primary-soft); border: 1px solid #bcdce9; border-radius: var(--radius-m); padding: 10px 12px; margin-bottom: 12px; font-size: .92em; }
.installbar span { flex: 1; }
pre.code { background: var(--drum); color: #e4eef1; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .82em; }
@media print {
  .side, .topbar, .bottomnav, .noprint { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
