/* Daftar look and feel: a left sidebar menu (expanded with labels, or collapsed to icons), control panel, list/form views.
   Colours: teal and navy, matching the daftarme.com website. Every app colour is a token below (light), redefined in the two dark
   blocks; swapping the palette means editing only these three blocks. Printed documents use their own --doc-* colours (Document Layout).
   Component rules below read the roles in tokens.css (--color-*, --space-*, --radius-*, --text-*, --z-*), so dark mode follows.
   Shared shell pieces (side menu, every form control, searchable dropdown, filter bar, list-table modes, toast and dialog
   layers, empty state) live in shell.css, which loads last: do not repeat them here.

   Sections: 1 palette, 2 base, 3 layout/shell (navbar, sidebar), 4 control panel and toolbars, 5 buttons, 6 forms,
   7 tables, 8 cards and dashboards, 9 badges, alerts and status, 10 dialogs, menus and toasts, 11 feature screens,
   12 printed documents, 13 print, 14 responsive. */

/* ======================================================================
   1. Palette (the source: light, then dark by OS preference, then dark by choice)
   ====================================================================== */
:root {
  --bg: #f3f8f7;
  --panel: #ffffff;
  --panel-2: #eef5f3;
  --text: #0f172a;
  --muted: #5b6676;
  --border: #dfe8e6;
  --border-strong: #c7d5d2;
  --primary: #0f766e;
  --primary-2: #115e59;
  --primary-soft: #e3f6f1;
  --primary-text: #0f766e;
  --accent: #0f172a;
  --action: #0f766e;
  --action-2: #115e59;
  --action-soft: #e3f6f1;
  --secondary: #e9efee;
  --secondary-2: #d5dfdd;
  --navbar: #ffffff;
  --navbar-text: #0f172a;
  --navbar-hover: rgba(15, 118, 110, .08);
  --sidebar: #ffffff;
  --sidebar-text: #334155;
  --logo-bg: #0f766e;
  --logo-leaf: #ffffff;
  --logo-vein: #0f766e;
  --danger: #d44c59;
  --danger-soft: #fbe7e9;
  --warning: #b7791f;
  --warning-soft: #fdf3e1;
  --info: #2b6cb0;
  --info-soft: #e6f0fa;
  --success: #16a34a;
  --success-soft: #d7f3e1;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
  --radius: 6px;
  --navbar-height: 52px;
  /* Printed paper is always white with dark ink, in light and dark mode (not themed on purpose). */
  --doc-paper: #ffffff;
  --doc-ink: #222222;
  --doc-ink-2: #555555;
  --doc-ink-3: #777777;
  --doc-ink-4: #999999;
  --doc-rule: #e3e3e3;
  --doc-rule-2: #d6d6d6;
  --doc-rule-3: #dddddd;
  --doc-rule-4: #bbbbbb;
  --doc-fill: #f4f4f4;
  --doc-shadow: 0 2px 14px rgba(0, 0, 0, .16);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  color: var(--text);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1413; --panel: #111d1c; --panel-2: #172826; --text: #e3ecea; --muted: #94a8a3; --border: #213431;
    --border-strong: #2e4743; --primary: #0f8a7f; --primary-2: #13a193; --primary-soft: #123430; --primary-text: #5eead4;
    --accent: #0f8a7f; --action: #2dd4bf; --action-2: #5eead4; --action-soft: #123430; --secondary: #213431;
    --secondary-2: #2e4743; --navbar: #111d1c; --navbar-text: #e3ecea; --navbar-hover: rgba(255, 255, 255, .07);
    --sidebar: #0e1918; --sidebar-text: #b9cac6;
    --logo-bg: #0f8a7f; --logo-leaf: #ffffff; --logo-vein: #0f8a7f;
    --danger: #ef6b6b; --danger-soft: #42262b; --warning: #e0a744; --warning-soft: #3a2f1a;
    --info: #6aa8e8; --info-soft: #1d2c3d; --success: #3ec46d; --success-soft: #1c3a27; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1413; --panel: #111d1c; --panel-2: #172826; --text: #e3ecea; --muted: #94a8a3; --border: #213431;
  --border-strong: #2e4743; --primary: #0f8a7f; --primary-2: #13a193; --primary-soft: #123430; --primary-text: #5eead4;
  --accent: #0f8a7f; --action: #2dd4bf; --action-2: #5eead4; --action-soft: #123430; --secondary: #213431;
  --secondary-2: #2e4743; --navbar: #111d1c; --navbar-text: #e3ecea; --navbar-hover: rgba(255, 255, 255, .07);
  --sidebar: #0e1918; --sidebar-text: #b9cac6;
  --logo-bg: #0f8a7f; --logo-leaf: #ffffff; --logo-vein: #0f8a7f;
  --danger: #ef6b6b; --danger-soft: #42262b; --warning: #e0a744; --warning-soft: #3a2f1a;
  --info: #6aa8e8; --info-soft: #1d2c3d; --success: #3ec46d; --success-soft: #1c3a27; color-scheme: dark;
}

/* ======================================================================
   2. Base
   ====================================================================== */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--color-bg); }
body { color: var(--color-text); }
a { color: var(--action); text-decoration: none; }
a:hover { color: var(--action-2); text-decoration: none; }
img, video { max-width: 100%; }
h1, h2, h3 { margin: 0 0 10px; font-weight: var(--weight-medium); }
h2 { font-size: var(--text-xl); font-weight: var(--weight-semibold); }
h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.spacer { flex: 1; }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-xs); }
.right { text-align: end; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--color-danger-strong); }
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ======================================================================
   3. Layout and shell: app frame, top bar, side menu
   ====================================================================== */
#app { display: flex; min-height: 100vh; min-height: 100dvh; }
#shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#view { padding: var(--space-4); min-width: 0; }

/* top bar: menu button, company switcher and user menu.
   Layering: navbar over the control panel, both under the side menu (no token exists for these two yet). */
