/* BillBook — admin-dashboard design system. All colours/sizes are variables so Admin → Layout can re-theme the app. */
:root {
  --primary: #2453d6;
  /* shades of --primary: plain values (set again by applyLayout for other accents) so old Android WebViews without color-mix() still show them */
  --primary-2: #1f47b5;
  --primary-soft: #edf1fc;
  --primary-soft-2: #dce3f8;
  --primary-ring: rgba(36, 83, 214, .22);
  --primary-shadow: rgba(36, 83, 214, .16);
  --primary-glow: rgba(36, 83, 214, .55);
  --primary-mid: #1b3a8f;
  --primary-deep: #1e42a7;
  --primary-light: #87a0e8;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e3e8ef;
  --line-2: #f1f4f8;
  --field: #ffffff;
  --field-line: #d3dae4;
  --hover: #f5f7fb;
  --green: #0f9d6b; --green-soft: #e6f6ef;
  --orange: #d97706; --orange-soft: #fef3e2;
  --red: #dc2626; --red-soft: #fdecec;
  --blue: #2563eb; --blue-soft: #e8f0fe;
  --teal: #0d9488; --teal-soft: #e2f5f3;
  --yellow: #b7791f; --yellow-soft: #fdf6e3;
  --radius: 8px;
  --r-sm: calc(var(--radius) * .75);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .03);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .16);
  --focus: 0 0 0 3px var(--primary-ring);
  --side-w: 252px;
  --head-h: 60px;
  --gap: 20px;
  --pad: 20px;
  --row: 11px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --side-bg: #ffffff; --side-ink: #334155; --side-muted: #94a3b8; --side-line: var(--line);
  --side-hover: #f1f4f9; --side-active-bg: var(--primary-soft); --side-active-ink: var(--primary);
  font-size: var(--fs, 14px);
}
body.dark {
  --bg: #0b1220; --panel: #111a2e; --ink: #e6ebf5; --ink-2: #c3cbdb; --muted: #8592ab; --faint: #56627c;
  --line: #1f2a42; --line-2: #172138; --field: #0e1628; --field-line: #2a3652; --hover: #18233b;
  --primary-soft: #152550; --primary-soft-2: #172c64;
  --green-soft: #0f2e25; --orange-soft: #33240e; --red-soft: #3a171b; --blue-soft: #14264a; --teal-soft: #0f2e2c; --yellow-soft: #30270f;
  --shadow: none; --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
  --side-bg: #0a1121; --side-ink: #c3cbdb; --side-muted: #66728d; --side-hover: #16203a; --side-line: #1a243b;
  --side-active-bg: var(--primary-side-dark, #112250); --side-active-ink: #fff;
  color-scheme: dark;
}
/* navy sidebar (default) */
body.sb-dark { --side-bg: #0f1b38; --side-ink: #c9d3e8; --side-muted: #7887a8; --side-line: #1c2a4c; --side-hover: rgba(255,255,255,.06); --side-active-bg: rgba(255,255,255,.1); --side-active-ink: #fff; }
body.sb-brand { --side-bg: var(--primary-2); --side-ink: rgba(255,255,255,.88); --side-muted: rgba(255,255,255,.6); --side-line: rgba(255,255,255,.14); --side-hover: rgba(255,255,255,.1); --side-active-bg: rgba(255,255,255,.18); --side-active-ink: #fff; }
body.dense { --pad: 14px; --row: 8px; --gap: 16px; --head-h: 56px; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nw { white-space: nowrap; }
.pos, .dr { color: var(--green); } .neg, .cr { color: var(--red); } .warn { color: var(--red); }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ================= shell ================= */
.app { display: flex; min-height: 100vh; }
.side { width: var(--side-w); flex: none; background: var(--side-bg); color: var(--side-ink); border-right: 1px solid var(--side-line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 40; }
.brand { height: var(--head-h); display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--side-line); flex: none; color: var(--side-ink); }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand .bn { font-weight: 800; font-size: 18px; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 8px 14px 18px; scrollbar-width: thin; }
.nav-sec { font-size: 11.5px; font-weight: 700; color: var(--side-muted); padding: 16px 10px 6px; letter-spacing: .2px; }
.nav-item > a, .nav-item > button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border-radius: var(--r-sm); color: var(--side-ink); font-weight: 600; font-size: 14px; border: 0; background: none; cursor: pointer; text-align: left; position: relative; }
.nav-item > a:hover, .nav-item > button:hover { background: var(--side-hover); }
.nav-item > a.active, .nav-item.has-active > button { background: var(--side-active-bg); color: var(--side-active-ink); }
.nav-item .car { margin-left: auto; width: 15px; height: 15px; opacity: .7; transition: transform .15s; }
.nav-item.open > button .car { transform: rotate(90deg); }
.nav-item .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sub { display: none; padding: 4px 0 6px 38px; position: relative; }
.nav-sub::before { content: ''; position: absolute; left: 19px; top: 6px; bottom: 10px; width: 1px; background: var(--side-line); }
.nav-item.open > .nav-sub { display: block; }
.nav-sub a { display: block; padding: 6px 10px; border-radius: var(--r-sm); color: var(--side-muted); font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sub a:hover { color: var(--side-ink); background: var(--side-hover); }
.nav-sub a.active { color: var(--side-active-ink); background: var(--side-active-bg); }
.nav-sub .sub-title { display: none; }
.side-foot { padding: 12px 14px; border-top: 1px solid var(--side-line); font-size: 12px; color: var(--side-muted); flex: none; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--head-h); background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 30; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; min-width: 0; white-space: nowrap; }
.crumbs a { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.crumbs a:hover { color: var(--primary); }
.crumbs b { color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.gsearch { position: relative; margin-left: auto; }
.gsearch input { width: 260px; padding: 8px 12px 8px 36px; border-radius: 22px; background: var(--bg); border-color: var(--line); font-size: 13.5px; }
.gsearch > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.gs-res { position: absolute; top: calc(100% + 8px); right: 0; width: 380px; max-height: 420px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.gs-res .gh { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 8px 10px 4px; }
.gs-res a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink); }
.gs-res a:hover { background: var(--hover); }
.gs-res small { color: var(--muted); display: block; font-size: 12px; }
.hbtn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); display: inline-grid; place-items: center; cursor: pointer; position: relative; flex: none; }
.hbtn:hover { background: var(--hover); color: var(--primary); }
.hchip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 700; font-size: 13px; color: var(--ink-2); max-width: 230px; }
.hchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hchip:hover { border-color: var(--primary); }
.uava { display: flex; align-items: center; gap: 10px; border: 0; background: none; cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 26px; }
.uava:hover { background: var(--hover); }
.uava .ut { text-align: left; line-height: 1.2; }
.uava .ut b { display: block; font-size: 13.5px; }
.uava .ut small { color: var(--muted); font-size: 11.5px; }
.menu-pop { position: fixed; z-index: 120; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 220px; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: none; text-align: left; cursor: pointer; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); color: var(--primary); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-pop .mh { padding: 8px 10px; }
.menu-pop .mh b { display: block; }
.menu-pop .mh small { color: var(--muted); }
.menu-pop .on { color: var(--primary); }
main.main { flex: 1; padding: 24px 26px 60px; min-width: 0; }
.mtoggle { display: none; }
.scrim { display: none; }

/* --- navigation variants --- */
body.nav-rail { --side-w: 76px; }
body.nav-rail .brand { padding: 0; justify-content: center; }
body.nav-rail .brand .bn, body.nav-rail .nav-sec, body.nav-rail .nav-item .lbl, body.nav-rail .nav-item .car, body.nav-rail .side-foot { display: none; }
body.nav-rail .nav { padding: 10px 12px; overflow: visible; }
body.nav-rail .nav-item { position: relative; }
body.nav-rail .nav-item > a, body.nav-rail .nav-item > button { justify-content: center; padding: 11px 0; }
body.nav-rail .nav-item > .nav-sub { display: none !important; position: absolute; left: calc(100% + 8px); top: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; min-width: 210px; z-index: 80; }
body.nav-rail .nav-item:hover > .nav-sub { display: block !important; }
body.nav-rail .nav-sub::before { display: none; }
body.nav-rail .nav-sub a { color: var(--ink-2); }
body.nav-rail .nav-sub a.active { color: var(--primary); background: var(--primary-soft); }
body.nav-rail .nav-sub .sub-title { display: block; font-weight: 800; padding: 4px 10px 6px; color: var(--ink); font-size: 13px; }
body.nav-top .app { flex-direction: column; }
body.nav-top .side { width: 100%; height: auto; position: sticky; top: 0; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--side-line); padding: 0 18px; }
body.nav-top .brand { border: 0; padding: 0 18px 0 0; height: 58px; }
body.nav-top .nav { display: flex; align-items: center; gap: 2px; overflow: visible; padding: 0; flex-wrap: wrap; }
body.nav-top .nav-sec, body.nav-top .side-foot { display: none; }
body.nav-top .nav-item { position: relative; }
body.nav-top .nav-item > a, body.nav-top .nav-item > button { padding: 8px 12px; }
body.nav-top .nav-item .car { transform: rotate(90deg); margin-left: 2px; }
body.nav-top .nav-item > .nav-sub { display: none !important; position: absolute; top: 100%; left: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; min-width: 210px; z-index: 80; }
body.nav-top .nav-item:hover > .nav-sub { display: block !important; }
body.nav-top .nav-sub::before { display: none; }
body.nav-top .nav-sub a { color: var(--ink-2); }
body.nav-top .nav-sub a.active { color: var(--primary); background: var(--primary-soft); }
body.nav-top .topbar { top: 59px; }

