/* ==========================================================================
   Arcston Invoice Studio — application UI
   Brand: arcston red #D51F36 · Global gray #5F6061
   ========================================================================== */
:root {
  --bg: #f5f4f1;
  --bg-2: #eceae6;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --ink: #16171a;
  --ink-2: #3e4044;
  --muted: #74767b;
  --faint: #a3a5a9;
  --line: #e8e6e1;
  --line-2: #d9d6d0;
  --brand: #d51f36;
  --brand-ink: #b3172b;
  --brand-soft: #fdecee;
  --brand-gray: #5f6061;
  --blue: #0b69b7;   --blue-soft: #e8f1fa;
  --green: #147a45;  --green-soft: #e5f3ea;
  --amber: #a15c00;  --amber-soft: #fcf0dc;
  --red: #c0192e;    --red-soft: #fce8ea;
  --violet: #5b3fb5; --violet-soft: #eeeafb;
  --r-sm: 7px; --r: 10px; --r-lg: 14px; --r-xl: 18px;
  --sh-1: 0 1px 2px rgba(22, 23, 26, 0.05);
  --sh-2: 0 1px 2px rgba(22, 23, 26, 0.04), 0 8px 24px -8px rgba(22, 23, 26, 0.12);
  --sh-3: 0 24px 64px -16px rgba(22, 23, 26, 0.28), 0 2px 6px rgba(22, 23, 26, 0.06);
  --ring: 0 0 0 3.5px rgba(213, 31, 54, 0.14);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --side-w: 248px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.45 var(--font); letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--muted); }
.dim { opacity: 0.55; }
.ico { flex: none; display: block; }
[hidden] { display: none !important; }
::selection { background: rgba(213, 31, 54, 0.16); }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px 14px;
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; text-decoration: none; }
.side-logo img { height: 34px; width: auto; }
.side-logo .tag { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-left: 1px solid var(--line-2); padding-left: 10px; line-height: 1.25; }
.side .btn-new { width: 100%; justify-content: center; margin-bottom: 18px; height: 40px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--faint); letter-spacing: 0.07em; text-transform: uppercase; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.nav a .ico { color: var(--muted); transition: color 0.15s; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--bg); color: var(--ink); }
.nav a.on .ico { color: var(--brand); }
.nav a .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--bg); padding: 1px 7px; border-radius: 99px; }
.nav a.on .count { background: var(--surface); }
.nav a .count:empty { display: none; }
.chart-empty { position: relative; }
.chart-empty .msg { position: absolute; inset: 0 0 26px 46px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 0 18px; display: flex; flex-direction: column; gap: 6px; }
/* Sidebar scrolls on short screens instead of clipping the bottom items */
.side { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; padding-bottom: 8px; }
.side::-webkit-scrollbar { width: 6px; }
.side::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; }
.side > * { flex-shrink: 0; } /* never squeeze the logo / New document button when the sidebar overflows */
.side .nav { flex: none; }
.side .nav a { padding: 7px 10px; }
.side .nav-label { padding-top: 12px; }
.sync { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 0 10px; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.sync.busy .dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); animation: pulse 1s infinite; }
.sync.err .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
@keyframes pulse { 50% { opacity: 0.35; } }