#navbar { display: flex; align-items: center; gap: var(--space-1); height: var(--navbar-height); padding: 0 var(--space-3);
  background: var(--navbar); color: var(--navbar-text); border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: var(--z-navbar); }
#navbar > * { flex-shrink: 0; }
#navbar > .spacer { flex-shrink: 1; min-width: 0; }
#company-name { color: var(--navbar-text); margin-inline-end: 10px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menu-toggle { display: inline-grid; place-items: center; width: var(--control-height-md); height: var(--control-height-md); min-height: 0; padding: 0;
  border: none; background: none; border-radius: var(--radius-md); color: var(--navbar-text); }
#menu-toggle:hover { background: var(--navbar-hover); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--color-text); font-size: var(--text-lg); white-space: nowrap; }
.brand:hover { color: var(--color-text); }
.brand b { font-weight: 700; }
.brand .logo { width: 26px; height: 26px; flex-shrink: 0; display: block; }
.brand .logo .bg { fill: var(--logo-bg); }
.brand .logo .leaf { fill: var(--logo-leaf); }
.brand .logo .vein { stroke: var(--logo-vein); }
.brand .brand-ar { font-weight: var(--weight-semibold); color: var(--color-primary-text); margin-inline-start: 6px; }

/* ======================================================================
   4. Control panel and toolbars
   ====================================================================== */
#control-panel { background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: var(--space-2) var(--space-4);
  position: sticky; top: var(--navbar-height); z-index: var(--z-control-panel); }
.cp-row { display: flex; align-items: center; gap: var(--space-3); min-height: 34px; }
#crumbs { display: flex; flex-direction: column; justify-content: center; }
#crumbs .parents { font-size: var(--text-xs); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#crumbs .parents a { color: var(--action); }
#crumbs .parents .sep { color: var(--color-text-muted); padding: 0 var(--space-1); }
#crumbs .current { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the header search box itself is styled in shell.css */
.cp-search { display: flex; align-items: center; }
#cp-toolbar:empty { display: none; }
#cp-toolbar { margin-top: var(--space-2); }
#cp-toolbar > .toolbar { margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: 14px; min-width: 0; }
.toolbar .spacer { flex: 1; }
.toolbar :is(input:not([type=checkbox]):not([type=radio]), select) { height: var(--control-height-md); }

/* ======================================================================
   5. Buttons: default (secondary), primary, danger, link; one height; focus ring from shell.css
   ====================================================================== */
button, .btn { font: inherit; font-weight: var(--weight-medium); display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--control-height-md); padding: 0 var(--space-3); line-height: 20px; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--secondary); border-radius: var(--radius-md); background: var(--secondary); color: var(--color-text); text-decoration: none;
  touch-action: manipulation;
  transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease); }
button:hover, .btn:hover { background: var(--secondary-2); border-color: var(--secondary-2); color: var(--color-text); text-decoration: none; }
/* shell.css squares the corners on focus (radius-sm); keep the button's own shape */
button:focus-visible, .btn:focus-visible { border-radius: var(--radius-md); }

button.primary, .btn.primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-on-primary); }
button.primary:hover, .btn.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: var(--color-text-on-primary); }

button.danger, .btn.danger { color: var(--color-danger-strong); }
button.danger:hover, .btn.danger:hover { background: var(--color-danger-subtle); border-color: var(--color-danger-subtle); color: var(--color-danger-strong); }
/* in a dialog the danger button is the main (destructive) action, so it is solid */
.modal footer button.danger { background: var(--color-danger); border-color: var(--color-danger); color: var(--color-text-on-primary); }
.modal footer button.danger:hover { background: var(--color-danger-strong); border-color: var(--color-danger-strong); color: var(--color-text-on-primary); }

button.link, .btn.link { min-height: 0; border: none; background: none; color: var(--action); padding: 2px var(--space-1); font-weight: 400; }
button.link:hover, .btn.link:hover { color: var(--action-2); background: none; text-decoration: underline; }

.icon-btn { border: none; background: none; font-size: var(--text-xl); padding: var(--space-1) var(--space-2); min-width: var(--control-height-md); }
.icon-btn:hover { background: var(--color-surface-hover); }

/* disabled: faded, no hover change (each variant keeps its own colours) */
button:disabled, .btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
button:disabled:hover, .btn:disabled:hover { background: var(--secondary); border-color: var(--secondary); color: var(--color-text); }
button.primary:disabled:hover, .btn.primary:disabled:hover { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-on-primary); }
button.danger:disabled:hover { background: var(--secondary); border-color: var(--secondary); color: var(--color-danger-strong); }
button.link:disabled:hover, .icon-btn:disabled:hover { background: none; text-decoration: none; }
button[aria-busy="true"] { cursor: progress; }

/* compact buttons inside table cells and the toast close button */
td :is(button, .btn):not(.analytic-btn) { min-height: var(--control-height-sm); }
.toast-close, .chip button { min-height: 0; }

/* ======================================================================
   6. Forms: every control and the field() layout live in shell.css (EMI fields); here only the document sheet
   ====================================================================== */
