/* =========================================================================
   Gianna Compta — design system
   Brand: monochrome ink on paper, Urbanist, the black disc as signature.
   ========================================================================= */

@font-face {
  font-family: "Urbanist";
  src: url("../fonts/Urbanist-Variable.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face { font-family: "Urbanist Num"; src: url("../fonts/UrbanistNum-400.woff") format("woff"); font-weight: 100 450; unicode-range: U+0030-0039; font-display: swap; }
@font-face { font-family: "Urbanist Num"; src: url("../fonts/UrbanistNum-500.woff") format("woff"); font-weight: 451 550; unicode-range: U+0030-0039; font-display: swap; }
@font-face { font-family: "Urbanist Num"; src: url("../fonts/UrbanistNum-600.woff") format("woff"); font-weight: 551 650; unicode-range: U+0030-0039; font-display: swap; }
@font-face { font-family: "Urbanist Num"; src: url("../fonts/UrbanistNum-700.woff") format("woff"); font-weight: 651 900; unicode-range: U+0030-0039; font-display: swap; }

:root {
  color-scheme: light;
  --ink: #090402;
  --ink-2: #3a3633;
  --mute: #736f6a;
  --faint: #a29e98;
  --line: #e5e4e0;
  --line-2: #d3d1cc;
  --bg: #f1f1ef;
  --paper: #ffffff;
  --sunk: #f1f0ed;
  --hover: #ecebe8;
  --on-ink: #ffffff;
  --ok: #1d7a4c;
  --ok-bg: #e4f1e9;
  --warn: #9a5c00;
  --warn-bg: #fbefd9;
  --alert: #c8231a;
  --alert-bg: #fce8e6;
  --chart-a: #090402;
  --chart-b: #8a8680;
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
  --shadow-float: 0 18px 48px rgba(9, 4, 2, .18), 0 2px 6px rgba(9, 4, 2, .08);
  --r-panel: 20px;
  --r-field: 12px;
  --r-pill: 999px;
  --font: "Urbanist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: "Urbanist Num", "Urbanist", ui-sans-serif, system-ui, sans-serif;
  --side-w: 252px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #f4f3f0;
    --ink-2: #d6d3ce;
    --mute: #a29e98;
    --faint: #6e6a65;
    --line: #2d2b28;
    --line-2: #3d3a36;
    --bg: #0e0d0c;
    --paper: #181716;
    --sunk: #211f1d;
    --hover: #26241f;
    --on-ink: #0e0d0c;
    --ok: #57c48f;
    --ok-bg: #16291f;
    --warn: #e8a64a;
    --warn-bg: #2e2312;
    --alert: #ff6f62;
    --alert-bg: #331714;
    --chart-a: #f4f3f0;
    --chart-b: #7d7972;
    --shadow-float: 0 18px 48px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f3f0; --ink-2: #d6d3ce; --mute: #a29e98; --faint: #6e6a65; --line: #2d2b28; --line-2: #3d3a36;
  --bg: #0e0d0c; --paper: #181716; --sunk: #211f1d; --hover: #26241f; --on-ink: #0e0d0c;
  --ok: #57c48f; --ok-bg: #16291f; --warn: #e8a64a; --warn-bg: #2e2312; --alert: #ff6f62; --alert-bg: #331714;
  --chart-a: #f4f3f0; --chart-b: #7d7972; --shadow-float: 0 18px 48px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--sunk); padding: .1em .35em; border-radius: 6px; word-break: break-all; }
.num, .amount, td.num, th.num { font-family: var(--num); }
.muted { color: var(--mute); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.i.rot90 { transform: rotate(90deg); }
.table td svg.i { display: inline-block; vertical-align: middle; width: 17px; height: 17px; color: var(--mute); }
.right { text-align: right; }
.hidden, [hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { width: 150px; opacity: .9; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .boot img, :root:not([data-theme="light"]) .logo-img { filter: invert(1); } }
:root[data-theme="dark"] .boot img, :root[data-theme="dark"] .logo-img { filter: invert(1); }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 22px 16px 18px; border-right: 1px solid var(--line); background: var(--paper);
  display: flex; flex-direction: column; gap: 14px;
}
.side > * { flex-shrink: 0; }
.side .brand { display: flex; align-items: center; padding: 0 10px 2px; }
.side .brand img { width: 122px; height: auto; }
.side .new-btn { margin: 0 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group { margin-top: 10px; }
.nav-label { font-size: 12.5px; color: var(--faint); padding: 0 12px 4px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 7px 12px; border-radius: var(--r-pill);
  text-decoration: none; color: var(--ink-2); font-weight: 550; font-size: 14.5px; position: relative;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .75; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.active { background: var(--ink); color: var(--on-ink); }
.nav a.active svg { opacity: 1; }
.nav a .count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--r-pill);
  background: var(--alert); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; font-family: var(--num);
}
.side-foot { margin-top: auto; padding: 8px 4px 0; display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.side-foot .company { font-size: 12.5px; color: var(--mute); margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 18px 36px 14px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.topbar .title { min-width: 0; flex: 1 1 300px; display: flex; align-items: center; gap: 12px; }
.topbar h1 { font-size: 28px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { flex: none; }
.topbar .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.search-btn { min-width: 220px; justify-content: flex-start !important; color: var(--mute) !important; background: var(--paper) !important; border: 1px solid var(--line) !important; }
.search-btn kbd { margin-left: auto; font: inherit; font-size: 12px; color: var(--faint); }
@media (max-width: 1399px) { .search-btn { min-width: 0; width: 40px; padding: 0 !important; justify-content: center !important; } .search-btn span, .search-btn kbd { display: none; } }
.content { padding: 8px 36px 64px; max-width: 1240px; width: 100%; }
.content.wide { max-width: none; }

/* mobile shell */
.mobile-bar, .tabbar { display: none; }
@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .topbar { padding: calc(12px + var(--safe-t)) 16px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .topbar .title { grid-column: 1; grid-row: 1; }
  .topbar .search-btn { grid-column: 2; grid-row: 1; width: 40px; padding: 0; justify-content: center !important; }
  .topbar .actions { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .topbar .actions:empty { display: none; }
  .topbar h1 { font-size: 22px; }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn kbd { display: none; }
  .content { padding: 4px 16px calc(110px + var(--safe-b)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 8px 6px calc(8px + var(--safe-b)); background: var(--paper); border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0;
    background: none; border: 0; text-decoration: none; color: var(--mute); font-size: 11.5px; font-weight: 600; cursor: pointer;
  }
  .tabbar a svg, .tabbar button svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--ink); }
  .tabbar .shutter-wrap { display: flex; justify-content: center; }
  .tabbar .shutter {
    width: 64px; height: 64px; margin-top: -30px; border-radius: 50%;
    background: var(--ink); color: var(--on-ink); display: grid; place-items: center;
    box-shadow: 0 8px 24px rgba(9, 4, 2, .28), 0 0 0 6px var(--paper);
  }
  .tabbar .shutter svg { width: 26px; height: 26px; }
  .tabbar .badge-dot { position: absolute; transform: translate(10px, -2px); width: 9px; height: 9px; border-radius: 50%; background: var(--alert); }
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-pill); border: 1px solid transparent;
  background: var(--paper); color: var(--ink); font-weight: 600; font-size: 14.5px; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s;
  border-color: var(--line-2);
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--alert); }
.btn.danger.solid { background: var(--alert); color: #fff; border-color: var(--alert); }
.btn.sm { height: 32px; padding: 0 13px; font-size: 13.5px; }
.btn.big { height: 50px; padding: 0 26px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.icon { width: 40px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn[disabled], .btn.busy { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.end { justify-content: flex-end; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; background: var(--sunk); border-radius: var(--r-pill); gap: 2px; flex-wrap: wrap; }
.seg button, .seg a {
  border: 0; background: transparent; height: 32px; padding: 0 14px; border-radius: var(--r-pill);
  font-weight: 600; font-size: 13.5px; color: var(--mute); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.seg button.on, .seg a.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(9, 4, 2, .12); }
.seg.big button { height: 44px; padding: 0 20px; font-size: 15px; }
.seg .n { font-family: var(--num); font-size: 12px; color: var(--faint); }
.seg svg { width: 16px; height: 16px; flex: none; }
.field > .seg:not(.methods) { align-self: flex-start; }
.seg.methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 18px; }
.seg.methods button { justify-content: center; height: 42px; border-radius: 15px; white-space: nowrap; }

/* chips (choice lists, e.g. expense categories) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); background: var(--paper); font-weight: 600; font-size: 14px; cursor: pointer; user-select: none;
}
.chip svg { width: 17px; height: 17px; }
.chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ------------------------------------------------------------------ panels */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 22px 24px; }
.panel + .panel, .stack > * + * { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 17px; }
.panel-head .sub { font-size: 13px; color: var(--mute); font-weight: 500; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush .panel-head { padding: 18px 22px 0; }
.grid { display: grid; gap: 16px; align-items: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side-r { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid > .panel + .panel { margin-top: 0; }
@media (max-width: 1100px) { .grid.side-r { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.kv dd.num { font-family: var(--num); }

/* figures */
.figure .label { font-size: 13px; color: var(--mute); font-weight: 550; }
.figure .value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; }
.figure .value small { font-size: 14px; color: var(--mute); font-weight: 600; margin-right: 4px; }
.figure .meta { font-size: 13px; color: var(--mute); margin-top: 2px; }

/* ------------------------------------------------------------------ dashboard */
.dash-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 34px; align-items: center; padding: 26px 30px; }
.disc {
  width: 236px; aspect-ratio: 1; border-radius: 50%; background: var(--ink); color: var(--on-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 26px;
  position: relative;
}
.disc .label { font-size: 13.5px; opacity: .72; font-weight: 600; }
.disc .value { font-size: 36px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; margin: 6px 0 4px; }
.disc .value small { display: block; font-size: 13px; font-weight: 600; opacity: .7; letter-spacing: 0; }
.disc .meta { font-size: 12.5px; opacity: .7; }
.disc.negative .value { color: #ff8a80; }
.ledger-list { display: flex; flex-direction: column; }
.ledger-list .row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: baseline;
  padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none;
}
.ledger-list .row:last-child { border-bottom: 0; }
.ledger-list .row .k { font-weight: 600; }
.ledger-list .row .k small { display: block; font-size: 12.5px; color: var(--mute); font-weight: 500; }
.ledger-list .row .v { font-family: var(--num); font-weight: 650; font-size: 18px; white-space: nowrap; }
.ledger-list a.row:hover .k { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 760px) {
  .dash-hero { grid-template-columns: 1fr; justify-items: center; padding: 22px 18px; gap: 18px; }
  .disc { width: 210px; }
  .dash-hero .ledger-list { width: 100%; }
}
.quick { display: flex; gap: 10px; flex-wrap: wrap; }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; text-decoration: none;
  background: var(--paper); border: 1px solid var(--line); font-weight: 600;
}
.alert .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink); }
.alert.warn .dot { background: var(--warn); }
.alert.alert-red .dot { background: var(--alert); }
.alert .go { margin-left: auto; color: var(--mute); }
.alert:hover { border-color: var(--line-2); }

/* chart */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--mute); font-size: 11px; font-family: var(--num); }
.chart .bar-a { fill: var(--chart-a); }
.chart .bar-b { fill: var(--chart-b); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + g rect, .chart g.month:hover rect { opacity: .82; }
.chart .label-top { fill: var(--ink); font-size: 11.5px; font-weight: 650; font-family: var(--num); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--mute); font-weight: 550; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--paper); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 9px 12px; box-shadow: var(--shadow-float); font-size: 13px; min-width: 170px;
}
.tooltip .t { color: var(--mute); font-weight: 600; margin-bottom: 4px; }
.tooltip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .r b { font-family: var(--num); font-weight: 700; }
.tooltip .r i { width: 12px; height: 2px; display: inline-block; border-radius: 2px; }

/* ------------------------------------------------------------------ tables / lists */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: var(--mute); padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:active td { background: var(--sunk); }
@media (hover: hover) and (min-width: 761px) { .table tbody tr.link:hover td { background: var(--sunk); } }
.table td .sub { display: block; font-size: 12.5px; color: var(--mute); font-weight: 500; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--line-2); border-bottom: 0; }
.panel.flush .table th:first-child, .panel.flush .table td:first-child { padding-left: 22px; }
.panel.flush .table th:last-child, .panel.flush .table td:last-child { padding-right: 22px; }
.list { display: flex; flex-direction: column; }
.list .item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 14px; align-items: center;
  padding: 13px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit;
}
.list .item:last-child { border-bottom: 0; }
.list .item .t { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .s { font-size: 12.5px; color: var(--mute); grid-column: 1; }
.list .item .v { font-family: var(--num); font-weight: 650; text-align: right; grid-row: 1 / span 2; grid-column: 2; white-space: nowrap; }
.list .item .v small { display: block; font-family: var(--font); font-size: 12px; color: var(--mute); font-weight: 550; }
a.item:hover .t { text-decoration: underline; text-underline-offset: 3px; }

/* document lines on phones: description on its own row, figures underneath */
@media (max-width: 760px) {
  .table.doc-lines thead { display: none; }
  .table.doc-lines, .table.doc-lines tbody { display: block; }
  .table.doc-lines tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
  .table.doc-lines tr:last-child { border-bottom: 0; }
  .table.doc-lines td { display: block; padding: 0 !important; border: 0; font-size: 13px; color: var(--mute); text-align: left; }
  .table.doc-lines td:first-child { flex: 1 0 100%; font-size: 14px; color: var(--ink); }
  .table.doc-lines td.q::after { content: " ×"; }
  .table.doc-lines td.t::before { content: "TVA "; }
  .table.doc-lines td:last-child { margin-left: auto; font-size: 14px; color: var(--ink); }
}

/* mobile tables become cards */
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .table.responsive td { padding: 0; border: 0; }
  .table.responsive tbody tr.link:active, .table.responsive tbody tr.link:active td { background: var(--sunk); }
  .table.responsive td.num { text-align: right; }
  .table.responsive td[data-m="hide"] { display: none; }
  .table.responsive td[data-m="full"] { grid-column: 1 / -1; }
  .panel.flush .table.responsive td:first-child { padding-left: 0; }
  .panel.flush .table.responsive td:last-child { padding-right: 0; }
}

/* status */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; flex: none; box-sizing: border-box; }
.status.draft { color: var(--mute); }
.status.draft::before { border-style: dashed; }
.status.open { color: var(--ink-2); }
.status.overdue { color: var(--alert); }
.status.overdue::before, .status.paid::before, .status.ok::before, .status.alert::before, .status.warn::before { background: currentColor; }
.status.paid, .status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.cancelled { color: var(--faint); text-decoration: line-through; }
.status.muted { color: var(--mute); }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--sunk); font-size: 12.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }
.pill.ink { background: var(--ink); color: var(--on-ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.alert { background: var(--alert-bg); color: var(--alert); }

/* ------------------------------------------------------------------ forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.form-grid > * { grid-column: span 12; }
.c2 { grid-column: span 2 !important; } .c3 { grid-column: span 3 !important; } .c4 { grid-column: span 4 !important; }
.c1 { grid-column: span 1 !important; } .c5 { grid-column: span 5 !important; } .c6 { grid-column: span 6 !important; } .c7 { grid-column: span 7 !important; }
.c8 { grid-column: span 8 !important; } .c9 { grid-column: span 9 !important; } .c10 { grid-column: span 10 !important; } .c11 { grid-column: span 11 !important; } .c12 { grid-column: span 12 !important; }
@media (max-width: 760px) { .form-grid > * { grid-column: span 12 !important; } .form-grid > .m6 { grid-column: span 6 !important; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint, .hint { font-size: 12.5px; color: var(--mute); font-weight: 500; }
.field .err { font-size: 12.5px; color: var(--alert); font-weight: 600; }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-field); border: 1px solid var(--line);
  background: var(--sunk); font-size: 15px; font-weight: 550; transition: border-color .15s, background .15s;
}
.field textarea, textarea.input { height: auto; min-height: 88px; padding: 11px 14px; line-height: 1.45; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--ink); background: var(--paper); box-shadow: none; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--alert); }
.field input.num, .input.num { text-align: right; font-family: var(--num); }
.field select, select.input {
  appearance: none; -webkit-appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23736f6a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 550; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 550; }
.switch input { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line-2); position: relative; transition: background .2s; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(18px); background: var(--paper); }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; background: var(--hover); border: 1px solid var(--line); border-right: 0; border-radius: var(--r-field) 0 0 var(--r-field); font-weight: 650; font-size: 13.5px; color: var(--mute); }
.input-group input { border-radius: 0 var(--r-field) var(--r-field) 0 !important; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.section-title { font-size: 15px; font-weight: 650; margin: 8px 0 -4px; }

/* combobox */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; max-height: 300px; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-float); padding: 6px;
}
.combo-list button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-weight: 550;
}
.combo-list button small { display: block; color: var(--mute); font-size: 12.5px; font-weight: 500; }
.combo-list button:hover, .combo-list button.hl { background: var(--sunk); }
.combo-list .empty { padding: 10px 12px; color: var(--mute); font-size: 13.5px; }