.main { min-width: 0; }
.page { max-width: 1320px; margin: 0 auto; padding: 30px 36px 64px; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-h h1 { font-size: 26px; line-height: 1.15; }
.page-h p { margin: 6px 0 0; color: var(--muted); }
.page-h .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-bar { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; font-weight: 500; white-space: nowrap; background: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s, color 0.15s;
}
a.btn, a.icon-btn { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 1px 2px rgba(179, 23, 43, 0.35); }
.btn-primary:hover { background: var(--brand-ink); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #2b2d31; }
.btn-secondary { background: var(--surface); border-color: var(--line-2); box-shadow: var(--sh-1); }
.btn-secondary:hover { border-color: #c7c3bc; background: var(--surface-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a01426; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: none; color: var(--ink-2); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.bordered { border-color: var(--line-2); background: var(--surface); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .hint.err { color: var(--red); }
.field .hint.ok { color: var(--green); }
.inp, .sel, .ta, .datefield {
  width: 100%; height: 38px; padding: 0 11px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); outline: none; transition: border-color 0.15s, box-shadow 0.15s; min-width: 0;
}
.inp::placeholder, .ta::placeholder { color: var(--faint); }
.inp:hover, .sel:hover, .ta:hover, .datefield:hover { border-color: #c7c3bc; }
.inp:focus, .sel:focus, .ta:focus, .datefield:focus-visible { border-color: var(--brand); box-shadow: var(--ring); }
.inp.num { text-align: right; font-variant-numeric: tabular-nums; }
.inp.big { height: 48px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.inp[readonly] { background: var(--surface-2); color: var(--ink-2); }
.ta { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.ta.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.sel {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2374767b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.datefield { display: flex; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.datefield span { flex: 1; font-variant-numeric: tabular-nums; }
.datefield em { font-style: normal; color: var(--faint); }
.datefield .ico:first-child { color: var(--muted); }
.inp-group { display: flex; align-items: stretch; }
.inp-group .inp { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.inp-group .addon { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-2); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.inp-group .addon.pre { border-left: 1px solid var(--line-2); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.inp-group .addon.pre + .inp { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
/* Layout children may shrink below their content (long names, nowrap labels) instead of widening the page */
.grid > *, .split > *, .x-grid > *, .calc-wrap > *, .arch-grid > *, .lists-grid > *, .kpis > *, .set-grid > *, .dash-grid > *, .ed-body > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* segmented control */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--bg-2); border-radius: 9px; padding: 3px; gap: 2px; width: 100%; max-width: 100%; } /* wraps instead of spilling when labels don't fit */
.seg button {
  flex: 1; border: 0; background: none; border-radius: 7px; height: 32px; padding: 0 10px; font-weight: 500; font-size: 13px;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s var(--ease); white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 0.5px rgba(0,0,0,.04); }
.seg.lg button { height: 40px; font-size: 14px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s;
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: #c2beb7; color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.ghost { border-style: dashed; }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13.5px; color: var(--ink-2); padding: 4px 0; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; width: 34px; height: 20px; border-radius: 99px; background: #d6d3cd; position: relative;
  transition: background 0.2s var(--ease); flex: none; cursor: pointer;
}
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform 0.2s var(--ease); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:focus-visible { box-shadow: var(--ring); outline: none; }
.switch .sub { display: block; font-size: 12px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--ink); width: 15px; height: 15px; margin: 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-h h3 { font-size: 15px; }
.card-h .muted { font-size: 13px; }
.card-b { padding: 16px 20px 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .k-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .k-label .ico { color: var(--faint); }
.kpi .k-val { font-size: 27px; font-weight: 600; letter-spacing: -0.03em; margin-top: 10px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.kpi.accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi.accent .k-label, .kpi.accent .k-sub { color: #b9bbc0; }
.kpi.accent .k-label .ico { color: var(--brand); }
.kpi .bar { height: 5px; border-radius: 99px; background: var(--bg-2); margin-top: 12px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.kpi.accent .bar { background: rgba(255,255,255,.12); }

.dash-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 14px; }
.dash-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--line); stroke-dasharray: 2 4; }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart .b-inv { fill: var(--ink); }
.chart .b-rec { fill: var(--brand); }
.chart .b-out { fill: #b4b1aa; }
.chart .b-hover { fill: transparent; }
.chart g.m:hover .b-inv { fill: #3a3c41; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 7px 10px; border-radius: 8px; box-shadow: var(--sh-2); z-index: 60; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* lists / tables */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .ref { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--ink); }
.tbl .who { font-weight: 500; }
.tbl .who small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 1px; }
.tbl .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.tbl .row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0.35; transition: opacity 0.15s; }
.tbl tr:hover .row-actions, .tbl tr:focus-within .row-actions { opacity: 1; }
.type-dot { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.type-dot::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--brand); }
.type-dot.q::before { background: var(--blue); border-radius: 50%; }
.tbl-wrap { overflow-x: auto; }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.pill-neutral { background: var(--bg-2); color: var(--ink-2); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-violet { background: var(--violet-soft); color: var(--violet); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .inp { padding-left: 36px; }
.filters .sel { width: auto; min-width: 140px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 500; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs a.on, .tabs button.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .count { font-size: 11.5px; background: var(--bg-2); color: var(--muted); border-radius: 99px; padding: 1px 7px; }

.attn { display: flex; flex-direction: column; }
.attn a { display: flex; align-items: center; gap: 12px; padding: 11px 20px; text-decoration: none; border-top: 1px solid var(--line); }
.attn a:hover { background: var(--surface-2); }
.attn .a-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.attn .a-ico.red { background: var(--red-soft); color: var(--red); }
.attn .a-ico.amber { background: var(--amber-soft); color: var(--amber); }
.attn .a-ico.blue { background: var(--blue-soft); color: var(--blue); }
.attn .a-t { flex: 1; min-width: 0; }
.attn .a-t b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attn .a-t small { color: var(--muted); font-size: 12.5px; }
.attn .a-v { font-weight: 600; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .ico { color: var(--faint); margin-bottom: 4px; }
.empty h4 { color: var(--ink); font-size: 15px; }
.empty p { margin: 0 0 8px; max-width: 360px; }
.empty > * { max-width: 100%; }
.empty .btn { white-space: normal; height: auto; min-height: 36px; padding-block: 7px; text-align: center; justify-content: center; }

/* ---------- modal / toast / menus ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(22, 23, 26, 0.32); backdrop-filter: blur(3px); opacity: 0; transition: opacity 0.18s; }
.modal-wrap.in { opacity: 1; }
.modal { width: 100%; min-width: 0; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); max-height: calc(100vh - 40px); display: flex; flex-direction: column; transform: translateY(8px) scale(0.985); transition: transform 0.22s var(--ease); }
.modal-wrap.in .modal { transform: none; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-h h3 { font-size: 17px; }
.modal-b { padding: 10px 20px 20px; overflow: auto; }
.modal-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.confirm-msg { margin: 0; color: var(--ink-2); }
.step-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.step-label:first-child { margin-top: 4px; }
.step-label b { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 11px; letter-spacing: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tpl { text-align: left; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r); padding: 11px 12px; transition: all 0.15s; }
.tpl:hover { border-color: #c2beb7; }
.tpl.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.tpl b { display: block; font-weight: 500; font-size: 13.5px; }
.tpl small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; margin-top: 2px; }
.setup-summary { margin-top: 16px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px dashed var(--line-2); font-size: 13px; color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.setup-summary .ico { color: var(--brand); }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; box-shadow: var(--sh-2); font-weight: 500; font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: all 0.22s var(--ease); }
.toast.in { opacity: 1; transform: none; }
.toast .ico { color: #5fd08f; }
.toast-err .ico { color: #ff8595; }

.pop-menu { position: fixed; z-index: 70; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3); padding: 5px; }
.pop-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; text-align: left; font-size: 13.5px; color: var(--ink-2); }
.pop-menu button:hover { background: var(--bg); color: var(--ink); }
.pop-menu button .ico { color: var(--muted); }
.pop-menu button.danger { color: var(--red); }
.pop-menu button.danger .ico { color: var(--red); }
.pop-menu button[disabled] { opacity: 0.4; }
.pop-menu kbd { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }

.dp { position: fixed; z-index: 90; width: 284px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-3); padding: 12px; }
.dp-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-t { font-weight: 600; }
.dp-t span { color: var(--muted); font-weight: 500; }
.dp-w, .dp-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-w span { text-align: center; font-size: 11px; color: var(--faint); font-weight: 500; padding: 4px 0; }
.dp-g .d { height: 34px; border: 0; border-radius: 8px; background: none; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); transition: background 0.12s; }
.dp-g .d:hover { background: var(--bg); }
.dp-g .d.out { color: var(--faint); }
.dp-g .d.today { box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 600; }
.dp-g .d.sel { background: var(--brand); color: #fff; font-weight: 600; box-shadow: none; }
.dp-f { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.dp-f .chip { height: 26px; font-size: 12px; padding: 0 10px; }
.dp-t { display: flex; align-items: center; gap: 2px; }
.dp-sel {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 7px; cursor: pointer; font: 600 14px var(--font); color: var(--ink);
  padding: 5px 20px 5px 7px; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2374767b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 5px center;
}
.dp-sel:hover, .dp-sel:focus-visible { background-color: var(--bg); outline: none; }
.dp-sel.yr { color: var(--muted); font-weight: 500; }

/* range slider (row spacing) */
.range { display: flex; align-items: center; gap: 12px; height: 38px; }
.range input[type="range"] {
  flex: 1; min-width: 40px; width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 99px; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--ink) 0 var(--p, 40%), var(--line-2) var(--p, 40%) 100%);
}
.range input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 1.5px solid var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.18); cursor: grab; transition: transform .12s; }
.range input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); cursor: grabbing; }
.range input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 1.5px solid var(--ink); cursor: grab; }
.range input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
.range output { min-width: 50px; text-align: right; font: 500 12.5px var(--mono); color: var(--ink-2); }
.range .ends { font-size: 11.5px; color: var(--faint); }

/* sign-in code */
.inp.pin { height: 54px; text-align: center; font: 500 26px var(--mono); letter-spacing: 0.45em; padding-left: 0.45em; }
.inp.pin::placeholder { letter-spacing: 0.3em; color: var(--line-2); }
.auth-form .auth-switch { height: auto; padding: 4px 8px; align-self: center; color: var(--muted); font-size: 13px; }

/* inline "add" chips & label links */
.add-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.add-chips .chip { border-style: dashed; height: 28px; font-size: 12.5px; color: var(--ink-2); }
.add-chips .chip .ico { color: var(--muted); }
.add-chips .chip:hover { border-style: solid; }
.lbl-link { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); text-decoration: none; }
.lbl-link:hover { color: var(--brand); }
.tax-block { margin-top: 14px; padding: 4px 14px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.meta-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* presets → lists */
.lists-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.list-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.list-row.two { grid-template-columns: 78px 1fr auto auto auto; }
.list-sub { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 4px 0 8px; }
.list-sub + .list-row { margin-top: 0; }
.list-block + .list-block { margin-top: 18px; }
@media (max-width: 900px) { .lists-grid { grid-template-columns: 1fr; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { position: relative; overflow: hidden; background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; gap: 44px; }
.auth-art > div:not(.paper) { position: relative; z-index: 2; }
.auth-art .paper { position: absolute; z-index: 1; left: 46%; top: 44%; width: 440px; transform: rotate(-7deg); border-radius: 4px; overflow: hidden; box-shadow: 0 40px 80px rgba(0,0,0,.5); }
.auth-art .paper.back { left: 22%; top: 54%; transform: rotate(5deg); opacity: 0.28; }
.auth-art h2 { font-size: 40px; line-height: 1.05; letter-spacing: -0.035em; max-width: 440px; position: relative; }
.auth-art h2 em { font-style: normal; color: var(--brand); }
.auth-art p { color: #a9abb0; max-width: 380px; position: relative; }
.auth-art .brandmark { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; color: #c9cbd0; position: relative; }
.auth-art .brandmark i { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); }
.auth-form { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.auth-form img { height: 44px; width: auto; align-self: flex-start; margin-bottom: 12px; }
.auth-form h1 { font-size: 24px; }
.auth-form .sub { color: var(--muted); margin: -8px 0 6px; }
.auth-form .btn { height: 42px; justify-content: center; }
.auth-err { color: var(--red); font-size: 13px; min-height: 18px; }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r); background: var(--amber-soft); color: #6d3f00; font-size: 13px; margin-bottom: 18px; }

/* ---------- editor ---------- */
.ed { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.ed-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0; }
.ed-top .crumb { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ed-top .crumb .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-top .crumb .t .mono { color: var(--muted); font-weight: 500; margin-left: 6px; }
.ed-top .sp { flex: 1; }
.ed-top .saved { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ed-top .sel { width: auto; height: 34px; font-size: 13px; }
.ed-body { display: grid; grid-template-columns: minmax(420px, 480px) 1fr; min-height: 0; }
.ed-form { overflow-y: auto; border-right: 1px solid var(--line); background: var(--surface); scrollbar-gutter: stable; }
.ed-canvas { position: relative; overflow: auto; background: #e6e3de; background-image: radial-gradient(rgba(0,0,0,.07) 1px, transparent 1px); background-size: 18px 18px; }
.ed-pages { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 28px 28px 110px; transform-origin: top center; }
.ed-pages .a4 { box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 18px 40px -12px rgba(0,0,0,.25); border-radius: 2px; }
.zoombar { position: sticky; bottom: 18px; left: 0; margin: -70px auto 18px; width: max-content; z-index: 5; display: flex; align-items: center; gap: 4px; background: rgba(22,23,26,.92); color: #fff; border-radius: 99px; padding: 5px; box-shadow: var(--sh-2); backdrop-filter: blur(8px); }
.zoombar .icon-btn { color: #d7d8db; width: 32px; height: 32px; border-radius: 99px; }
.zoombar .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.zoombar .z { font-size: 12px; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; color: #d7d8db; }
.zoombar .sep { width: 1px; height: 18px; background: rgba(255,255,255,.16); margin: 0 4px; }
.zoombar .pg { font-size: 12px; color: #a9abb0; padding: 0 8px 0 4px; }

.sec { border-bottom: 1px solid var(--line); }
.sec-h { width: 100%; display: flex; align-items: center; gap: 12px; padding: 16px 20px; border: 0; background: none; text-align: left; }
.sec-h:hover { background: var(--surface-2); }
.sec-h .n { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--bg); color: var(--ink-2); flex: none; }
.sec-h .n .ico { width: 14px; height: 14px; }
.sec-h .tt { flex: 1; min-width: 0; }
.sec-h .tt b { font-weight: 600; display: block; font-size: 14px; }
.sec-h .tt small { color: var(--muted); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sec-h .chev { color: var(--faint); transition: transform 0.2s var(--ease); }
.sec.open .sec-h .chev { transform: rotate(180deg); }
.sec.open .sec-h .n { background: var(--ink); color: #fff; }
.sec-b { padding: 2px 20px 22px; display: none; }
.sec.open .sec-b { display: block; }
.sub-h { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 18px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.sub-h:first-child { margin-top: 4px; }

.item { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 10px 10px 10px 12px; margin-bottom: 8px; transition: border-color 0.15s, box-shadow 0.15s; }
.item:focus-within { border-color: var(--line-2); box-shadow: var(--sh-2); }
.item.opt { background: repeating-linear-gradient(-45deg, var(--surface), var(--surface) 8px, var(--surface-2) 8px, var(--surface-2) 16px); }
.item-top { display: flex; align-items: flex-start; gap: 8px; }
.item-top .idx { font-family: var(--mono); font-size: 12px; color: var(--faint); padding-top: 10px; width: 18px; flex: none; }
.item-top .inp { flex: 1; }
.item-top .ta-title { min-height: 38px; height: 38px; resize: none; overflow: hidden; }
.item-nums { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 8px; margin: 8px 0 0 26px; }
.item-nums.hsn { grid-template-columns: 0.9fr 1fr 1.25fr 1.25fr; }
.item-nums .field > label { font-size: 11.5px; color: var(--muted); }
.item-nums .amount { height: 38px; display: flex; align-items: center; justify-content: flex-end; padding: 0 11px; border-radius: var(--r-sm); background: var(--surface-2); font-weight: 600; font-variant-numeric: tabular-nums; border: 1px solid var(--line); }
.item-more { margin: 8px 0 0 26px; }
.item-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 6px 0 0 20px; }
.item-tools .btn { color: var(--muted); }
.item-tools .sp { flex: 1; }
.add-row { display: flex; gap: 8px; }
.add-row .btn { flex: 1; justify-content: center; border-style: dashed; }

.totals-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 14px; margin-top: 12px; }
.totals-card .tr { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.totals-card .tr.g { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 10px; color: var(--ink); font-weight: 600; font-size: 15.5px; }
.rev { margin-top: 12px; border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.rev-h { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--ink); color: #fff; }
.rev-h b { font-weight: 600; font-size: 13.5px; }
.rev-h small { color: #a9abb0; font-size: 12px; }
.rev-h .ico { color: var(--brand); }
.rev-b { padding: 14px; background: var(--surface); }
.rev-out { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.rev-out div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.rev-out small { display: block; font-size: 11.5px; color: var(--muted); }
.rev-out b { font-weight: 600; font-variant-numeric: tabular-nums; }
.rev-out .wide { grid-column: span 2; }

.md-bar { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--line-2); border-bottom: 0; border-radius: var(--r-sm) var(--r-sm) 0 0; background: var(--surface-2); flex-wrap: wrap; }
.md-bar + .ta { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.md-bar .icon-btn { width: 30px; height: 28px; }
.md-bar .btn { height: 28px; font-size: 12.5px; padding: 0 8px; }
.md-help { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.md-help code { font-family: var(--mono); font-size: 11.5px; background: var(--bg); padding: 1px 5px; border-radius: 4px; color: var(--ink-2); }
.meta-row { display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.meta-row .fixed { height: 38px; display: flex; align-items: center; padding: 0 11px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gst-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 9px 12px; border-radius: 9px; background: var(--blue-soft); color: #0a4c86; margin-top: 12px; }
.gst-note.inter { background: var(--violet-soft); color: #3f2b86; }
.pay-list .pay-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.pay-list .pay-row:last-child { border-bottom: 0; }
.balance-box { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; }
.balance-box b { font-size: 18px; font-variant-numeric: tabular-nums; }
.img-pick { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2); }
.img-pick .thumb { width: 88px; height: 56px; border-radius: 8px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; }
.img-pick .thumb img { max-width: 92%; max-height: 90%; object-fit: contain; }
.img-pick .info { flex: 1; min-width: 0; font-size: 13px; }
.img-pick .info small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- presets / settings ---------- */
.split { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
.plist { max-height: calc(100vh - 230px); overflow: auto; padding: 6px; }
.plist button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 0; background: none; border-radius: 9px; }
.plist button:hover { background: var(--surface-2); }
.plist button.on { background: var(--bg); }
.plist button .pl-t { flex: 1; min-width: 0; }
.plist button b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plist button small { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plist .avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--bg-2); color: var(--ink-2); flex: none; }
.plist button.on .avatar { background: var(--ink); color: #fff; }
.plist-h { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.plist-h .search { max-width: none; min-width: 0; }
.editor-card .card-b { display: flex; flex-direction: column; gap: 14px; }
.editor-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.set-grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.set-grid:last-child { border-bottom: 0; }
.set-grid > div:first-child h3 { font-size: 15px; }
.set-grid > div:first-child p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tokens code { font-family: var(--mono); font-size: 11.5px; background: var(--bg); border: 1px solid var(--line); padding: 2px 6px; border-radius: 5px; cursor: pointer; }
.tokens code:hover { border-color: var(--line-2); color: var(--brand); }
.preview-ref { font-family: var(--mono); font-size: 13px; background: var(--ink); color: #fff; padding: 4px 10px; border-radius: 6px; display: inline-block; }

/* ---------- tools ---------- */
.calc-wrap { display: grid; grid-template-columns: 1.05fr 1fr; gap: 14px; }
.calc-result { background: var(--ink); color: #fff; border-radius: var(--r-lg); padding: 24px; display: flex; flex-direction: column; gap: 4px; }
.calc-result .cr-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.1); font-variant-numeric: tabular-nums; color: #c9cbd0; }
.calc-result .cr-row b { color: #fff; font-weight: 500; }
.calc-result .cr-row.big { border-bottom: 0; padding-top: 16px; }
.calc-result .cr-row.big b { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; }
.calc-result .cr-row.big span { align-self: flex-end; }
.calc-result .words { font-size: 12.5px; color: #a9abb0; margin-top: 4px; }
.calc-result .cr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.calc-result .btn-secondary { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
.calc-result .btn-secondary:hover { background: rgba(255,255,255,.14); }

/* editor: collapse the sidebar into an icon rail */
.rail-logo { display: none; }
@media (min-width: 901px) {
  .shell.in-editor { grid-template-columns: 68px 1fr; }
  .shell.in-editor .side { padding: 16px 10px 12px; align-items: center; }
  .shell.in-editor .side-logo { padding: 2px 0 16px; }
  .shell.in-editor .side-logo img:not(.rail-logo), .shell.in-editor .side-logo .tag,
  .shell.in-editor .nav-label, .shell.in-editor .nav a .count, .shell.in-editor .side .btn-new kbd, .shell.in-editor .sync .txt { display: none; }
  .shell.in-editor .rail-logo { display: block; width: 34px; height: 34px; }
  .shell.in-editor .side .btn-new { width: 40px; padding: 0; font-size: 0; gap: 0; }
  .shell.in-editor .nav a { font-size: 0; gap: 0; justify-content: center; padding: 10px; }
  .shell.in-editor .nav { gap: 4px; }
  .shell.in-editor [data-logout] { font-size: 0; gap: 0; width: 40px; justify-content: center !important; }
  .shell.in-editor .install-btn { font-size: 0; gap: 0; width: 40px; height: 36px; padding: 0; }
  .shell.in-editor .sync { padding: 0; justify-content: center; }
}

/* ---------- sync / install / update ---------- */
button.sync { border: 0; background: none; width: 100%; text-align: left; cursor: pointer; border-radius: 7px; padding: 6px 10px; }
button.sync:hover { background: var(--surface-2); color: var(--ink); }
.sync.off .dot { background: var(--faint); box-shadow: 0 0 0 3px var(--bg-2); }
.nav a .count.due { background: var(--red-soft); color: var(--red); }
.install-btn { justify-content: center; }
.update-bar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 85; display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 8px 8px 8px 16px; border-radius: 99px; box-shadow: var(--sh-3); font-size: 13.5px; }
.update-bar .ico { color: var(--brand); }
.filed-note { display: flex; gap: 10px; align-items: flex-start; margin: 14px 20px 0; padding: 10px 12px; border-radius: 9px; background: var(--green-soft); color: #0e5a33; font-size: 12.5px; line-height: 1.45; }
.filed-note .ico { margin-top: 1px; }
.how { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.how > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); font-size: 13px; }
.how p { margin: 4px 0 0; color: var(--ink-2); line-height: 1.5; }

/* ---------- analytics ---------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; margin-bottom: 14px; }
.filterbar .sel { width: auto; min-width: 170px; }
.filterbar .seg { width: auto; }
.an-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.an-grid > .card { min-width: 0; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(22, 23, 26, 0.04); }
.chart .axis.up { fill: var(--green); font-weight: 600; }
.chart .axis.down { fill: var(--red); font-weight: 600; }
.delta { font-weight: 600; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hb { display: grid; grid-template-columns: minmax(120px, 1.1fr) 2fr auto; gap: 12px; align-items: center; padding: 5px 6px; border-radius: 7px; }
.hb:hover { background: var(--surface-2); }
.hb-l { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.hb-l .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-l .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.hb-bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.hb-bar i { display: block; height: 100%; border-radius: 99px; }
.hb-v { text-align: right; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb-v small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.compact-tbl td, .compact-tbl th { padding: 8px 10px; font-size: 13px; }
.tbl-wrap.mt { margin-top: 12px; }
.funnel { display: flex; flex-direction: column; gap: 10px; }
.fn { display: grid; grid-template-columns: 90px 1fr 36px 40px; gap: 10px; align-items: center; font-size: 13px; }
.fn-bar { height: 22px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.fn-bar i { display: block; height: 100%; border-radius: 6px; }
.fn b { text-align: right; font-variant-numeric: tabular-nums; }
.fn small { color: var(--muted); text-align: right; }
.funnel-lost { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.funnel-lost b { color: var(--ink); }
.pivot td, .pivot th { padding: 7px 9px; font-size: 12.5px; white-space: nowrap; }
.pivot .pv-h { font-weight: 500; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pivot .pv-0 { color: var(--faint); }

/* ---------- GST filings ---------- */
.gst-tbl td { vertical-align: top; }
.gst-tbl td small { display: block; font-size: 11.5px; }
.gst-tbl .ret { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.gst-tbl .ret small { color: var(--muted); }
.warn { color: var(--amber); display: inline-flex !important; align-items: center; gap: 4px; margin-top: 3px; }
.pick-list { max-height: 44vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
.check.pick { display: grid; grid-template-columns: auto 110px 1fr auto; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.check.pick:last-child { border-bottom: 0; }
.check.pick .num { font-variant-numeric: tabular-nums; }

/* ---------- PDF archive ---------- */
.arch-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; align-items: start; }
.arch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.prog { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; margin-bottom: 6px; }
.prog i { display: block; height: 100%; width: 0; background: var(--brand); border-radius: inherit; transition: width .25s var(--ease); }
.tree { font-size: 13px; max-height: 60vh; overflow: auto; }
.tr-node { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px calc(8px + var(--d) * 18px); border-radius: 6px; }
.tr-node:hover { background: var(--surface-2); }
.tr-node .ico { color: var(--muted); }
.tr-node small { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) { .an-grid, .arch-grid, .how { grid-template-columns: 1fr; } }

/* ---------- finance: invoices payments, GST status, bulk ---------- */
.tbl td.num, .tbl .ref { white-space: nowrap; }
.cb { width: 15px; height: 15px; accent-color: var(--ink); cursor: pointer; margin: 0; vertical-align: middle; }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--ink); color: #fff; font-size: 13px; }
.bulkbar .btn-secondary { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.bulkbar .btn-ghost { color: #d7d8db; }
.bulkbar .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.paycell { min-width: 150px; }
.paycell small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.paycell small b { color: var(--ink); font-weight: 600; }
.pbar { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; min-width: 80px; }
.pbar i { display: block; height: 100%; background: var(--amber); border-radius: inherit; }
.pbar i.full { background: var(--green); }
.gstbtn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px; border-radius: 99px; cursor: pointer; }
.gstbtn:hover .pill { box-shadow: 0 0 0 2px var(--line-2); }
.inv-strip { margin: 14px 20px 2px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 4px 12px; }
.is-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; flex-wrap: wrap; font-size: 13px; }
.is-row + .is-row { border-top: 1px dashed var(--line-2); }
.is-k { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-2); width: 88px; }
.is-k .ico { color: var(--muted); }
.is-v { color: var(--ink-2); flex: 1; min-width: 120px; }
.is-row .pbar { width: 90px; flex: none; }
.is-row .btn { height: 28px; }

/* GST roll-ups */
.qcard { margin-bottom: 14px; }
.qstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 14px 20px 6px; }
.qstats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.qstats small { display: block; font-size: 11.5px; color: var(--muted); }
.qstats b { font-weight: 600; font-variant-numeric: tabular-nums; }
.qstats b.neg { color: var(--red); }
.card-b .qstats { margin: 0 0 12px; }
.ygrid { display: grid; grid-template-columns: 70px repeat(12, 1fr); gap: 6px 4px; align-items: center; padding: 10px 20px 4px; font-size: 12px; }
.ygrid .yh { text-align: center; color: var(--muted); font-size: 11px; }
.ygrid .yl { color: var(--ink-2); font-weight: 500; }
.gdot { justify-self: center; width: 18px; height: 18px; border-radius: 6px; background: var(--bg-2); }
.gdot.g-filed { background: var(--green); }
.gdot.g-overdue { background: var(--red); }
.gdot.g-due { background: #e7a11a; }
.gdot.g-open { background: var(--line-2); }
.gdot.g-none { background: transparent; border: 1px dashed var(--line-2); }
.g9 { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 20px 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); }
.g9 small { display: block; color: var(--muted); font-size: 12.5px; }
.ok { color: var(--green); }

/* expenses */
.x-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.xf-modal .modal-b { padding-top: 14px; }
.xf-money { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; margin-top: 16px; padding: 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); align-items: start; }
.xf-money .totals-card { background: var(--surface); }
/* TDS withheld on a payment (not cash, but settles the balance) */
.tds-box { margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--line-2); border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.tds-box .chips { align-items: center; }
.tds-box .hint { font-size: 12px; color: var(--muted); margin-left: 2px; }
.remind-to { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.remind-to b { color: var(--ink-2); font-weight: 500; }
.span3 { grid-column: span 3; }
tfoot td { padding: 12px 14px; border-top: 1px solid var(--line-2); }

@media (max-width: 1180px) { .x-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .xf-money { grid-template-columns: 1fr; } .ygrid { grid-template-columns: 56px repeat(12, 1fr); padding: 10px 12px; } .gdot { width: 14px; height: 14px; } }

/* print root: rendered off-screen, shown only when printing */
#print-root { position: fixed; left: -10000px; top: 0; }

@media print {
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { position: static !important; left: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .ed-body { grid-template-columns: minmax(380px, 420px) 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; width: var(--side-w); transform: translateX(-100%); transition: transform 0.25s var(--ease); box-shadow: var(--sh-3); }
  .shell.nav-open .side { transform: none; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .mobile-bar img { height: 26px; }
  .page { padding: 20px 16px 48px; }
  .split, .calc-wrap, .set-grid { grid-template-columns: 1fr; }
  .ed-body { grid-template-columns: 1fr; }
  .ed-body.show-preview .ed-form { display: none; }
  .ed-body:not(.show-preview) .ed-canvas { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .ed-top { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .ed-top .crumb { flex: 1 1 160px; }
  .ed-top .sp { display: none; }
}
@media (min-width: 901px) { .only-mobile { display: none !important; } }
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .tpl-grid { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: 1fr; }
  .span3 { grid-column: auto; }
  .modal-f .btn { flex: 1 1 auto; justify-content: center; }
  .ed-top .saved { display: none; }
  .ed-top #as-template, .ed-top #pay, .ed-top #convert, .ed-top #print, .ed-top #toggle-preview { font-size: 0; gap: 0; padding: 0 10px; }
  .item-nums, .item-nums.hsn { grid-template-columns: 1fr 1fr; margin-left: 0; }
  .item-more, .item-tools { margin-left: 0; }
}