input, select, textarea { font: inherit; color: var(--color-text); min-width: 0; }
.card.pad:has(.doc-title) { padding: var(--space-6) var(--space-8); max-width: 1400px; }
.doc-title { font-size: var(--text-2xl); font-weight: var(--weight-semibold); margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
/* document head: kind + number, then ONE status row (steps, payment, printed, secured) on its own line (H9, M20) */
.doc-head { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-start; margin-bottom: var(--space-5); }
.doc-head .doc-kind { color: var(--color-text-muted); font-weight: var(--weight-medium); font-size: var(--text-sm); }
.doc-status { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.doc-status .statusbar { margin-inline-start: 0; }
.form-section { font-size: var(--text-sm); font-weight: 700; letter-spacing: .02em; padding-bottom: var(--space-1); margin: 6px 0 var(--space-2);
  border-bottom: 1px solid var(--color-border); }
.radio-row { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: var(--space-1); }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.radio-row input { accent-color: var(--action); height: auto; }

/* chips (many2many) */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.chip { background: var(--color-primary-subtle); color: var(--color-text); border-radius: var(--radius-pill); padding: 1px var(--space-1) 1px var(--space-2);
  font-size: var(--text-xs); display: inline-flex; align-items: center; gap: 2px; }
.chip button { border: none; background: none; padding: 0 var(--space-1); color: inherit; font-size: var(--text-sm); }
.chip button:hover { background: none; color: var(--color-danger-strong); }

/* ======================================================================
   7. Tables: list tables and editable line tables
   ====================================================================== */
.table-wrap { overflow: auto; max-width: 100%; max-height: var(--table-max-height, none); overscroll-behavior-x: contain; }
table.list { width: 100%; border-collapse: collapse; }
/* the header sticks to the top of its scroll box (.table-wrap, or a pane that scrolls); z-index 1 only lifts it over its own rows */
table.list th { text-align: start; font-size: var(--text-sm); color: var(--color-text); font-weight: var(--weight-semibold); padding: 10px var(--space-3);
  border-bottom: 1px solid var(--color-border-strong); background: var(--color-surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
table.list th.num, table.list td.num { text-align: end; font-variant-numeric: tabular-nums; }
table.list td { padding: 10px var(--space-3); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tbody tr:hover td { background: var(--color-surface-hover); }
table.list tr.total td { font-weight: 700; background: var(--color-surface-2); }
table.list tr.section td { font-weight: var(--weight-semibold); background: var(--color-surface-2); }
table.list tr.sub td { color: var(--color-text-muted); }
tr.group-row td { font-weight: var(--weight-semibold); }
/* Trial balance as a tree: header rows fold and open their accounts. */
table.list tr.tb-group td { font-weight: var(--weight-semibold); background: var(--color-surface-2); cursor: pointer; }
table.list tr.tb-group.tb-l0 td { font-weight: 700; }
table.list tr.tb-hidden { display: none !important; }
.tb-caret { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; color: inherit; border-radius: 4px; }
.tb-caret:focus-visible { outline: 2px solid var(--color-focus, currentColor); outline-offset: 2px; }
.tb-caret-icon { display: inline-block; width: 1em; text-align: center; color: var(--color-text-muted); transition: transform .15s; }
tr.tb-folded .tb-caret-icon { transform: rotate(-90deg); }
[dir="rtl"] tr.tb-folded .tb-caret-icon { transform: rotate(90deg); }
.tb-tree-bar { display: flex; flex-wrap: wrap; gap: var(--space-2, 8px); align-items: center; margin-block: var(--space-2, 8px) var(--space-3, 12px); }
.tb-tree-bar select { width: auto; }
table.list tfoot td { font-weight: 700; border-top: 1px solid var(--color-border-strong); border-bottom: none; font-variant-numeric: tabular-nums; }
table.list td.indent-1 { padding-inline-start: 26px; }
table.list td.indent-2 { padding-inline-start: 42px; }
/* selected rows (chart of accounts, bank statement lines) */
table.list tbody tr.selected td, table.list tbody tr.selected:hover td, .st-row.selected td { background: var(--color-primary-subtle) !important; }
/* only a checkbox column gets squeezed; label columns keep their natural width */
table.list th:first-child:empty:has(+ th), table.list td:first-child:has(> input[type=checkbox]:only-child) { width: 36px; }
table.lines th { padding: var(--space-2) 6px; }
table.lines td { padding: var(--space-1) 6px; }
/* Invoice and entry lines (move-form.js). Wide screens: one row per line, every column wide enough for its value (H5). */
table.lines .c-quantity, table.lines .c-discount { width: 76px; }
table.lines .c-price_unit, table.lines :is(.c-debit, .c-credit) { width: 120px; }
table.lines .c-subtotal { width: 120px; white-space: nowrap; }
table.lines .c-rm { width: 36px; text-align: center; }
table.lines :is(.c-product_id, .c-account_id, .c-partner_id) { min-width: 150px; }
table.lines .c-name { min-width: 160px; }
table.lines .c-tax_ids { min-width: 130px; }
table.lines .c-analytic_distribution { min-width: 120px; }
table.lines tr:hover > td { background: none; }
/* Narrow screens (641 to 1024px): taxes and cost center move to a second row under the line (H5). */
@media (max-width: 1024px) and (min-width: 641px) {
  table.invoice-lines, table.invoice-lines > thead, table.invoice-lines > tbody { display: block; }
  table.invoice-lines tr { display: grid; align-items: center; column-gap: var(--space-1); padding-block: var(--space-1); border-bottom: 1px solid var(--color-border);
    grid-template-columns: minmax(100px, 1.2fr) minmax(100px, 1.4fr) minmax(100px, 1.2fr) 64px 92px 60px 100px 32px; }
  table.invoice-lines .ss { min-width: 0; }
  table.invoice-lines thead tr { background: var(--color-surface-2); border-bottom-color: var(--color-border-strong); }
  table.invoice-lines thead th { background: transparent; }
  table.invoice-lines tr > :is(th, td)[class] { min-width: 0; width: auto; padding: 2px var(--space-1); border: 0; }
  table.invoice-lines tr > .c-product_id { grid-area: 1 / 1; } table.invoice-lines tr > .c-name { grid-area: 1 / 2; }
  table.invoice-lines tr > .c-account_id { grid-area: 1 / 3; } table.invoice-lines tr > .c-quantity { grid-area: 1 / 4; }
  table.invoice-lines tr > .c-price_unit { grid-area: 1 / 5; } table.invoice-lines tr > .c-discount { grid-area: 1 / 6; }
  table.invoice-lines tr > .c-subtotal { grid-area: 1 / 7; } table.invoice-lines tr > .c-rm { grid-area: 1 / 8; }
  table.invoice-lines tr > .c-note { grid-area: 1 / 1 / 2 / 8; }
  table.invoice-lines tbody tr > .c-tax_ids { grid-area: 2 / 1 / 3 / 4; }
  table.invoice-lines tbody tr > .c-analytic_distribution { grid-area: 2 / 4 / 3 / 9; }
  table.invoice-lines:not(.with-analytic) tbody tr > .c-tax_ids { grid-area: 2 / 1 / 3 / 9; }
  table.invoice-lines thead :is(.c-tax_ids, .c-analytic_distribution) { display: none; }
  table.invoice-lines tbody :is(.c-tax_ids, .c-analytic_distribution) { display: flex; align-items: center; gap: var(--space-2); }
  table.invoice-lines tbody :is(.c-tax_ids, .c-analytic_distribution)::before { content: attr(data-label); flex: none; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); }
}
/* Phones (640px and below): each line is a small card with labelled fields, in the form and when read-only (H6). */
@media (max-width: 640px) {
  table.line-cards, table.line-cards > tbody, table.line-cards > tfoot { display: block; }
  table.line-cards > thead { display: none; }
  table.line-cards > tbody > tr { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2) var(--space-3);
    padding: var(--space-3); margin-bottom: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
  table.line-cards > tbody > tr > td { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; width: auto; padding: 0; border: 0; }
  table.line-cards > tbody > tr > td[data-label]::before { content: attr(data-label); color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); }
  table.line-cards > tbody > tr > td:is(.c-quantity, .c-price_unit, .c-discount, .c-subtotal, .c-debit, .c-credit) { grid-column: span 1; }
  table.line-cards > tbody > tr > td:is([class*="c-"]) { width: auto; min-width: 0; }
  /* discount and subtotal side by side; taxes and cost center after them */
  table.line-cards > tbody > tr > td.c-subtotal { order: 1; }
  table.line-cards > tbody > tr > td:is(.c-tax_ids, .c-analytic_distribution) { order: 2; }
  table.line-cards > tbody > tr > td.c-subtotal { align-items: flex-end; justify-content: flex-end; font-weight: var(--weight-semibold); font-size: var(--text-md); }
  table.line-cards > tbody > tr > td.c-rm { position: absolute; top: var(--space-1); inset-inline-end: var(--space-1); width: auto; }
  table.line-cards > tbody > tr > td.c-rm:empty { display: none; }
  table.line-cards > tbody > tr > td:first-child { padding-inline-end: var(--space-8); }
  table.line-cards > tbody > tr :is(input:not([type=checkbox], [type=radio]), select, .ss-input):not(:disabled):not([readonly]) {
    height: var(--field-height); border-color: var(--field-border); background-color: var(--field-bg); font-size: var(--text-lg); }
  table.line-cards > tfoot > tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-1); }
  table.line-cards > tfoot > tr > td { padding: 0; border: 0; }
  table.line-cards > tfoot > tr > td:empty { display: none; }
  table.line-cards .ss { min-width: 0; }
}
/* list pages: always a card holding the table (M4); the count line on top of it */
.card > .list-count { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.empty { padding: 36px; text-align: center; color: var(--color-text-muted); }

/* ======================================================================
   8. Cards, grids and dashboards
   ====================================================================== */
.card { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow); min-width: 0; }
.card.pad { padding: var(--space-4) var(--space-5); }
.card + .card { margin-top: var(--space-4); }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: var(--space-4); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* notebook tabs: the bottom line is an inset shadow so the row can scroll on phones and the open tab still covers it */
.tabs { display: flex; gap: 0; margin: 22px 0 0; box-shadow: inset 0 -1px 0 var(--color-border-strong); overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: none; border: 1px solid transparent; border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0; background: var(--color-surface-2);
  padding: var(--space-2) var(--space-4); color: var(--color-text); font-weight: 400; margin-inline-end: 2px; }
.tabs button:hover { background: var(--secondary); border-color: transparent; }
.tabs button:focus-visible { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.tabs button.on { background: var(--color-surface); border-color: var(--color-border-strong); border-top: 2px solid var(--color-primary); color: var(--color-primary-text);
  font-weight: var(--weight-medium); }

/* totals block */
.totals { margin-inline-start: auto; width: min(340px, 100%); margin-top: var(--space-3); font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: var(--space-4); padding: 3px 0; }
.totals div > span:first-child { flex: 1; text-align: end; }
.totals .grand { font-size: var(--text-lg); font-weight: 700; border-top: 1px solid var(--color-border); padding-top: var(--space-2); margin-top: var(--space-1); }

/* dashboard (journal kanban) */
.kanban { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: var(--space-4); }
.journal-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow);
  padding: var(--space-4) var(--space-5) var(--space-5); min-height: 128px; display: flex; flex-direction: column; gap: 14px;
  transition: border-color var(--motion-fast) var(--ease); }