/* document line editor */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line {
  display: grid; grid-template-columns: minmax(0, 1fr) 84px 118px 112px 112px 36px; gap: 10px; align-items: start;
  padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper);
}
.line .desc-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.line .title-in { font-weight: 650; }
.line textarea { min-height: 44px !important; font-size: 14px !important; color: var(--ink-2); }
.line .amount-out { height: 44px; display: flex; align-items: center; justify-content: flex-end; font-family: var(--num); font-weight: 700; font-size: 15px; }
.line .line-tools { display: flex; flex-direction: column; gap: 4px; }
.line .mini { font-size: 12px; color: var(--mute); font-weight: 600; margin-bottom: 4px; display: block; }
.line .adv { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.line .adv select { height: 34px; font-size: 13px; width: auto; max-width: 100%; padding-left: 10px; }
.line .adv .input-pct { width: 90px; height: 34px; font-size: 13px; }
.line-head { display: grid; grid-template-columns: minmax(0, 1fr) 84px 118px 112px 112px 36px; gap: 10px; font-size: 12.5px; color: var(--mute); font-weight: 600; padding: 0 15px; }
.line-head .r { text-align: right; }
.line .mini.m-show { display: none; }
/* the editor adapts to the width of its own column, not the window */
.line-editor { container: lines / inline-size; }
@container lines (max-width: 760px) {
  .line-head { display: none; }
  .line { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .line .desc-col { grid-column: 1 / -1; }
  .line .q { grid-column: span 2; } .line .p { grid-column: span 4; }
  .line .t { grid-column: span 3; } .line .amount-out { grid-column: span 3; align-self: end; }
  .line .line-tools { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .line .mini.m-show { display: block; }
}
.totals { display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.totals .r { display: flex; justify-content: space-between; gap: 18px; }
.totals .r span:last-child { font-family: var(--num); font-weight: 600; }
.totals .grand {
  margin-top: 6px; padding: 14px 18px; border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink);
  display: flex; justify-content: space-between; align-items: baseline; font-weight: 650;
}
.totals .grand span:last-child { font-family: var(--num); font-size: 20px; }

/* doc header */
.doc-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: start; }
.doc-head .who { font-size: 20px; font-weight: 650; }
.doc-head .who a { text-decoration: none; }
.doc-head .who a:hover { text-decoration: underline; }
.doc-amount { text-align: right; }
.doc-amount .big { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; }
.doc-amount .big small { font-size: 14px; color: var(--mute); font-weight: 600; margin-right: 4px; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-top: 14px; font-size: 13.5px; }
.doc-meta div span { display: block; color: var(--mute); font-size: 12.5px; font-weight: 550; }
.doc-meta div b { font-weight: 650; }
.pdf-frame { width: 100%; height: 860px; border: 1px solid var(--line); border-radius: 14px; background: var(--sunk); }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.doc-layout .doc-preview { display: none; }
@media (min-width: 1560px) { .doc-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 560px); } .doc-layout .doc-preview { display: block; position: sticky; top: 84px; } }
.timeline { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.timeline .ev { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; }
.timeline .ev::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); transform: translateY(-1px); }
.timeline .ev .when { color: var(--mute); font-size: 12.5px; white-space: nowrap; }
.timeline .ev .sub { display: block; margin-top: 1px; }