/* ================= page header ================= */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: var(--gap); flex-wrap: wrap; }
.page-head h1 { font-size: 21px; font-weight: 800; margin: 0; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.ph-t { flex: 1; min-width: 200px; }
.ph-a { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.backbtn { width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; color: var(--ink-2); }
.backbtn:hover { color: var(--primary); border-color: var(--primary); }

/* ================= buttons & pills ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border-radius: var(--r-sm); border: 1px solid var(--field-line); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 700; font-size: 13.5px; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn .i { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.soft:hover { background: var(--primary-soft-2); }
.btn.white { background: #fff; border-color: #fff; color: var(--primary); }
.btn.white:hover { background: rgba(255,255,255,.88); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { color: #fff; filter: brightness(.95); }
.btn.outline { border-color: var(--primary); color: var(--primary); }
.btn.outline:hover { background: var(--primary-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--primary); }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.lg { padding: 11px 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.link { background: none; border: 0; color: var(--primary); font-weight: 700; cursor: pointer; padding: 0; font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { text-decoration: underline; }
.icon-btn { width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); flex: none; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn .i { width: 15px; height: 15px; }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border-radius: var(--r-sm); border: 1px solid var(--field-line); background: var(--panel); cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 700; }
.pill-btn:hover { border-color: var(--primary); color: var(--primary); }
.pill-btn .i { width: 15px; height: 15px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.p-green { background: var(--green-soft); color: var(--green); }
.p-yellow { background: var(--yellow-soft); color: var(--yellow); }
.p-orange { background: var(--orange-soft); color: var(--orange); }
.p-red { background: var(--red-soft); color: var(--red); }
.p-blue { background: var(--blue-soft); color: var(--blue); }
.p-purple { background: var(--primary-soft); color: var(--primary); }
.p-gray { background: var(--line-2); color: var(--muted); }

/* ================= cards ================= */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--pad); }
.card + .card { margin-top: var(--gap); }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h3 { font-size: 15.5px; font-weight: 800; margin: 0; flex: 1; display: flex; align-items: center; gap: 9px; }
.card-h h3 .i { color: var(--primary); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-h { padding: var(--pad) var(--pad) 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .spanall { grid-column: 1 / -1; }
.cols { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.cols > .card + .card { margin-top: 0; }
.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.c-dash2 { grid-template-columns: 270px minmax(0, 1.6fr) minmax(0, 1fr); }

/* dashboard */
.banner { position: relative; overflow: hidden; border-radius: var(--radius); padding: 26px 28px; color: #fff; margin-bottom: var(--gap);
  background: linear-gradient(110deg, var(--primary-2) 0%, var(--primary) 55%, var(--primary-light) 100%); display: flex; align-items: center; gap: 20px; min-height: 150px; }
.banner::before { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255,255,255,.07); right: 180px; top: -120px; }
.banner h2 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.banner p { margin: 0 0 14px; opacity: .92; }
.banner .chips { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; opacity: .95; }
.banner .chips span { display: inline-flex; align-items: center; gap: 6px; }
.banner .bt { flex: 1; position: relative; z-index: 1; }
.banner .bill { position: relative; z-index: 1; flex: none; }
.ov-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; }
.ov { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ov .oi { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ov .oi .i { width: 19px; height: 19px; }
.ov > div:last-child { min-width: 0; }
.ov .ol { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ov .oval { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-purple { background: var(--primary-soft); color: var(--primary); }
.c-green { background: var(--green-soft); color: var(--green); }
.c-orange { background: var(--orange-soft); color: var(--orange); }
.c-blue { background: var(--blue-soft); color: var(--blue); }
.c-red { background: var(--red-soft); color: var(--red); }
.c-teal { background: var(--teal-soft); color: var(--teal); }
.mini .ml { color: var(--muted); font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.mini .ml .icon-btn { margin-left: auto; }
.mini .mv { font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.mini-foot { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.stack > .card + .card { margin-top: var(--gap); }
.trend { display: inline-flex; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 800; background: var(--green-soft); color: var(--green); }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-wrap .bar { fill: var(--primary); transition: fill .1s; }
.chart-wrap .bar.neg { fill: var(--red); }
.chart-wrap .bar.hl { fill: var(--primary-2); }
.chart-wrap .grid-l { stroke: var(--line); stroke-width: 1; }
.chart-wrap .base { stroke: var(--faint); stroke-width: 1; }
.chart-wrap text { fill: var(--muted); font-size: 14px; font-family: var(--font); }
.ctip { position: absolute; pointer-events: none; background: var(--ink); color: var(--panel); padding: 7px 10px; border-radius: 8px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -112%); box-shadow: var(--shadow-lg); z-index: 5; }
.ctip b { display: block; font-size: 13px; }
.rev-head { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.rev-head .rv { font-size: 22px; font-weight: 800; }
.clist .cl { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); color: var(--ink); }
.clist .cl:last-child { border-bottom: 0; }
.clist .cl .cm { flex: 1; min-width: 0; }
.clist .cl .cm b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clist .cl small { color: var(--muted); font-size: 12px; }
.clist .cl .ca { text-align: right; }
.clist .cl .ca b { display: block; font-variant-numeric: tabular-nums; }

/* avatars */
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: var(--avc, var(--primary)); flex: none; letter-spacing: .3px; }
.av.lg { width: 44px; height: 44px; font-size: 15px; }
.av.sm { width: 28px; height: 28px; font-size: 10.5px; }
.av.sq { border-radius: var(--r-sm); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { min-width: 0; }
.who b { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); }
.stat .si { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.stat .si.green { background: var(--green-soft); color: var(--green); }
.stat .si.yellow { background: var(--orange-soft); color: var(--orange); }
.stat .si.red { background: var(--red-soft); color: var(--red); }
.stat .si.blue { background: var(--blue-soft); color: var(--blue); }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat .v { font-size: 19px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .c { color: var(--muted); font-size: 12px; }

/* ================= tables ================= */
.tbl-wrap { overflow-x: auto; }
.ptable, table.t { width: 100%; border-collapse: collapse; }
.ptable th, table.t th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink-2); padding: 11px 16px; white-space: nowrap; background: var(--line-2); border-bottom: 1px solid var(--line); }
.ptable td, table.t td { padding: var(--row) 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.ptable tr:last-child td { border-bottom: 0; }
.ptable tr.r, table.t tr.click { cursor: pointer; }
.ptable tr.r:hover td, table.t tr.click:hover td { background: var(--hover); }
.ptable td.amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.grp td { font-weight: 700; }
table.t tr.tot td, .ptable tr.tot td { font-weight: 800; background: var(--line-2); border-top: 1px solid var(--line); }
table.t tr.sub td { color: var(--muted); }
table.t td.l1 { padding-left: 34px; } table.t td.l2 { padding-left: 52px; } table.t td.l3 { padding-left: 70px; } table.t td.l4 { padding-left: 88px; }
.xbtn { width: 30px; height: 30px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); }
.xbtn:hover { background: var(--panel); border-color: var(--line); color: var(--primary); }
.xbtn .i { width: 16px; height: 16px; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 0 var(--pad); border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 56px; }
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.tab { padding: 17px 12px 15px; border: 0; background: none; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; font-size: 13.5px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.tab .c { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: var(--line-2); color: var(--muted); font-size: 11px; text-align: center; }
.tab.on .c { background: var(--primary-soft); color: var(--primary); }
.searchbox { position: relative; }
.searchbox .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.searchbox input { padding-left: 34px; width: 240px; }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .ei { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--primary-soft); color: var(--primary); }
.empty .ei .i { width: 26px; height: 26px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ================= drawer ================= */
.drawer-back { position: fixed; inset: 0; background: rgba(20, 22, 50, .35); z-index: 90; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--panel); z-index: 91; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.dw-h { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dw-h h3 { margin: 0; font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.dw-h small { color: var(--muted); display: block; font-size: 12.5px; margin-top: 2px; }
.dw-b { flex: 1; overflow-y: auto; padding: 20px 22px; }
.dw-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--line-2); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 18px; }
.kv-grid .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kv-grid .v { font-weight: 700; }
.party-box { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; background: var(--line-2); }
.party-box .pm { flex: 1; min-width: 0; }
.party-box b { display: block; font-size: 15px; }
.party-box small { color: var(--muted); font-size: 12.5px; }
.lines-mini { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.lines-mini th { font-size: 12px; color: var(--muted); font-weight: 700; text-align: left; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lines-mini td { padding: 9px 0; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.lines-mini td small { display: block; color: var(--muted); font-size: 12px; }
.totbox { margin-left: auto; width: min(300px, 100%); }
.totbox div { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.totbox div span:first-child { color: var(--muted); }
.totbox .gt { border-top: 1px dashed var(--field-line); margin-top: 6px; padding-top: 10px; font-size: 17px; font-weight: 800; }
.totbox .gt span:first-child { color: var(--ink); }
.note-box { margin-top: 16px; padding: 12px 14px; background: var(--line-2); border-radius: var(--r-sm); font-size: 13px; color: var(--ink-2); }

/* ================= forms ================= */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 700; }
label.f > input, label.f > select, label.f > textarea, label.f > .inline, label.f > .pw { font-weight: 500; color: var(--ink); font-size: 14px; }
label.f small { font-weight: 500; color: var(--muted); }
label.f .req { color: var(--red); }
input, select, textarea { border: 1px solid var(--field-line); border-radius: var(--r-sm); padding: 9px 12px; background: var(--field); min-width: 0; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input[disabled] { background: var(--line-2); color: var(--muted); }
input[type=color] { padding: 2px; height: 38px; width: 52px; cursor: pointer; }
input[type=range] { padding: 0; accent-color: var(--primary); }
textarea { resize: vertical; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; min-width: 0; }
.inline > .narrow { flex: 0 0 90px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.switch { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.switch:last-child { border-bottom: 0; }
.switch .st { flex: 1; }
.switch .st b { display: block; font-weight: 700; font-size: 13.5px; }
.switch .st small { color: var(--muted); font-size: 12.5px; }
.switch input, input.tog { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 12px; background: var(--field-line); position: relative; cursor: pointer; border: 0; padding: 0; flex: none; transition: background .15s; }
.switch input::after, input.tog::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.switch input:checked, input.tog:checked { background: var(--primary); }
.switch input:checked::after, input.tog:checked::after { left: 21px; }
.seg { display: inline-flex; border: 1px solid var(--field-line); border-radius: var(--r-sm); padding: 3px; gap: 3px; background: var(--field); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: calc(var(--r-sm) - 2px); cursor: pointer; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.seg button.on { background: var(--primary); color: #fff; }
.fsec-h { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.fsec-h .n { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.fsec-h h3 { margin: 0; font-size: 15.5px; font-weight: 800; flex: 1; }
.doc-form > .card { margin-bottom: var(--gap); }
.doc-form > .card + .card { margin-top: 0; }
.party-pick { position: relative; }
.party-pick .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.party-pick input { width: 100%; padding-left: 40px; height: 44px; }
.party-chip { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 14px 16px; border: 1px dashed var(--primary-soft-2); border-radius: var(--radius); background: var(--primary-soft); }
.party-chip .pc-m { flex: 1; min-width: 0; }
.party-chip b { font-size: 15px; }
.party-chip .pc-s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.party-chip .pc-bal { text-align: right; font-size: 12px; color: var(--muted); }
.party-chip .pc-bal b { display: block; font-size: 15px; }
.hint { font-size: 12.5px; margin-top: 8px; }
.itable { width: 100%; border-collapse: separate; border-spacing: 0; }
.itable th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink-2); padding: 10px 6px; white-space: nowrap; background: var(--line-2); }
.itable th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); padding-left: 12px; } .itable th:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.itable td { padding: 6px 4px; vertical-align: middle; border-bottom: 1px solid var(--line-2); }
.itable input, .itable select { width: 100%; padding: 8px 10px; }
.itable input.n { text-align: right; }
.itable td.calc { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; padding-right: 10px; white-space: nowrap; }
.itable .ln { color: var(--muted); font-size: 12.5px; text-align: center; width: 34px; }
.rm { border: 0; background: none; color: var(--faint); cursor: pointer; width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; }
.rm:hover { color: var(--red); background: var(--red-soft); }
.rm .i { width: 15px; height: 15px; }
.addline { margin-top: 12px; }
.form-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap); align-items: start; }
.form-bottom > .card + .card { margin-top: 0; }
.summary .sum-row { display: flex; justify-content: space-between; padding: 7px 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.summary .sum-row span:first-child { color: var(--muted); }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--field-line); margin-top: 10px; padding-top: 14px; }
.sum-total span:first-child { font-weight: 800; }
.sum-total span:last-child { font-size: 23px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.sum-words { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 16px; }
.actionbar { position: sticky; bottom: 0; z-index: 20; margin: var(--gap) -26px -60px; padding: 14px 26px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; box-shadow: 0 -6px 20px rgba(20,22,50,.05); }
.actionbar .tot { font-weight: 800; font-size: 16px; }
.actionbar .tot small { color: var(--muted); font-weight: 600; font-size: 12.5px; margin-right: 6px; }

/* ================= reports ================= */
.tform { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.tside { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tside .th { padding: 14px 18px; font-weight: 800; background: var(--line-2); border-bottom: 1px solid var(--line); }
.tside .tb { flex: 1; padding: 6px 0; }
.tline { display: flex; justify-content: space-between; gap: 10px; padding: 8px 18px; }
.tline.g { font-weight: 700; }
.tline.d { color: var(--muted); font-size: 13px; padding-top: 4px; padding-bottom: 4px; }
.tline.click { cursor: pointer; } .tline.click:hover { background: var(--hover); color: var(--ink); }
.tline.k { font-weight: 800; color: var(--primary); background: var(--primary-soft); margin: 6px 12px; border-radius: var(--r-sm); padding: 10px 12px; }
.tside .tf { display: flex; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--line); font-weight: 800; font-size: 15px; background: var(--line-2); }
.rpt-title { font-size: 15px; font-weight: 800; margin: var(--gap) 0 12px; }
.rgroups h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 26px 0 12px; font-weight: 800; }
.rgroups h2:first-child { margin-top: 0; }
.rcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.rcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; color: var(--ink); transition: border-color .12s, transform .12s; }
.rcard:hover { border-color: var(--primary); transform: translateY(-2px); }
.rcard .si { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.rcard b { display: block; margin-bottom: 3px; }
.rcard small { color: var(--muted); font-size: 12.5px; line-height: 1.45; display: block; }

/* ================= admin ================= */
.admin { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.admin > .card + .card { margin-top: 0; }
.anav { position: sticky; top: calc(var(--head-h) + 20px); padding: 10px; }
.anav h6 { margin: 12px 10px 6px; font-size: 11.5px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .6px; }
.anav h6:first-child { margin-top: 4px; }
.anav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 700; font-size: 13.5px; }
.anav a .i { width: 16px; height: 16px; color: var(--muted); }
.anav a:hover { background: var(--hover); color: var(--primary); }
.anav a.on { background: var(--primary-soft); color: var(--primary); }
.anav a.on .i { color: var(--primary); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.swatch { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--panel); box-shadow: 0 0 0 1px var(--line); cursor: pointer; position: relative; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.swatch.on::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; }
.navpick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.navpick button { border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 10px; cursor: pointer; text-align: center; font-weight: 700; color: var(--ink-2); }
.navpick button.on { border-color: var(--primary); color: var(--primary); }
.navpick .np { height: 64px; border-radius: 6px; background: var(--line-2); display: flex; gap: 4px; padding: 5px; margin-bottom: 8px; }
.navpick .np.col { flex-direction: column; }
.navpick .np i { display: block; background: var(--primary-soft-2); border-radius: 3px; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 6px; background: var(--panel); }
.mrow.child { margin-left: 34px; }
.mrow.sec { background: var(--line-2); }
.mrow input[type=text] { flex: 1; padding: 6px 10px; }
.mrow .mk { font-size: 12px; color: var(--muted); width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perm th, .perm td { text-align: center; }
.perm th:first-child, .perm td:first-child { text-align: left; }
.perm td small { display: block; color: var(--muted); font-weight: 500; }
.preview-box { border: 1px solid var(--line); border-radius: var(--radius); background: #e6e7ee; padding: 18px; overflow: auto; max-height: 760px; }
.preview-box .paper { background: #fff; margin: 0 auto; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 22px; color: #111; }
.uimg { display: flex; align-items: center; gap: 14px; }
.uimg .ph { width: 64px; height: 64px; border-radius: var(--r-sm); border: 1px dashed var(--field-line); display: grid; place-items: center; overflow: hidden; background: var(--line-2); color: var(--muted); }
.uimg .ph img { width: 100%; height: 100%; object-fit: contain; }

/* ================= auth screens ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--panel); }
.auth-art { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(140deg, var(--primary-2), var(--primary) 60%, var(--primary-light)); }
.auth-art::before, .auth-art::after { content: ''; position: absolute; border-radius: 50%; border: 60px solid rgba(255,255,255,.07); }
.auth-art::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.auth-art::after { width: 300px; height: 300px; left: -100px; bottom: -110px; }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .ab { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.auth-art .ab .logo { width: 38px; height: 38px; border-radius: 10px; background: #fff; color: var(--primary); display: grid; place-items: center; font-weight: 800; overflow: hidden; }
.auth-art .ab .logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-art h1 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; font-weight: 800; max-width: 460px; }
.auth-art p { opacity: .9; max-width: 440px; margin: 0; }
.auth-art .feat { display: grid; gap: 12px; margin-top: 28px; }
.auth-art .feat span { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.auth-art .feat .i { background: rgba(255,255,255,.18); border-radius: 50%; padding: 6px; width: 30px; height: 30px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form form { width: min(400px, 100%); }
.auth-form h2 { font-size: 26px; font-weight: 800; margin: 0 0 6px; }
.auth-form .sub { color: var(--muted); margin-bottom: 26px; }
.auth-form label.f { margin-bottom: 16px; }
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 42px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; display: grid; }
.auth-err { background: var(--red-soft); color: var(--red); padding: 10px 12px; border-radius: var(--r-sm); font-weight: 700; font-size: 13px; margin-bottom: 16px; }
.welcome { width: min(820px, 100%); margin: 0 auto; }

/* ================= modal & toast ================= */
.modal-back { position: fixed; inset: 0; background: rgba(20, 22, 50, .45); display: flex; align-items: flex-start; justify-content: center; padding: 56px 16px; z-index: 100; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--panel); border-radius: calc(var(--radius) + 4px); width: 100%; max-width: 680px; box-shadow: var(--shadow-lg); }
.modal-h { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; }
.modal-b { padding: 20px 22px; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--line-2); border-radius: 0 0 calc(var(--radius) + 4px) calc(var(--radius) + 4px); }
#toast { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
#toast div { background: var(--ink); color: var(--panel); padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow-lg); max-width: 380px; font-weight: 600; border-left: 4px solid var(--primary); }
#toast div.err { border-left-color: var(--red); }
#toast div.ok { border-left-color: var(--green); }

/* ================= import page ================= */
.drop { text-align: center; border: 2px dashed var(--field-line); background: var(--panel); padding: 34px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .ei { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.drop .ei .i { width: 26px; height: 26px; }
.drop b { font-size: 16px; }
.formats { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; max-width: 640px; }
#imp-body > .card { margin-top: var(--gap); }
.fname { min-width: 0; }
.fname b { white-space: normal !important; word-break: break-all; }
.fname small { display: flex !important; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.imp-docs td { vertical-align: top; }
td.small { font-size: 12.5px; line-height: 1.5; min-width: 200px; }
.imp-docs td.num small { white-space: normal; max-width: 200px; margin-left: auto; }
.check input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: var(--gap); align-items: start; }
.form-grid > .card + .card { margin-top: 0; }
.rail { position: sticky; top: calc(var(--head-h) + 20px); }
.summary h3 { margin: 0 0 14px; font-size: 15.5px; font-weight: 800; }
.summary .btn + .btn { margin-top: 10px; }
.dp-l { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.dp-amt { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dp-note { margin-top: 14px; font-size: 13px; color: var(--ink-2); background: var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; }
.kv { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.kv b { color: var(--ink); }

/* ================= print ================= */
#print-area { display: none; }
.inv { font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #111; }
.inv table { width: 100%; border-collapse: collapse; }
.inv.classic td, .inv.classic th { border: 1px solid #666; padding: 4px 6px; vertical-align: top; }
.inv.classic th { background: var(--pc-soft, #e5eafa); font-size: 11px; }
.inv .c { text-align: center; } .inv .r { text-align: right; }
.inv.classic .title { text-align: center; font-weight: 700; font-size: 15px; letter-spacing: 1px; padding: 6px; background: var(--pc, #2453d6); color: #fff; }
.inv .co { font-size: 18px; font-weight: 700; }
.inv .nob td { border: 0 !important; padding: 2px 4px; }
.inv .copy { float: right; font-size: 10px; font-style: italic; font-weight: 400; }
.inv .logo { max-height: 60px; max-width: 160px; object-fit: contain; display: block; margin-bottom: 6px; }
.inv.modern { font-size: 12.5px; }
.inv.modern .mh { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 14px; border-bottom: 3px solid var(--pc, #2453d6); }
.inv.modern .mt { text-align: right; }
.inv.modern .mt h1 { margin: 0; font-size: 26px; color: var(--pc, #2453d6); letter-spacing: 1px; }
.inv.modern .meta { display: grid; grid-template-columns: auto auto; gap: 2px 14px; justify-content: end; margin-top: 6px; }
.inv.modern .meta span:nth-child(odd) { color: #666; }
.inv.modern .addr { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 16px 0; }
.inv.modern .addr h4 { margin: 0 0 4px; font-size: 10.5px; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.inv.modern .items th { background: var(--pc, #2453d6); color: #fff; padding: 7px 8px; text-align: left; font-size: 11px; }
.inv.modern .items th.r { text-align: right; }
.inv.modern .items td { padding: 7px 8px; border-bottom: 1px solid #e3e3e8; }
.inv.modern .items tr:nth-child(even) td { background: #f7f7fa; }
.inv.modern .mfoot { display: grid; grid-template-columns: 1fr 280px; gap: 24px; margin-top: 14px; }
.inv.modern .tots div { display: flex; justify-content: space-between; padding: 4px 0; }
.inv.modern .tots .g { border-top: 2px solid var(--pc, #2453d6); margin-top: 6px; padding-top: 8px; font-size: 16px; font-weight: 700; color: var(--pc, #2453d6); }
.inv.modern .small { font-size: 11px; color: #555; }
.inv.modern .hsn { margin-top: 12px; }
.inv.modern .hsn th, .inv.modern .hsn td { border: 1px solid #ddd; padding: 4px 6px; font-size: 11px; }
.inv.modern .sign { text-align: right; margin-top: 30px; }
.inv.thermal { width: 72mm; font-family: 'Courier New', monospace; font-size: 11px; margin: 0 auto; }
.inv.thermal hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
.inv.thermal table td { padding: 1px 0; vertical-align: top; }
.inv.thermal .big { font-size: 14px; font-weight: 700; }

@media print {
  body { background: #fff; }
  .side, .topbar, .ph-a, .no-print, #toast, #modal-root, .actionbar, .toolbar .searchbox, .drawer, .drawer-back { display: none !important; }
  main.main { padding: 0; }
  .card, .stat, .tside { box-shadow: none; }
  body.print-doc .app { display: none !important; }
  body.print-doc #print-area { display: block; }
}

/* ================= responsive ================= */
@media (max-width: 1280px) {
  .c-dash2 { grid-template-columns: 1fr 1fr; }
  .c-dash2 > :first-child { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
  .c-dash2 > :first-child > .card + .card { margin-top: 0; }
}
@media (max-width: 1100px) {
  .c3 { grid-template-columns: 1fr; }
  .form-bottom, .form-grid { grid-template-columns: 1fr; }
  .admin { grid-template-columns: 1fr; }
  .anav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .anav h6 { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  body:not(.nav-top) .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); width: 258px; }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20,22,50,.35); z-index: 35; }
  body.nav-rail .brand .bn, body.nav-rail .nav-sec, body.nav-rail .nav-item .lbl, body.nav-rail .nav-item .car { display: revert; }
  .mtoggle { display: inline-grid; }
  .gsearch input { width: 160px; }
  .uava .ut, .hchip span { display: none; }
  main.main { padding: 16px 16px 60px; }
  .actionbar { margin: var(--gap) -16px -60px; padding: 12px 16px; flex-wrap: wrap; }
  .tform, .c-dash2, .c-dash2 > :first-child { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .navpick { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats, .g2, .g3, .g4, .kv-grid { grid-template-columns: minmax(0, 1fr); }
  label.f > input, label.f > select, label.f > textarea { min-width: 0; width: 100%; }
  .span2, .span3 { grid-column: auto; }
  .gsearch { display: none; }
  .banner .bill { display: none; }
}

/* admin form helpers */
div.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 700; }
div.f > b { font-weight: 700; }
.check input[type=color] { width: 46px; height: 32px; padding: 2px; border-radius: var(--r-sm); }
.preview-box .paper { max-width: none; }
/* ===== clickable cards ===== */
[data-href] { cursor: pointer; }
.card[data-href], .stat[data-href], .ov { transition: border-color .12s, box-shadow .12s, transform .12s; }
.card[data-href]:hover, .stat[data-href]:hover, .stat[data-tab]:hover { border-color: var(--primary); box-shadow: 0 6px 18px var(--primary-shadow); }
.stat[data-tab] { cursor: pointer; }
a.ov { border-radius: var(--r-sm); padding: 4px; margin: -4px; }
a.ov:hover { background: var(--hover); }

/* ===== filters & pagination ===== */
.filters { display: flex; align-items: center; gap: 10px; padding: 10px var(--pad); border-bottom: 1px solid var(--line); background: var(--line-2); flex-wrap: wrap; }
.fl-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 12.5px; color: var(--ink-2); margin-right: 4px; }
.fl-title .i { width: 15px; height: 15px; color: var(--primary); }
.fl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.fl select { padding: 5px 8px; font-size: 13px; max-width: 220px; }
.pager { display: flex; align-items: center; gap: 6px; padding: 12px var(--pad); border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager:empty { display: none; }
.pg { min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 700; color: var(--ink-2); display: inline-grid; place-items: center; }
.pg .i { width: 15px; height: 15px; }
.pg:hover:not([disabled]) { border-color: var(--primary); color: var(--primary); }
.pg.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg[disabled] { opacity: .4; cursor: default; }

/* ===== analytics charts ===== */
:root { --s1: #2a78d6; --s2: #eb6834; }
body.dark { --s1: #3987e5; --s2: #d95926; }
.sbar.s1, .legend i.s1, .tk.s1 { fill: var(--s1); background: var(--s1); }
.sbar.s2, .legend i.s2, .tk.s2 { fill: var(--s2); background: var(--s2); }
.sbar { transition: opacity .1s; }
.sbar.dim { opacity: .35; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ctip .tk { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.hb { display: flex; flex-direction: column; gap: 4px; }
.hb-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 6px; border-radius: var(--r-sm); color: var(--ink); }
a.hb-row:hover { background: var(--hover); }
.hb-l { min-width: 0; }
.hb-l b { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-l small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-t { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.hb-t i { display: block; height: 100%; border-radius: 4px; background: var(--primary); }
.hb-t i.neg { background: var(--red); }
.hb-v { font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat[data-pt], .stat[data-st], .stat[data-tt] { cursor: pointer; }
.stat[data-pt]:hover, .stat[data-st]:hover, .stat[data-tt]:hover { border-color: var(--primary); box-shadow: 0 6px 18px var(--primary-shadow); }

/* GST returns */
.gst-per { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.gst-per select { padding: 7px 10px; border: 1px solid var(--field-line); border-radius: var(--r-sm); background: var(--panel); color: var(--ink); font: inherit; font-weight: 700; }
.gst-warn { margin-bottom: var(--gap); padding: 12px 14px; border-radius: var(--r-sm); background: var(--orange-soft); color: var(--ink); font-size: 13px; display: grid; gap: 6px; }
.gst-warn div { display: flex; gap: 8px; align-items: flex-start; } .gst-warn .i { width: 16px; height: 16px; color: var(--orange); flex: none; margin-top: 1px; }
#gst-body { margin-top: var(--gap); }
.gst-stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.gst-up { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: var(--gap); }
.gst-up small { display: block; color: var(--muted); margin-top: 3px; }
@media print { .gst-per, .gst-up { display: none !important; } }

/* ===== subscription bar, billing ===== */
.subbar { display: flex; align-items: center; gap: 10px; padding: 9px 24px; font-size: 13.5px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--blue-soft); color: var(--ink); }
.subbar > .i { flex: none; color: var(--blue); }
.subbar span { flex: 1; min-width: 0; }
.subbar.warn { background: var(--orange-soft); } .subbar.warn > .i { color: var(--orange); }
.subbar.bad { background: var(--red-soft); } .subbar.bad > .i { color: var(--red); }
.subbar small { color: var(--muted); }
.billing-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.billing-cols > .card { margin: 0; }
#cyc { flex: none; }
.billing-kv { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 0; }
.billing-kv > div { display: flex; flex-direction: column; gap: 3px; }
.meter { height: 8px; border-radius: 6px; background: var(--line-2); overflow: hidden; margin: 8px 0 4px; }
.meter span { display: block; height: 100%; border-radius: 6px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--gap); }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.plan.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.plan .pn { font-weight: 800; font-size: 16px; }
.plan .pp { font-size: 26px; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; }
.plan .pp small { font-size: 13px; color: var(--muted); font-weight: 600; }
.plan ul { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 6px; font-size: 13px; flex: 1; }
.plan li { display: flex; align-items: center; gap: 6px; } .plan li .i { width: 16px; height: 16px; color: var(--green); }
@media (max-width: 600px) {
  .subbar { padding: 8px 14px; flex-wrap: wrap; }
  .billing-kv, .billing-cols { grid-template-columns: 1fr; }
  .card-h:has(#cyc) { flex-wrap: wrap; gap: 10px; }
}
/* phones with a notch / home indicator (mobile app, installed web app) */
@media screen { @supports (padding: env(safe-area-inset-top)) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--head-h) + env(safe-area-inset-top)); }
  main.main { padding-bottom: calc(env(safe-area-inset-bottom) + 60px); }
} }

/* ===== line items as cards on phones (invoice, bill, payment, journal lines) ===== */
@media (max-width: 700px) {
  .doc-form .tbl-wrap:has(> .itable) { overflow: visible; }
  .itable thead { display: none; }
  .itable, .itable tbody { display: block; }
  .itable tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; position: relative; padding: 12px;
    margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
  .itable td { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 0; border: 0; }
  .itable td[data-l]::before { content: attr(data-l); font-size: 11.5px; font-weight: 700; color: var(--muted); }
  .itable td.wide { grid-column: 1 / -1; }
  .itable td.wide2 { grid-column: span 2; }
  .itable td.ln { display: block; grid-column: 1 / -1; width: auto; text-align: left; font-weight: 800; color: var(--primary); padding-right: 40px; }
  .itable td.calc:empty { display: none; }
  .itable td.ln::before { content: 'Line '; }
  .itable td:last-child { position: absolute; top: 6px; right: 6px; }
  .itable td.calc { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center;
    padding: 10px 0 0; border-top: 1px dashed var(--line); font-size: 15px; }
  .itable td.calc::before { font-size: 13px; }
  .itable td[data-bal]:empty { display: none; }
  .itable input, .itable select { padding: 10px; font-size: 15px; } /* 15px+ stops phones zooming into the field */
}

/* ===================== professional theme polish ===================== */
body { font-feature-settings: 'cv11', 'ss01'; letter-spacing: -0.006em; }
.num, .ptable td, .stat .v, .totbox, .itable td.calc, .plan .pp, .dp-amt { font-variant-numeric: tabular-nums; }
/* type: Inter reads best at 600–700, not 800 */
.page-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.page-head .sub { font-size: 13px; }
.card-h h3 { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.brand .bn { font-weight: 700; letter-spacing: -0.02em; }
.brand .logo { border-radius: 8px; }
.btn { font-weight: 600; border-radius: var(--r-sm); }
.btn.primary { box-shadow: 0 1px 2px rgba(15, 23, 42, .12), inset 0 1px 0 rgba(255, 255, 255, .08); }
.pill { font-weight: 600; border-radius: 999px; padding: 3px 10px; }
.stat .v { font-weight: 700; letter-spacing: -0.01em; }
.stat .si { border-radius: 10px; }
.uava .ut b { font-weight: 600; }
/* focus: one consistent, visible ring (keyboard + touch) */
:where(input, select, textarea):focus { outline: none; border-color: var(--primary) !important; box-shadow: var(--focus); }
:where(.btn, .pill-btn, .tab, .nav-item > a, .nav-item > button, .xbtn, .icon-btn):focus-visible { outline: none; box-shadow: var(--focus); }
/* sidebar */
.nav-sec { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 18px 12px 6px; }
.nav-item > a, .nav-item > button { font-weight: 500; font-size: 13.5px; padding: 8px 12px; }
.nav-item > a.active, .nav-item.has-active > button { font-weight: 600; }
body.sb-dark .nav-item > a.active, body.dark .nav-item > a.active { box-shadow: inset 3px 0 0 var(--primary-light); }
body.sb-dark .brand .logo, body.dark .brand .logo { box-shadow: 0 0 0 1px rgba(255, 255, 255, .12); }
/* tables: quiet, scannable headers */
.ptable th, table.t th, .itable th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafc; }
body.dark .ptable th, body.dark table.t th, body.dark .itable th { background: var(--line-2); }
.ptable tbody tr:hover td { background: var(--hover); }
.tab { font-weight: 600; }
/* dashboard banner & sign-in panel: deep navy instead of bright gradients */
.banner { background: linear-gradient(115deg, #0f1b38 0%, var(--primary-mid) 62%, var(--primary) 100%); }
.banner::before { border-color: rgba(255, 255, 255, .05); }
.banner h2 { font-weight: 700; letter-spacing: -0.02em; }
.auth-art { background:
  radial-gradient(circle at 85% 10%, var(--primary-glow) 0, transparent 45%),
  linear-gradient(150deg, #0b1530 0%, #0f1b38 55%, var(--primary-deep) 100%); }
.auth-art::before, .auth-art::after { border-color: rgba(255, 255, 255, .04); }
.auth-art h1 { font-weight: 700; letter-spacing: -0.025em; }
.auth-art .feat span { font-weight: 500; }
.auth-form h2 { font-weight: 700; letter-spacing: -0.02em; }
/* thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(100, 116, 139, .45) transparent; }

/* ===== phones: list & report tables as cards (labels come from labelTable() in app.js) ===== */
@media (max-width: 700px) {
  table.mcards { min-width: 0 !important; border-collapse: separate; }
  table.mcards thead { display: none; }
  table.mcards, table.mcards tbody, table.mcards tfoot, table.mcards tr { display: block; width: 100%; }
  table.mcards tbody, table.mcards tfoot { padding: 10px; }
  .card:not(.flush) table.mcards tbody, .card:not(.flush) table.mcards tfoot, .drawer table.mcards tbody { padding: 0; }
  table.mcards tr { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 8px; margin-bottom: 10px; box-shadow: var(--shadow); }
  table.mcards td { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 6px 0 !important; border: 0 !important;
    text-align: right; white-space: normal; background: none !important; min-width: 0; font-size: 13.5px; }
  table.mcards td::before { content: attr(data-l); flex: none; max-width: 48%; text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; }
  table.mcards td[data-l=""]::before, table.mcards td:not([data-l])::before { display: none; }
  table.mcards td:empty { display: none; }
  /* first column is the card's title */
  table.mcards td:first-child { justify-content: flex-start; text-align: left; font-size: 14.5px; font-weight: 600; padding: 10px 0 !important;
    margin-bottom: 4px; border-bottom: 1px solid var(--line-2) !important; }
  table.mcards td:first-child::before { display: none; }
  table.mcards td:first-child:last-child { border-bottom: 0 !important; margin: 0; }
  /* a cell spanning columns (group heading, "nothing found", notes) uses the full width */
  table.mcards td.span { display: block; text-align: left; font-weight: 600; }
  table.mcards td.span::before { display: none; }
  table.mcards tr:has(> td.span:only-child) { padding-top: 8px; }
  table.mcards tr:has(.empty) { box-shadow: none; border-style: dashed; }
  table.mcards td .who { min-width: 0; }
  table.mcards td .num, table.mcards td.num { text-align: right; }
  /* totals, groups, sub-rows of reports */
  table.mcards tr.tot, table.mcards tfoot tr { background: var(--primary-soft); border-color: var(--primary-soft-2); }
  table.mcards tr.grp { background: var(--line-2); }
  table.mcards tr.r:hover td, table.mcards tr.click:hover td { background: none !important; }
  table.mcards tr.r:active, table.mcards tr.click:active { border-color: var(--primary); }
  table.mcards td[class*="l1"], table.mcards td[class*="l2"], table.mcards td[class*="l3"], table.mcards td[class*="l4"] { padding-left: 0 !important; }
  .tbl-wrap:has(> table.mcards) { overflow: visible; }
}
@media (max-width: 700px) {
  table.mcards td.mhide { display: none; }
  /* any page split into side-by-side columns stacks on phones */
  .cols, .cols[style], .admin, .form-bottom, .tform, .c-dash2, .c3 { grid-template-columns: minmax(0, 1fr) !important; }
  /* admin settings menu: one swipeable row */
  .anav { position: static; display: flex; gap: 6px; overflow-x: auto; padding: 8px; scrollbar-width: none; }
  .anav h6 { display: none; }
  .anav a { flex: none; white-space: nowrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; }
  .anav a.on { border-color: var(--primary-soft-2); }
  /* summary boxes: two per row, compact */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
  .stat { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .stat .si { width: 34px; height: 34px; }
  .stat .si .i { width: 16px; height: 16px; }
  .stat .v { font-size: 16px; overflow-wrap: anywhere; }
  .stat .l, .stat .c { font-size: 11.5px; }
  /* page headers: title on its own line, actions wrap neatly */
  .page-head { gap: 10px; }
  .page-head .ph-t { flex: 1 1 100%; }
  .page-head .ph-a { flex-wrap: wrap; gap: 8px; }
  /* filter tabs scroll sideways instead of squeezing */
  .toolbar { flex-wrap: wrap; }
  .toolbar .tabs { flex: 1 1 100%; }
  .toolbar .searchbox { flex: 1 1 100%; }
}
@media (max-width: 700px) {
  /* the whole card opens the record, so the row's "Details" arrow is redundant */
  table.mcards tr.r td[data-l=""]:has(> .xbtn[title="Details"]:only-child) { display: none; }
  .pager { flex-wrap: wrap; justify-content: center; gap: 8px 12px; }
  .pager > :first-child { flex: 1 1 100%; text-align: center; }
}