.journal-card:hover { border-color: var(--color-border-strong); }
.journal-card .title { color: var(--action); font-size: var(--text-lg); font-weight: var(--weight-medium); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.journal-card .title a { color: inherit; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.journal-card .title a:hover { color: var(--action-2); text-decoration: underline; }
.journal-card .title .badge { flex: none; font-size: var(--text-2xs); color: var(--color-text-muted); }
.journal-card .body { flex: 1; display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.journal-card .actions { display: flex; gap: 6px; flex-wrap: wrap; flex: none; }
.journal-card .stats { margin-inline-start: auto; display: grid; grid-template-columns: auto minmax(90px, auto); gap: 6px 18px; text-align: end;
  font-variant-numeric: tabular-nums; line-height: 20px; white-space: nowrap; }
.journal-card .stats .num { font-weight: var(--weight-medium); }
.journal-card .stats .lbl, .journal-card .stats .lbl a { color: var(--action); }
.journal-card .stats .lbl.neg, .journal-card .stats .lbl.neg a { color: var(--color-danger-strong); }
.recon-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); padding: 14px 18px;
  border-inline-start: 3px solid var(--color-primary); }
.recon-banner .recon-title { font-weight: var(--weight-semibold); font-size: var(--text-md); display: flex; align-items: center; gap: var(--space-2); margin-bottom: 2px; }
.recon-banner button { flex: none; }
/* A record waiting for a manager's approval, or rejected (features/approvals). */
.appr-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); padding: 12px 16px;
  border-radius: var(--radius-md); border: 1px solid var(--color-warning); background: var(--color-warning-subtle); color: var(--color-warning-strong); }