/* ------------------------------------------------------------------ modal / sheet */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(9, 4, 2, .42); display: grid; place-items: center; padding: 20px; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--paper);
  border-radius: 24px; box-shadow: var(--shadow-float); padding: 24px; animation: rise .18s ease-out;
}
.modal.wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
@media (max-width: 760px) {
  .overlay { place-items: end center; padding: 0; }
  .modal { max-width: none; border-radius: 24px 24px 0 0; max-height: 92vh; padding: 20px 18px calc(20px + var(--safe-b)); }
  .modal.wide { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .overlay, .modal { animation: none; } * { scroll-behavior: auto !important; } }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(28px + var(--safe-b)); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--on-ink); padding: 12px 20px; border-radius: var(--r-pill); font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow-float); animation: rise .18s ease-out; pointer-events: auto; }
.toast.error { background: var(--alert); color: #fff; }
@media (max-width: 1023px) { .toasts { bottom: calc(96px + var(--safe-b)); } }

/* ------------------------------------------------------------------ misc */
.empty { padding: 42px 20px; text-align: center; color: var(--mute); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .ring { width: 54px; height: 54px; border-radius: 50%; border: 2px dashed var(--line-2); display: grid; place-items: center; color: var(--faint); }
.empty .ring svg { width: 22px; height: 22px; }
.empty b { color: var(--ink); font-size: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .search { position: relative; }
.toolbar .search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.toolbar .search input { padding-left: 38px; background: var(--paper); }
.summary-strip { display: flex; gap: 28px; flex-wrap: wrap; padding: 4px 2px 16px; }
.summary-strip .figure .value { font-size: 22px; }
.notice { padding: 14px 16px; border-radius: 14px; background: var(--sunk); font-size: 14px; display: flex; gap: 12px; align-items: flex-start; }
.notice svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.alert { background: var(--alert-bg); color: var(--alert); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice b { font-weight: 700; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--mute); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; font-size: 14.5px; }
.tabs a.on, .tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
/* settings: vertical rubric list beside the form, horizontal strip on phones */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.side-tabs { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; }
.side-tabs a { padding: 9px 12px; border-radius: 12px; color: var(--mute); font-weight: 600; text-decoration: none; font-size: 14.5px; }
.side-tabs a:hover { background: var(--hover); color: var(--ink); }
.side-tabs a.on { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
@media (max-width: 1023px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .side-tabs { position: static; flex-direction: row; overflow-x: auto; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; scrollbar-width: none; }
  .side-tabs::-webkit-scrollbar { display: none; }
  .side-tabs a { white-space: nowrap; border-radius: 0; padding: 10px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .side-tabs a:hover { background: none; }
  .side-tabs a.on { background: none; box-shadow: none; border-bottom-color: var(--ink); }
}
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 108px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--sunk); font-size: 12px; }
.thumb a { display: block; text-decoration: none; }
.thumb img { width: 100%; height: 108px; object-fit: cover; }
.thumb .file { height: 108px; display: grid; place-items: center; color: var(--mute); }
.thumb .file svg { width: 30px; height: 30px; }
.thumb .name { padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb .del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(9, 4, 2, .7); color: #fff; display: grid; place-items: center; cursor: pointer; }
.thumb .del svg { width: 14px; height: 14px; }
.drop {
  border: 2px dashed var(--line-2); border-radius: 16px; padding: 18px; text-align: center; color: var(--mute); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 550;
}
.drop svg { width: 24px; height: 24px; }
.drop.over { border-color: var(--ink); color: var(--ink); background: var(--sunk); }
.progress { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* capture (receipt photo flow) */
.capture { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.capture .photo {
  position: relative; border-radius: 22px; overflow: hidden; background: var(--ink); color: var(--on-ink);
  min-height: 210px; display: grid; place-items: center; cursor: pointer;
}
.capture .photo img { width: 100%; max-height: 360px; object-fit: contain; background: #000; }
.capture .photo .cta { display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 650; padding: 30px; text-align: center; }
.capture .photo .cta .lens { width: 74px; height: 74px; border-radius: 50%; border: 3px solid currentColor; display: grid; place-items: center; }
.capture .photo .cta .lens svg { width: 30px; height: 30px; }
.capture .photo .retake { position: absolute; right: 12px; bottom: 12px; }
.amount-input { font-size: 34px !important; height: 66px !important; text-align: right; font-family: var(--num) !important; font-weight: 650 !important; }

/* reports */
.report-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.report-cols > .panel + .panel { margin-top: 0; }
@media (max-width: 960px) { .report-cols { grid-template-columns: 1fr; } }
.rep { width: 100%; border-collapse: collapse; font-size: 14px; }
.rep td { padding: 7px 0; vertical-align: baseline; }
.rep td.num { text-align: right; font-family: var(--num); white-space: nowrap; padding-left: 12px; }
.rep tr.sec td { font-weight: 700; font-size: 15px; padding-top: 16px; }
.rep tr.grp td { font-weight: 650; padding-top: 10px; color: var(--ink-2); }
.rep tr.acc td:first-child { padding-left: 14px; color: var(--ink-2); }
.rep tr.acc td .no { color: var(--faint); font-family: var(--num); margin-right: 8px; font-size: 12.5px; }
.rep tr.sub td { font-weight: 650; border-top: 1px solid var(--line); }
.rep tr.total td { font-weight: 750; font-size: 16px; border-top: 2px solid var(--ink); padding-top: 10px; }
.rep tr.acc:hover td { background: var(--sunk); cursor: pointer; }
.rep td.neg { color: var(--alert); }
.afc { width: 100%; border-collapse: collapse; font-size: 14px; }
.afc td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.afc td.code { width: 54px; font-family: var(--num); font-weight: 700; color: var(--ink); }
.afc td.num { text-align: right; font-family: var(--num); white-space: nowrap; font-weight: 600; }
.afc tr.key td { background: var(--sunk); font-weight: 700; }
.afc tr.zero td { color: var(--faint); }
.afc tr.zero td.code { color: var(--faint); }
.afc td .sub { display: block; margin-top: 2px; font-weight: 500; }
.quarters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .quarters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.quarter { text-align: left; border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: var(--paper); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.quarter.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.quarter .q { font-weight: 700; font-size: 16px; }
.quarter .a { font-family: var(--num); font-weight: 650; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.login-card .logo-img { width: 150px; margin-bottom: 18px; }
.login-card h1 { font-size: 30px; line-height: 1.15; }
.login-card .lead { color: var(--mute); }
.code-input { font-size: 30px !important; letter-spacing: .4em; text-align: center; height: 64px !important; font-family: var(--num) !important; font-weight: 650 !important; }

/* installer */
.install-body { background: var(--bg); }
.install { max-width: 760px; margin: 0 auto; padding: 48px 20px 80px; display: flex; flex-direction: column; gap: 18px; }
.install-logo { width: 150px; margin-bottom: 10px; }
.install h1 { font-size: 32px; line-height: 1.15; }
.install h2 { font-size: 17px; margin-top: 10px; }
.install .lead { color: var(--mute); font-size: 16px; }
.install .panel { display: flex; flex-direction: column; gap: 12px; }
.install .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.install .span2 { grid-column: span 2; }
@media (max-width: 640px) { .install .grid2 { grid-template-columns: 1fr; } .install .span2 { grid-column: span 1; } }
.install .checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.install .checks li { display: flex; align-items: center; gap: 10px; }
.install .checks small { color: var(--mute); margin-left: auto; }
.install .checks .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.install .checks .ko .dot { background: var(--alert); }
.install-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.form-msg { font-weight: 600; }
.form-msg.ok { color: var(--ok); }
.form-msg.ko { color: var(--alert); }

/* print */
@media print {
  .side, .topbar .actions, .tabbar, .toolbar, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; }
  .topbar { position: static; padding: 0 0 12px; background: none; }
}

/* bank statement check */
.check-form { display: grid; gap: 8px; }
.check-form .row { display: flex; gap: 8px; }
.check-form .row .input { flex: 1; min-width: 0; }
