:root {
  --brand: #0f3d33;
  --brand-2: #17614f;
  --accent: #1f9d73;
  --accent-soft: #e3f4ec;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --line: #e3e8e6;
  --text: #14211d;
  --muted: #61706b;
  --pos: #12804f;
  --neg: #c2362b;
  --warn: #b7791f;
  --warn-soft: #fdf3e1;
  --neg-soft: #fbe9e7;
  --info-soft: #e8f0fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 4px 16px rgba(16, 40, 32, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #0c2a24; --brand-2: #1a5a4a; --accent: #3cc591; --accent-soft: #143a30;
    --bg: #0d1412; --surface: #141e1b; --surface-2: #18241f; --line: #24332e;
    --text: #e6efeb; --muted: #93a49e; --pos: #48c98d; --neg: #f07a6c; --warn: #e5b45a;
    --warn-soft: #2d2615; --neg-soft: #2f1a17; --info-soft: #152437;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--muted); } .warn { color: var(--warn); }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.hidden { display: none !important; }

/* ---------- boot / auth ---------- */
.boot { display: grid; place-items: center; min-height: 100vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 60%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.18); }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo svg { flex: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #e7f3ee; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .logo { padding: 4px 10px 18px; font-size: 17px; color: #fff; }
.side a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: #cfe3dc; text-decoration: none; font-weight: 500; }
.side a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side a.on { background: rgba(255,255,255,.13); color: #fff; }
.side .grow { flex: 1; }
.side .badge { margin-left: auto; }
.main { min-width: 0; padding: 22px 28px 120px; max-width: 1180px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; flex: 1; min-width: 140px; }
.monthpick { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.monthpick button { border: 0; background: none; padding: 7px 11px; cursor: pointer; color: var(--muted); }
.monthpick button:hover { color: var(--text); }
.monthpick span { padding: 0 6px; font-weight: 600; min-width: 112px; text-align: center; text-transform: capitalize; }
.tabbar { display: none; }
.fab { position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: #fff; font-size: 28px; line-height: 1; box-shadow: 0 8px 24px rgba(31,157,115,.4); cursor: pointer; z-index: 20; }
.fab:active { transform: scale(.96); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
  .topbar h2 { font-size: 20px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); text-decoration: none; padding: 4px 0; position: relative; }
  .tabbar a.on { color: var(--accent); font-weight: 600; }
  .tabbar .dot { position: absolute; top: 2px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--neg); }
  .fab { bottom: calc(78px + env(safe-area-inset-bottom)); right: 16px; width: 52px; height: 52px; }
}

/* ---------- cards / grid ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1060px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g3, .g2 { grid-template-columns: 1fr; } .g4 { gap: 10px; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card h3 .right { margin-left: auto; font-weight: 500; }
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 640px) { .kpi { padding: 13px; } .kpi .val { font-size: 19px; } }
.hero { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border: 0; }
.hero .lbl, .hero .sub { color: rgba(255,255,255,.75); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 2px 10px; font-weight: 650; }

/* ---------- bars ---------- */
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > i { background: var(--warn); } .bar.neg > i { background: var(--neg); }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.catrow:last-child { border-bottom: 0; }
.catrow .bar { grid-column: 1 / -1; }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; vertical-align: 1px; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 15px; font-weight: 700; color: #fff; }
.item .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.item .v { text-align: right; font-weight: 600; }
.item .v .s { font-weight: 400; }
.dayhead { font-size: 12px; font-weight: 650; color: var(--muted); padding: 14px 4px 4px; display: flex; justify-content: space-between; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--pos); border-color: transparent; }
.pill.late { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill.soon { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--info-soft); color: #2f6fd1; border-color: transparent; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--neg); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- alerts ---------- */
.alert { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 11px 12px; border-radius: 12px; margin-bottom: 8px; background: var(--surface-2); border: 1px solid var(--line); align-items: start; }
.alert .ai { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.alert.danger { background: var(--neg-soft); border-color: transparent; } .alert.danger .ai { background: var(--neg); color: #fff; }
.alert.warn { background: var(--warn-soft); border-color: transparent; } .alert.warn .ai { background: var(--warn); color: #fff; }
.alert.info { background: var(--info-soft); border-color: transparent; } .alert.info .ai { background: #2f6fd1; color: #fff; }
.alert.good { background: var(--accent-soft); border-color: transparent; } .alert.good .ai { background: var(--accent); color: #fff; }
.alert b { display: block; font-size: 13.5px; } .alert span { font-size: 12.5px; color: var(--muted); }
.alert[data-go] { cursor: pointer; }

/* ---------- buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; min-height: 42px; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.input.big { font-size: 26px; font-weight: 700; padding: 10px 12px; letter-spacing: -.02em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 9px; align-items: center; padding: 8px 0; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 14px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.sm button { padding: 6px 8px; font-size: 12.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; min-height: 36px; padding: 6px 10px; font-size: 13.5px; }
.filters .search { flex: 1; min-width: 160px; }
@media (max-width: 640px) { .filters .input { flex: 1 1 calc(50% - 8px); min-width: 0; } .filters .search { flex-basis: 100%; } .topbar .monthpick span { min-width: 96px; } }

/* ---------- sheet (modal) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 20, 17, .45); z-index: 50; display: flex; align-items: center; justify-content: center; animation: fade .15s; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 20px; padding: 18px 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: up .2s ease-out; }
.sheet.wide { max-width: 860px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 17px; flex: 1; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; position: sticky; bottom: -20px; background: var(--surface); padding: 10px 0 0; }
.x { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; color: var(--muted); }
@media (max-width: 640px) {
  .overlay { align-items: flex-end; }
  .sheet { border-radius: 20px 20px 0 0; max-height: 94vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #14211d; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 80; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .2s; max-width: calc(100vw - 32px); }
.toast.err { background: var(--neg); }

/* ---------- cards (credit) ---------- */
.cc { border-radius: 16px; padding: 16px; color: #fff; position: relative; overflow: hidden; cursor: pointer; min-height: 132px; display: flex; flex-direction: column; gap: 6px; border: 2px solid transparent; }
.cc.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.cc::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.08); }
.cc .nm { font-weight: 700; font-size: 15px; }
.cc .lm { font-size: 12px; opacity: .8; }
.cc .bar { background: rgba(255,255,255,.2); border-color: transparent; margin-top: auto; }
.cc .bar > i { background: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: thin; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 7px 11px; cursor: pointer; text-align: left; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); }
.chip .m { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.chip .a { font-weight: 700; font-size: 13.5px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.tbl td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl select.input { min-height: 32px; padding: 4px 6px; font-size: 13px; }
.scroll-x { overflow-x: auto; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.menu-list a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); font-weight: 550; cursor: pointer; }
.menu-list a:last-child { border-bottom: 0; }
.menu-list a .chev { margin-left: auto; color: var(--muted); }