.appr-banner.rejected { border-color: var(--color-danger); background: var(--color-danger-subtle); color: var(--color-danger-strong); }
.appr-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.appr-banner .appr-actions { flex: none; }
.appr-count { margin-inline-start: var(--space-2); }
.kpi { padding: 14px var(--space-4); }
.kpi .label { color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.kpi .value { font-size: var(--text-2xl); font-weight: var(--weight-medium); margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.section-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin: var(--space-6) 0 10px; }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding: var(--space-2) var(--space-1) 0; border-bottom: 1px solid var(--color-border); overflow-x: auto; }
.bars .bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; }
.bars .bar { width: 18px; min-height: 1px; }
.bars .bar.rev { background: var(--color-primary); }
.bars .bar.exp { background: var(--secondary-2); }
.bars small { color: var(--color-text-muted); font-size: var(--text-2xs); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--text-xs); color: var(--color-text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: var(--space-1); vertical-align: -1px; }

/* ======================================================================
   9. Badges, alerts and the status bar
   ====================================================================== */
/* status pill: dot + text, strong text on the tone's soft background (contrast-safe in both themes) */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px var(--space-2); border-radius: var(--radius-pill); font-size: var(--text-xs);
  font-weight: var(--weight-medium); line-height: 18px; white-space: nowrap; background: var(--color-surface-2); color: var(--color-text); border: none; }
.badge:is(.green, .blue, .orange, .red, .teal)::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.green { background: var(--color-success-subtle); color: var(--color-success-strong); }
.badge.blue { background: var(--color-info-subtle); color: var(--color-info-strong); }
.badge.orange { background: var(--color-warning-subtle); color: var(--color-warning-strong); }
.badge.red { background: var(--color-danger-subtle); color: var(--color-danger-strong); }
.badge.teal { background: var(--color-primary-subtle); color: var(--color-primary-text); }
.ribbon { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-semibold); }

.alert { padding: 10px 14px; border-radius: var(--radius-md); margin-bottom: var(--space-3); }
.alert.warn { background: var(--color-warning-subtle); color: var(--color-warning-strong); }
.alert.info { background: var(--color-info-subtle); color: var(--color-info-strong); }
.alert.ok { background: var(--color-success-subtle); color: var(--color-success-strong); }
.alert.err { background: var(--color-danger-subtle); color: var(--color-danger-strong); }
#sub-banner { margin: 0; border-radius: 0; text-align: center; }
/* an ended trial sits inside the sticky control panel, so it stays in sight while the page scrolls */
#sub-banner.sticky { border-radius: var(--radius-md); margin-bottom: var(--space-2); font-weight: var(--weight-semibold); }

/* status bar with arrow-shaped stages */
.statusbar { display: flex; gap: 0; margin-inline-start: auto; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.statusbar span { flex: none; position: relative; padding-block: 4px; padding-inline: 22px 14px; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted);
  background: var(--secondary); clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%); margin-inline-start: -6px; line-height: 20px; }
.statusbar span:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); padding-inline-start: 14px;
  border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md); margin-inline-start: 0; }
.statusbar span:last-child { padding-inline-end: var(--space-4); }
.statusbar span.on { background: var(--color-primary-subtle); color: var(--color-primary-text); }

/* ======================================================================
   10. Dialogs, menus and toasts (layers, backdrop colour and dialog shadow/radius come from shell.css)
   ====================================================================== */
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: start center; padding: 56px var(--space-4) var(--space-4); }
.modal { background: var(--color-surface); color: var(--color-text); width: min(560px, 100%); max-height: 88vh; max-height: 88dvh; overflow: auto; }
.modal.wide { width: min(900px, 100%); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--color-border); font-weight: var(--weight-medium); font-size: var(--text-lg);
  display: flex; align-items: center; gap: var(--space-2); }
.modal header button { margin-inline-start: auto; }
.modal .body { padding: var(--space-4) 18px; }
.modal footer { padding: var(--space-3) 18px; border-top: 1px solid var(--color-border); display: flex; flex-wrap: wrap; gap: var(--space-2);
  justify-content: flex-start; flex-direction: row-reverse; }

/* user menu and company switcher (auth.js, companies.js) */
#user-menu { position: relative; }
.user-btn { border: none; background: none; color: var(--navbar-text); padding: 2px var(--space-1); font-weight: 400; }
.user-btn:hover { background: var(--navbar-hover); color: var(--navbar-text); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--color-text-on-primary); display: inline-grid; place-items: center;
  font-weight: var(--weight-semibold); font-size: var(--text-sm); }
#user-menu .menu, #company-name .menu { position: absolute; inset-inline-end: 0; top: 38px; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-dropdown); min-width: 200px;
  max-width: calc(100vw - var(--space-6)); padding: var(--space-1) 0; z-index: var(--z-dropdown); }
#user-menu .menu button, #company-name .menu button { display: flex; width: 100%; text-align: start; justify-content: flex-start; border: none; border-radius: 0;
  background: none; padding: 7px var(--space-4); font-weight: 400; color: var(--color-text); }
