/* ================================================================ tokens */
:root {
  --bg: #F3F5FA; --surface: #FFFFFF; --surface-2: #F7F9FD; --ink: #0F1B3D; --ink-2: #4A5574; --muted: #737D96; --line: #E2E7F1; --line-2: #EDF0F6;
  --primary: #2C57E8; --primary-2: #2148CC; --primary-soft: #EAF0FF; --on-primary: #FFFFFF;
  --navy: #0D1836; --navy-2: #15234A; --nav-ink: #C9D3EC; --nav-ink-active: #FFFFFF;
  --ok: #12805A; --ok-soft: #E4F5EE; --bad: #C93A33; --bad-soft: #FCEBEA; --wait: #B7700A; --wait-soft: #FFF4E0; --info: #2C57E8;
  --shadow-1: 0 1px 2px rgba(15,27,61,.05), 0 2px 8px rgba(15,27,61,.04);
  --shadow-2: 0 2px 6px rgba(15,27,61,.06), 0 12px 32px rgba(15,27,61,.08);
  --r-card: 16px; --r-ctl: 10px; --r-pill: 999px;
  --font: "Inter", "Hind Siliguri", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", sans-serif;
  --side: 248px; --tabbar-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0A1120; --surface: #111A2E; --surface-2: #162038; --ink: #E8EDF8; --ink-2: #A9B3CA; --muted: #8590A8; --line: #23304B; --line-2: #1B263E;
  --primary: #5B82FF; --primary-2: #7698FF; --primary-soft: #1A2850; --navy: #070D1B; --navy-2: #0F1730;
  --ok: #3CC48E; --ok-soft: #10301F; --bad: #FF7A72; --bad-soft: #3A1715; --wait: #F2B44C; --wait-soft: #3A2A0E; --info: #7698FF;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 10px 30px rgba(0,0,0,.4); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0A1120; --surface: #111A2E; --surface-2: #162038; --ink: #E8EDF8; --ink-2: #A9B3CA; --muted: #8590A8; --line: #23304B; --line-2: #1B263E;
  --primary: #5B82FF; --primary-2: #7698FF; --primary-soft: #1A2850; --navy: #070D1B; --navy-2: #0F1730;
  --ok: #3CC48E; --ok-soft: #10301F; --bad: #FF7A72; --bad-soft: #3A1715; --wait: #F2B44C; --wait-soft: #3A2A0E; --info: #7698FF;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3); --shadow-2: 0 10px 30px rgba(0,0,0,.4); color-scheme: dark; }

/* ================================================================ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15.5px/1.55 var(--font); font-feature-settings: "tnum", "cv11"; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 0 0 8px; font-weight: 650; }
p { margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.icon { flex: none; }
.muted { color: var(--ink-2); } .small { font-size: .88rem; }
small.block { display: block; color: var(--muted); font-size: .84rem; line-height: 1.35; margin-top: 1px; }
.eyebrow { color: var(--primary); font-weight: 600; font-size: .85rem; margin-bottom: 2px; }

/* ================================================================ brand */
.mark { display: inline-block; width: 18px; height: 18px; transform: rotate(45deg); border-radius: 3px; flex: none;
  background: linear-gradient(135deg, #6E8EFF, var(--primary)); box-shadow: 0 0 0 3px rgba(91,130,255,.18); margin: 0 6px 0 3px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand small { font-weight: 500; font-size: .82rem; color: var(--muted); }
.env { font-size: .7rem; font-weight: 700; letter-spacing: .04em; padding: 2px 8px; border-radius: var(--r-pill); background: #FFB020; color: #3A2500; }

/* ================================================================ shell */
#app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--navy), var(--navy-2)); color: var(--nav-ink); display: flex; flex-direction: column;
  padding: 22px 14px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; padding: 0 10px 26px; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; color: var(--nav-ink); padding: 10px 12px; border-radius: 10px; font-weight: 500; text-decoration: none; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a[aria-current] { background: rgba(91,130,255,.18); color: var(--nav-ink-active); box-shadow: inset 3px 0 0 #7C9BFF; }
.sidebar nav a[aria-current] .icon { color: #9DB4FF; }
.whoami { margin-top: auto; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.whoami strong { color: #fff; display: block; font-size: .95rem; } .whoami span { font-size: .82rem; opacity: .8; }
.whoami-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.whoami .icon-btn { color: var(--nav-ink); border-color: rgba(255,255,255,.14); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  background: linear-gradient(135deg, #6E8EFF, #2C57E8); color: #fff; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.topbar { display: none; }
main#main { padding: 32px clamp(16px, 3.5vw, 48px) 64px; min-width: 0; outline: none; }
.tabbar { display: none; }
.page { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.page > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-sub { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.meta { display: inline-flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: .82rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.section-title { margin-top: 4px; }

/* ================================================================ hero (member home) */
.hero { border-radius: 20px; padding: 24px 24px 22px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, #3E6BFF 0%, #2148CC 45%, #12245C 100%); box-shadow: var(--shadow-2); }
.hero::after { content: ""; position: absolute; right: -30px; top: -30px; width: 160px; height: 160px; transform: rotate(45deg);
  border: 28px solid rgba(255,255,255,.08); border-radius: 18px; }
.hero h1 { font-size: 1.9rem; } .hero-greet { opacity: .8; font-weight: 500; }
.hero .chip { background: rgba(255,255,255,.16); color: #fff; }

/* ================================================================ cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow-1); display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; align-content: start; }
.card-title { font-size: 1.02rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpis.compact { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.figure.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 18px; box-shadow: var(--shadow-1); display: grid; gap: 8px; align-content: start; min-width: 0; }
.kpi-head { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .9rem; font-weight: 500; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.figure.kpi strong { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; overflow-wrap: anywhere; }
.figure.kpi small { color: var(--muted); font-size: .84rem; }
.figure.ok strong { color: var(--ok); } .figure.ok .kpi-icon { background: var(--ok-soft); color: var(--ok); }
.figure.bad strong { color: var(--bad); } .figure.bad .kpi-icon { background: var(--bad-soft); color: var(--bad); }
.figure.wait strong { color: var(--wait); } .figure.wait .kpi-icon { background: var(--wait-soft); color: var(--wait); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.chart .bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { height: 10px; background: var(--line-2); border-radius: var(--r-pill); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, #6E8EFF, var(--primary)); }
.bar-value { font-weight: 600; white-space: nowrap; }

/* ================================================================ callouts / empty / notes */
.callouts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--primary-soft); color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.callout:hover { text-decoration: none; border-color: var(--primary); }
.callout .icon { color: var(--primary); margin-top: 2px; }
.callout span { display: block; color: var(--ink-2); font-size: .9rem; }
.callout.wait { background: var(--wait-soft); } .callout.wait .icon { color: var(--wait); }
.callout.bad { background: var(--bad-soft); } .callout.bad .icon { color: var(--bad); }
.empty { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 28px 20px; color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 14px; text-align: center; flex-wrap: wrap; }
.empty.bad { color: var(--bad); background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); justify-content: flex-start; text-align: left; flex-wrap: nowrap; }
.loading { display: flex; gap: 10px; align-items: center; padding: 48px; color: var(--muted); justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { display: flex; gap: 8px; align-items: center; color: var(--ink-2); }
.plus { color: var(--ok); font-weight: 650; } .minus { color: var(--bad); font-weight: 650; } .low { color: var(--wait); } .wait-text { color: var(--wait); font-weight: 600; }
.total { display: block; text-align: right; font-size: 1.25rem; font-weight: 700; }

/* ================================================================ status mark (the rhombus) */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: .86rem; font-weight: 600; white-space: nowrap; padding: 3px 10px 3px 9px; border-radius: var(--r-pill); background: var(--line-2); color: var(--ink-2); }
.status i { width: 7px; height: 7px; transform: rotate(45deg); background: currentColor; border-radius: 1px; }
.status.ok { color: var(--ok); background: var(--ok-soft); } .status.bad { color: var(--bad); background: var(--bad-soft); }
.status.wait { color: var(--wait); background: var(--wait-soft); } .status.info { color: var(--info); background: var(--primary-soft); }

/* ================================================================ buttons & controls */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 44px;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: 0 1px 1px rgba(15,27,61,.04); transition: background-color .12s, border-color .12s, box-shadow .12s; }
.btn:hover { border-color: color-mix(in srgb, var(--ink-2) 45%, var(--line)); text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(44,87,232,.3), 0 4px 12px rgba(44,87,232,.18); }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--bad); } .btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 8px 0; min-height: 0; box-shadow: none; font-weight: 500; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; border-radius: 9px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn[aria-busy] { cursor: progress; }
.btn-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 10px 12px; min-height: 46px; width: 100%; transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 76px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
input[disabled] { background: var(--surface-2); color: var(--ink-2); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 20px; accent-color: var(--primary); padding: 0; }
input.qty { width: 96px; text-align: right; } input.price { width: 116px; text-align: right; } input.code { width: 90px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: .92rem; }
.field small { color: var(--muted); font-size: .84rem; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1 1 170px; min-width: 0; }
.form-row > .btn { flex: 0 0 auto; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar > select { width: auto; min-width: 200px; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; display: flex; align-items: center; }
.search .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: 36px; cursor: pointer; }
.checks { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 10px 14px; display: grid; gap: 4px; margin: 0; }
.checks legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
.switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 16px; }

/* ================================================================ layout helpers */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.split > div { display: grid; gap: 20px; min-width: 0; }
.narrow { max-width: 620px; width: 100%; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ================================================================ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.card > .table-wrap:only-child, .card > .table-wrap { margin: 0; }
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid th, .grid td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.grid td { overflow-wrap: anywhere; }
.grid td small.block { max-width: 60ch; }
.grid th { font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid tr:last-child td { border-bottom: 0; }
.grid td:first-child { min-width: 180px; }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.grid tr.clickable { cursor: pointer; }
.th-sort { all: unset; display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.th-sort .icon { opacity: .45; } th[aria-sort="ascending"] .th-sort .icon, th[aria-sort="descending"] .th-sort .icon { opacity: 1; color: var(--primary); }
.th-sort:focus-visible { outline: 2px solid var(--primary); }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; color: var(--ink-2); font-size: .9rem; }

/* ================================================================ order picker, basket, parcels, statement */
.picker { display: grid; gap: 6px; max-height: 62vh; overflow: auto; padding-right: 2px; }
.pick { text-align: left; font: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; color: var(--ink); min-height: 52px; }
.pick:hover { border-color: var(--primary); background: var(--primary-soft); }
.pick small { color: var(--muted); grid-column: 1; } .pick .icon { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--primary); }
.basket { display: grid; gap: 10px; }
.line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.line-name { flex: 1 1 200px; font-weight: 500; } .line-name small { display: block; color: var(--muted); font-weight: 400; }
.line-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.line select { width: auto; }
.parcels { display: grid; gap: 12px; }
.parcel { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 10px; background: var(--surface-2); }
.parcel-head { display: flex; gap: 12px; align-items: center; } .parcel-head > div { flex: 1; min-width: 0; }
.parcel-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.cn { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cn-label { font-size: .8rem; color: var(--muted); font-weight: 600; } .cn b { font-size: 1.1rem; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.inline-edit summary { cursor: pointer; color: var(--primary); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.inline-edit .form-row { margin-top: 8px; }
.timeline { padding: 0 0 0 4px; margin: 0; list-style: none; display: grid; gap: 10px; }
.timeline li { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; } .timeline small { color: var(--muted); }
.statement { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.statement li { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); border-left: 4px solid var(--bad); }
.statement li.credit { border-left-color: var(--ok); }
.st-main { display: grid; gap: 2px; min-width: 0; } .st-main small { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.st-amt { display: grid; gap: 2px; text-align: right; } .st-amt strong { font-size: 1.08rem; white-space: nowrap; } .st-amt small { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.statement li.debit .st-amt strong { color: var(--bad); } .statement li.credit .st-amt strong { color: var(--ok); }

/* ================================================================ admin */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs a { display: inline-flex; gap: 8px; align-items: center; padding: 10px 14px; color: var(--ink-2); font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a[aria-current] { color: var(--primary); border-bottom-color: var(--primary); }
.people { display: grid; gap: 8px; }
.person { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.person summary { display: flex; gap: 12px; align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.person summary::-webkit-details-marker { display: none; }
.person summary > div { flex: 1; min-width: 0; }
.person[open] summary { border-bottom: 1px solid var(--line-2); }
.person-body { padding: 14px; display: grid; gap: 12px; }
.add-row { padding-top: 6px; border-top: 1px dashed var(--line); }
.opt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.opt-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.report { grid-template-columns: 1fr auto; align-items: center; }

/* ================================================================ dialogs & toasts */
.dialog { border: 0; border-radius: 18px; padding: 24px; width: min(480px, calc(100vw - 32px)); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-2); }
.dialog::backdrop { background: rgba(8,14,32,.55); backdrop-filter: blur(2px); }
.dialog h2 { margin: 0 0 10px; font-size: 1.15rem; } .dialog-body { color: var(--ink-2); } .dialog-body ul { padding-left: 18px; margin: 6px 0 0; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; max-width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-2); font-weight: 500; }
.toast .icon { color: #7CE0B4; } .toast.bad { background: #8F1F1A; } .toast.bad .icon { color: #FFC2BE; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } } }

/* ================================================================ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; grid-column: 1 / -1; position: relative; overflow: hidden;
  background: radial-gradient(90% 70% at 85% 0%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%), var(--bg); }
.login-art { position: absolute; width: 520px; height: 520px; transform: rotate(45deg); border-radius: 60px; right: -220px; bottom: -260px;
  border: 60px solid color-mix(in srgb, var(--primary) 10%, transparent); }
.login-card { position: relative; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow-2); display: grid; gap: 14px; }
.brand.big { font-size: 1.4rem; padding-bottom: 6px; }

/* ================================================================ tablet */
@media (max-width: 1100px) { .split.wide-left { grid-template-columns: 1fr; } :root { --side: 220px; } }

/* ================================================================ phones & small tablets */
@media (max-width: 860px) {
  html, body { font-size: 16px; }
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-2); }
  main#main { padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .page { gap: 16px; }
  h1 { font-size: 1.45rem; } .hero h1 { font-size: 1.6rem; } .hero { padding: 20px; border-radius: 18px; }
  .tabbar { display: flex; position: fixed; z-index: 40; bottom: 0; left: 0; right: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(15,27,61,.08); }
  .tabbar > a, .tabbar summary { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted);
    text-decoration: none; font-size: .74rem; font-weight: 600; border-radius: 12px; list-style: none; cursor: pointer; min-width: 0; }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar > a[aria-current] { color: var(--primary); } .tabbar > a[aria-current] .icon { background: var(--primary-soft); border-radius: 10px; padding: 3px 12px; width: 48px; height: 28px; }
  .more { flex: 1; display: flex; }
  .more summary { width: 100%; }
  .more-menu { position: fixed; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom)); right: 10px; left: 10px; background: var(--surface); color: var(--ink);
    border-radius: 16px; box-shadow: var(--shadow-2); border: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
  .more-menu a, .more-signout { display: flex; gap: 12px; align-items: center; color: var(--ink); padding: 12px; border-radius: 10px; font-weight: 600; text-decoration: none; min-height: 48px; }
  .more-signout { font: inherit; font-weight: 600; background: none; border: 0; text-align: left; cursor: pointer; color: var(--bad); }
  .more-menu a[aria-current] { background: var(--primary-soft); color: var(--primary); }
  .split, .split.wide-left { grid-template-columns: 1fr; }
  .kpis, .kpis.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > .figure:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .figure.kpi { padding: 14px; } .figure.kpi strong { font-size: 1.35rem; }
  .kpi-head { font-size: .84rem; gap: 8px; } .kpi-icon { width: 28px; height: 28px; }
  .quick { display: grid; grid-template-columns: 1fr 1fr; } .quick .btn { min-height: 64px; white-space: normal; text-align: center; flex-direction: column; gap: 4px; line-height: 1.2; }
  .card { padding: 16px; border-radius: 14px; }
  .toolbar > select, .search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .btn { min-height: 48px; } .btn.small { min-height: 40px; }
  input, select, textarea { min-height: 50px; }
  .charts { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; } .head-actions { width: 100%; } .head-actions .btn { flex: 1; }
  /* tables become labelled cards */
  .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  table.grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  table.grid { background: none; }
  .grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .grid tr { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 8px 14px; }
  .grid tbody tr:hover td { background: none; }
  .grid td { border: 0; padding: 7px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; min-width: 0; }
  .grid td::before { content: attr(data-label); color: var(--muted); font-size: .86rem; font-weight: 500; text-align: left; flex: none; max-width: 42%; }
  .grid td[data-label=""]::before { content: none; } .grid td[data-label=""] { justify-content: flex-end; }
  .grid td:empty { display: none; }
  .grid td:first-child { min-width: 0; }
  .grid td > * { min-width: 0; }
  .grid .num { white-space: normal; }
  .grid td > select, .grid td > input:not([type=checkbox]) { max-width: 58%; }
  .dialog .actions { flex-direction: column-reverse; } .dialog .actions .btn { width: 100%; }
  .report { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(80px, 34%) 1fr auto; }
}
@media (max-width: 380px) {
  main#main { padding-left: 12px; padding-right: 12px; }
  .figure.kpi strong { font-size: 1.2rem; }
  .statement li { padding: 12px; flex-direction: column; gap: 6px; } .st-amt { text-align: left; }
  .quick { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.code-text { font-variant-numeric: tabular-nums; letter-spacing: .08em; font-size: 1.02rem; }
