:root {
  --bg: #f3f0e8; --card: #ffffff; --ink: #14231b; --muted: #5e6c64; --line: #e3dfd3;
  --brand: #0f4a36; --brand-ink: #ffffff; --signal: #c6f36a; --soft: #e8efe9;
  --ok: #1d7a4b; --ok-bg: #dff3e6; --warn: #8a5a00; --warn-bg: #fbecc8; --bad: #a82f27; --bad-bg: #fbdedb; --info: #1f5f99; --info-bg: #dcebf8; --mute-bg: #ebe8de;
  --shadow: 0 1px 2px rgba(20,35,27,.06), 0 4px 14px rgba(20,35,27,.05);
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1511; --card: #15211b; --ink: #e9f0eb; --muted: #97a79d; --line: #263429; --brand: #7fd9a8; --brand-ink: #0b1c14; --signal: #c6f36a; --soft: #1b2a22;
    --ok: #6fd9a0; --ok-bg: #173a29; --warn: #f0c060; --warn-bg: #3a2e12; --bad: #ff9a90; --bad-bg: #40201d; --info: #8cc4f5; --info-bg: #172f45; --mute-bg: #223027;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hide { display: none !important; }

/* shell */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: var(--brand-ink); }
.top .logo { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; flex: 1; min-width: 0; }
.top .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(198,243,106,.25); flex: none; }
.top .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn { background: rgba(255,255,255,.14); border: 0; color: inherit; border-radius: 12px; min-width: 40px; height: 40px; padding: 0 12px; cursor: pointer; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .iconbtn { background: rgba(0,0,0,.12); } }
main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-in { display: flex; width: 100%; max-width: 760px; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 2px 8px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; min-height: 56px; }
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--brand); }
.nav a.on::before { content: ""; position: absolute; margin-top: -9px; width: 28px; height: 3px; border-radius: 3px; background: var(--brand); }
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 19; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--signal); color: #14231b; font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer; }
@media (min-width: 800px) { .fab { right: calc(50% - 380px - 20px); } }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 a { text-transform: none; letter-spacing: 0; color: var(--brand); font-weight: 600; text-decoration: none; }
.hello { margin: 2px 0 12px; }
.hello h1 { font-size: 22px; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 13px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 22px; font-weight: 750; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 1px; }
.kpi.alert .v { color: var(--bad); }
.kpi.good .v { color: var(--ok); }
.sec { font-size: 12px; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 18px 2px 8px; }

/* rows & badges */
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:first-of-type { border-top: 0; padding-top: 2px; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .m { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--mute-bg); color: var(--muted); white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); } .b-info { background: var(--info-bg); color: var(--info); }
.empty { color: var(--muted); padding: 6px 0 2px; }

/* charts */
.cols { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.col .bar { width: 100%; max-width: 44px; border-radius: 8px 8px 3px 3px; background: var(--info-bg); position: relative; min-height: 3px; overflow: hidden; }
.col .bar i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--brand); }
.col .val { font-size: 11px; font-weight: 700; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.col .lab { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; background: var(--brand); vertical-align: -1px; }
.legend span.b::before { background: var(--info-bg); border: 1px solid var(--line); }
.hbar { display: grid; grid-template-columns: 112px 1fr auto; gap: 10px; align-items: center; margin: 7px 0; font-size: 13.5px; }
.hbar .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .tr { height: 10px; background: var(--soft); border-radius: 6px; overflow: hidden; }
.hbar .tr i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.hbar b { font-variant-numeric: tabular-nums; }
.funnel { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.stage { flex: 1 0 84px; background: var(--soft); border-radius: 12px; padding: 9px 10px; }
.stage .n { font-size: 20px; font-weight: 750; }
.stage .l { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.stage .a { font-size: 11.5px; color: var(--muted); }

/* list view */
.tools { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 10; background: var(--bg); padding: 4px 0 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.search { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 16px; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 9px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 13px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.item { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 13px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer; }
.item .h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.item .t { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.item .sub { color: var(--muted); font-size: 13.5px; margin-top: 1px; overflow-wrap: anywhere; }
.item .amt { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; }
.item .when { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.item .when.late { color: var(--bad); }
.prog { height: 6px; background: var(--soft); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--ok); }
.acts { display: flex; gap: 8px; margin-top: 11px; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; font-weight: 650; cursor: pointer; min-height: 44px; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.pri { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.sm { min-height: 38px; padding: 7px 12px; font-size: 13.5px; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; }
.count { color: var(--muted); font-size: 13px; margin: 2px 2px 10px; }

/* sheet (form) */
.scrim { position: fixed; inset: 0; background: rgba(8,16,12,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .2s ease-out; }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 22px; max-height: 90vh; } }
.sheet header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.sheet header h2 { flex: 1; font-size: 18px; }
.sheet .body { overflow-y: auto; padding: 4px 16px 12px; -webkit-overflow-scrolling: touch; }
.sheet footer { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.sheet footer .btn { flex: 1; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.field label i { color: var(--bad); font-style: normal; }
.in { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 16px; min-height: 46px; }
.in:focus, .search:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea.in { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc { background: var(--soft); border-radius: 12px; padding: 11px 13px; margin-bottom: 12px; font-weight: 700; display: flex; justify-content: space-between; }
.calc span { font-weight: 500; color: var(--muted); }
.quick { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.err { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.ok { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.group { font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 16px 0 8px; }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .brand { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login .brand .dot { width: 16px; height: 16px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 5px rgba(198,243,106,.35); }
.login p { color: var(--muted); margin: 0 0 20px; }

/* admin */
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 4px; font-weight: 650; font-size: 13px; cursor: pointer; color: var(--muted); min-height: 40px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.seg button + button { border-left: 1px solid var(--line); }
.perm { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; font-weight: 650; }
.log { font-size: 12.5px; padding: 8px 0; border-top: 1px solid var(--line); color: var(--muted); overflow-wrap: anywhere; }
.log b { color: var(--ink); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 600; z-index: 80; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 90vw; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 18px; letter-spacing: .5px; background: var(--card); border: 1px dashed var(--brand); padding: 10px 12px; border-radius: 12px; word-break: break-all; user-select: all; }