#user-menu .menu button:hover, #company-name .menu button:hover { background: var(--color-surface-2); }
#company-name.company-switcher { position: relative; overflow: visible; max-width: none; }
#company-name.company-switcher > .user-btn { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: var(--control-height-md); }
#company-name .menu { min-width: 260px; }
#company-name .menu button { justify-content: space-between; gap: 10px; }
#company-name .menu button.current { font-weight: var(--weight-semibold); }
#company-name .menu hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-1) 0; }

/* toasts (layer and close button from shell.css) */
#toasts { position: fixed; inset-inline-end: 18px; top: calc(var(--navbar-height) + var(--space-2)); display: flex; flex-direction: column; gap: var(--space-2); }
.toast { background: var(--color-surface); color: var(--color-text); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-dropdown);
  max-width: min(420px, calc(100vw - var(--space-8))); border-inline-start: 4px solid var(--color-success); }
.toast.error { border-inline-start-color: var(--color-danger); }

/* ======================================================================
   11. Feature screens: partners, bank, reports, sign-in, chart of accounts, analytic, layout editor
   ====================================================================== */
/* partner (customer / vendor) list and form */
.partner-avatar { display: inline-grid; place-items: center; border-radius: var(--radius-sm); color: var(--color-text-on-primary); font-weight: var(--weight-semibold); flex-shrink: 0; }
.partner-name { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.partner-sheet { padding: 0 var(--space-8) var(--space-6) !important; max-width: 1400px; }
.smart-buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; margin: 0 calc(-1 * var(--space-8)) var(--space-4); border-bottom: 1px solid var(--color-border); min-height: 1px; }
.smart-buttons .smart { background: none; border: none; border-inline-start: 1px solid var(--color-border); border-radius: 0; padding: var(--space-2) var(--space-4); min-width: 140px;
  font-weight: 400; color: var(--color-text); gap: 10px; justify-content: flex-start; }
.smart-buttons .smart:hover { background: var(--color-surface-2); }
.smart-buttons .smart b { font-size: var(--text-xl); color: var(--color-text-muted); font-weight: 400; }
.smart-buttons .smart span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.smart-buttons .smart small { color: var(--color-primary-text); font-weight: var(--weight-semibold); }
.partner-head { display: flex; gap: var(--space-5); align-items: flex-start; padding-top: var(--space-2); }
.partner-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.partner-main input:not([type=radio]) { width: 100%; max-width: 560px; }
.partner-main input.partner-title { font-size: var(--text-2xl); font-weight: var(--weight-semibold); height: 52px; max-width: none; }
.field.address > div { display: flex; flex-direction: column; gap: var(--space-2); }
.addr-row { display: grid; grid-template-columns: 2fr 1.4fr 1fr; gap: var(--space-2); }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--space-3); }
.contact-card { display: flex; gap: var(--space-3); align-items: flex-start; justify-content: flex-start; padding: var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); background: var(--color-surface); cursor: pointer; min-height: 70px; text-align: start; font-weight: 400; white-space: normal; }
.contact-card:hover { border-color: var(--action); background: var(--color-surface); }
.contact-card.add { justify-content: center; align-items: center; color: var(--action); font-weight: var(--weight-medium); background: var(--color-surface); border-style: solid; }
.contact-card.sub { opacity: .6; }

/* bank reconciliation */
.bank-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--space-4); align-items: start; }
.bank-layout .list-pane { max-height: calc(100vh - 200px); overflow: auto; }
/* the pane is the scroll box here, so the table header sticks to the pane */
.bank-layout .list-pane .table-wrap { overflow: visible; }
.bank-layout td:first-child { white-space: nowrap; }

/* report: a centred sheet with grey section rows (headers stay transparent, like the printed report) */
.card.report { max-width: 1100px; margin: 0 auto; padding: var(--space-6) 28px; }
.report h2 { margin-bottom: 2px; }
.report .sub { color: var(--color-text-muted); margin-bottom: 18px; }
.report table.list th { background: var(--color-surface); font-size: var(--text-sm); }
.report table.list td { padding: 6px 10px; }
.report table.list td a { color: var(--color-text); }
.report table.list td a:hover { color: var(--action); }
.report table.list tr.section td, .report table.list tr.total td { background: var(--secondary); }

/* sign-in */
#auth-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--space-4);
  background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-primary-subtle) 100%); }
.auth-card { width: min(400px, 100%); padding: 28px; }
.auth-card .brand { color: var(--color-text); padding: 0 0 18px; justify-content: center; border-bottom: 1px solid var(--color-border); margin-bottom: 18px; }
.auth-card .brand .logo { width: 40px; height: 40px; }
.auth-card .brand small { color: var(--color-text-muted); display: block; font-size: var(--text-xs); }
.auth-card input { width: 100%; }
.auth-label { display: block; color: var(--color-text); font-size: var(--text-md); margin: var(--space-3) 0 var(--space-1); }

/* chart of accounts tree */
.tree-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-2) 10px; border-bottom: 1px solid var(--color-border); }
.tree-caret { display: inline-block; width: 18px; color: var(--color-text-muted); user-select: none; }
.tree-caret:hover { color: var(--color-text); }
.jofotara-box { display: flex; gap: var(--space-3); align-items: flex-start; margin: 10px 0; padding: 10px var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); background: var(--color-surface-2); }
.jofotara-qr { width: 96px; height: 96px; image-rendering: pixelated; flex: none; }

/* analytic distribution (cost centers) on lines */
.analytic-btn { width: 100%; justify-content: flex-start; text-align: start; font-weight: 400; font-size: var(--text-xs); min-height: 0; padding: 3px 6px;
  background: none; border: 1px dashed transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--color-text); }
.analytic-btn:hover:not(:disabled) { border-color: var(--color-border-strong); background: none; }
.analytic-btn.missing { border-color: var(--color-danger); background: var(--color-danger-subtle); }
.analytic-plan { margin-bottom: 14px; }
.analytic-plan-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.analytic-plan-head .spacer { flex: 1; }

/* document layout editor (layout.js) */
.layout-page { display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.layout-preview { position: sticky; top: var(--space-3); overflow: auto; }
.layout-form textarea { width: 100%; }
.layout-logo { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* logos are drawn for white paper, so they keep a white backdrop in dark mode too */
.layout-logo img { max-height: 48px; max-width: 160px; background: var(--doc-paper); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 3px; }
.layout-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: var(--space-2); margin-bottom: 14px; }
.layout-thumb { padding: 5px; border: 2px solid var(--color-border); background: var(--color-surface); display: flex; flex-direction: column; gap: var(--space-1);
  align-items: center; font-weight: 400; min-height: 0; }
.layout-thumb:hover { background: var(--color-surface-2); border-color: var(--color-border-strong); }
.layout-thumb.on { border-color: var(--action); font-weight: var(--weight-semibold); }
.layout-thumb .mini { width: 80px; height: 106px; overflow: hidden; background: var(--doc-paper); border: 1px solid var(--doc-rule-3); }
.layout-thumb .mini > .doc-sheet { width: 794px; padding: 40px; zoom: .1; pointer-events: none; }

/* ======================================================================
   12. Printed documents: invoices and vouchers (always white paper; --doc-primary/secondary come from the chosen layout)
   ====================================================================== */
.doc-paper { background: var(--doc-paper); color: var(--doc-ink); width: 794px; min-height: 1123px; margin: 0 auto; padding: 48px 52px; box-shadow: var(--doc-shadow); }
.doc-paper.letter { width: 816px; min-height: 1056px; }
.doc-paper.preview { zoom: .72; }

.doc-sheet { --doc-primary: #714B67; --doc-secondary: #017E84; font-size: 13px; line-height: 1.45; color: var(--doc-ink); text-align: start; }
.doc-header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 14px; margin-bottom: 18px; }
.doc-logo img { max-height: 80px; max-width: 240px; object-fit: contain; display: block; }
.doc-logo b { font-size: 22px; color: var(--doc-primary); }
.doc-company { text-align: end; color: var(--doc-ink-2); font-size: 12px; }
.doc-company b { color: var(--doc-ink); font-size: 13px; }
.doc-tagline { color: var(--doc-primary); font-weight: 700; margin-bottom: 2px; }
.doc-intro { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.doc-meta { display: flex; gap: 24px; }
.doc-label { font-size: 11px; color: var(--doc-ink-3); text-transform: uppercase; letter-spacing: .03em; }
.doc-name { font-size: 24px; margin: 0 0 14px; color: var(--doc-primary); font-weight: 700; }
.doc-lines { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.doc-lines th { text-align: start; font-weight: 700; padding: 7px 8px; border-bottom: 2px solid var(--doc-primary); }
.doc-lines td { padding: 7px 8px; border-bottom: 1px solid var(--doc-rule); vertical-align: top; }
.doc-lines .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-lines tr.section td { font-weight: 700; background: var(--doc-fill); }
.doc-lines tr.note td { font-style: italic; color: var(--doc-ink-2); }
.doc-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.doc-totals { min-width: 280px; font-variant-numeric: tabular-nums; }
.doc-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 8px; }
.doc-totals .grand { font-weight: 700; font-size: 15px; border-top: 2px solid var(--doc-primary); color: var(--doc-primary); }
.doc-qr img { width: 120px; height: 120px; display: block; }
.doc-qr.empty { width: 120px; height: 120px; border: 2px dashed var(--doc-rule-4); display: grid; place-items: center; text-align: center; font-size: 11px; color: var(--doc-ink-4); padding: 6px; }
.doc-notes { margin-top: 22px; white-space: pre-wrap; }
.doc-payref { font-size: 12px; color: var(--doc-ink-2); }
.doc-footer { margin-top: 36px; padding-top: 8px; border-top: 1px solid var(--doc-rule-3); text-align: center; font-size: 11px; color: var(--doc-ink-3); white-space: pre-wrap; }
.doc-sheet[dir=rtl] .num, .doc-sheet[dir=rtl] .doc-totals span:last-child { direction: ltr; text-align: left; }

.tpl-light .doc-header { border-bottom: 1px solid var(--doc-rule); }

.tpl-boxed .doc-header { border: 2px solid var(--doc-primary); padding: 14px; border-radius: 4px; }
.tpl-boxed .doc-name { color: var(--doc-ink); }
.tpl-boxed .doc-lines th { background: var(--doc-primary); color: var(--doc-paper); border: 1px solid var(--doc-primary); }
.tpl-boxed .doc-lines td { border: 1px solid var(--doc-rule-2); }
.tpl-boxed .doc-totals { border: 1px solid var(--doc-rule-2); }
.tpl-boxed .doc-footer { border: 2px solid var(--doc-primary); border-radius: 4px; padding: 8px; }

.tpl-bold .doc-header { background: var(--doc-primary); padding: 20px 22px; border-radius: 2px; }
.tpl-bold .doc-company, .tpl-bold .doc-company b, .tpl-bold .doc-tagline, .tpl-bold .doc-logo b { color: var(--doc-paper); }
.tpl-bold .doc-logo img { background: var(--doc-paper); padding: 6px; border-radius: 4px; }
.tpl-bold .doc-name { font-size: 32px; text-transform: uppercase; letter-spacing: .02em; }
.tpl-bold .doc-lines th { border-bottom: 3px solid var(--doc-secondary); text-transform: uppercase; font-size: 11px; }
.tpl-bold .doc-totals .grand { background: var(--doc-primary); color: var(--doc-paper); border: none; padding: 8px; }

.tpl-striped .doc-header { border-bottom: 4px solid var(--doc-secondary); }
.tpl-striped .doc-name { color: var(--doc-secondary); }
.tpl-striped .doc-lines th { background: var(--doc-secondary); color: var(--doc-paper); border: none; }
.tpl-striped .doc-lines td { border-bottom: none; }
.tpl-striped .doc-lines tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--doc-secondary) 9%, white); }
.tpl-striped .doc-totals .grand { border-top-color: var(--doc-secondary); color: var(--doc-secondary); }

/* journal vouchers: the printed copy of an entry (documents.js printVouchersView) */
.voucher-page + .voucher-page { margin-top: 24px; }
.voucher .doc-name { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.voucher-copy { font-size: 12px; font-weight: 600; color: var(--doc-ink-3); border: 1px solid var(--doc-rule-4); border-radius: 3px; padding: 2px 8px; }
.voucher-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 24px; margin-bottom: 18px; }
.voucher .doc-lines tfoot td { font-weight: 700; border-top: 2px solid var(--doc-primary); border-bottom: none; padding: 8px; }
.voucher .doc-lines tfoot .num { text-align: end; white-space: nowrap; }
.voucher-signs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-top: 48px; }
.voucher-line { border-bottom: 1px solid var(--doc-ink-4); height: 36px; }
.doc-sheet[dir=rtl] .voucher .num, .doc-sheet.voucher[dir=rtl] .num { direction: ltr; text-align: left; }

/* ======================================================================
   13. Print
   ====================================================================== */
@media print {
  #sidebar, #navbar, #control-panel, .toolbar, .no-print { display: none !important; }
  html, body { background: var(--doc-paper); }
  #view { padding: 0; }
  .card { box-shadow: none; border: none; }
  .table-wrap { overflow: visible; max-height: none; }
  table.list th { position: static; background: transparent; }
  .doc-paper, .doc-paper.preview { box-shadow: none; width: auto; min-height: 0; padding: 0; margin: 0; zoom: 1; }
  .doc-sheet { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-lines tr { break-inside: avoid; }
  .voucher-page { break-after: page; }
  .voucher-page:last-child { break-after: auto; }
  .voucher-page + .voucher-page { margin-top: 0; }
}

/* ======================================================================
   14. Responsive: 1100 (narrow desktop), 900 (side menu becomes a drawer), 640 (phones)
   ====================================================================== */
@media (max-width: 1100px) and (min-width: 901px) {
  #user-menu .user-btn { font-size: 0; }
  #user-menu .user-btn .avatar { font-size: var(--text-sm); }
  #navbar #company-name.company-switcher > .user-btn { max-width: 160px; }
}

@media (max-width: 900px) {
  /* the side menu becomes a drawer: see shell.css */
  #company-name { display: none; }
  #company-name.company-switcher { display: block; }
  #company-name.company-switcher > .user-btn { max-width: 140px; }
  #view { padding: var(--space-3); }
  #control-panel { padding: var(--space-2) var(--space-3); }
  .cp-row { flex-wrap: wrap; }
  .cp-search { flex: 1 1 100%; order: 3; }
  .form-grid, .grid.cols-2, .grid.cols-3, .grid.cols-4, .bank-layout, .kanban, .layout-page { grid-template-columns: minmax(0, 1fr); }
  .card.pad:has(.doc-title) { padding: var(--space-4); }
  .layout-preview { position: static; }
  .doc-paper { zoom: .45; }
}

@media (max-width: 640px) {
  /* top bar: avatar only, shorter company name */
  #user-menu .user-btn { font-size: 0; }
  #user-menu .user-btn .avatar { font-size: var(--text-sm); }
  #company-name.company-switcher > .user-btn { max-width: 110px; }
  #crumbs .current { font-size: var(--text-lg); }

  /* toolbars: tidy rows, filters on their own full-width row, no empty spacer line */
  .toolbar { gap: var(--space-2); }
  .toolbar > .spacer { display: none; }
  .toolbar > .filters, .toolbar > .statusbar { flex: 1 1 100%; margin-inline-start: 0; }
  .filters > :is(input:not([type=checkbox]):not([type=radio]), select, .ss, .dp) { flex: 1 1 calc(100% - 64px); width: auto; min-width: 0; }
  /* a control-panel toolbar of buttons only: one row that scrolls sideways instead of a wall of buttons
     (the small padding keeps the focus ring visible inside the scroll box) */
  #cp-toolbar > .toolbar:not(:has(.filters, input, select, textarea, .statusbar)) {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
    padding: var(--space-1); margin: calc(-1 * var(--space-1)); }
  #cp-toolbar > .toolbar:not(:has(.filters, input, select, textarea, .statusbar)) > * { flex: none; }

  /* forms: one column, 16px text and 44px controls on phones come from shell.css */
  .addr-row { grid-template-columns: minmax(0, 1fr); }
  .doc-title { font-size: var(--text-2xl); }
  .doc-head, .partner-head { flex-wrap: wrap; }
  .partner-sheet { padding: 0 var(--space-4) var(--space-4) !important; }
  .smart-buttons { margin: 0 calc(-1 * var(--space-4)) var(--space-4); }
  .smart-buttons .smart { flex: 1 1 50%; min-width: 0; }
  .partner-main input.partner-title { font-size: var(--text-2xl); height: var(--control-height-lg); }
  .card.pad { padding: var(--space-4); }
  .card.report { padding: var(--space-4); }
  .auth-card { padding: var(--space-5); }

  /* dashboards */
  .recon-banner, .appr-banner { flex-direction: column; align-items: stretch; }
  .journal-card .body { flex-wrap: wrap; }
  .journal-card .stats { margin-inline-start: 0; }

  /* dialogs: full width, actions stack from the bottom */
  .modal-backdrop { padding: var(--space-4) var(--space-2); }
  .modal footer button { flex: 1 1 auto; }

  /* printed-document preview fits a 375px screen (794px x .42 = 333px) */
  .doc-paper { zoom: .42; }
  .voucher-meta { grid-template-columns: minmax(0, 1fr); }
}
