/* LaMotheo Billing & Finance Hub — "ledger" design system
   Navy ink, sage accents, warm paper. Bricolage Grotesque headings, Instrument Sans body, tabular figures. */

@font-face { font-family: "Bricolage Grotesque"; src: url(fonts/bricolage-grotesque-latin-wght-normal.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/instrument-sans-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/instrument-sans-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/instrument-sans-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/instrument-sans-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --navy: #021448; --navy-2: #0c2466; --navy-3: #1b3580;
  --sage: #A0BB83; --sage-2: #7f9c62; --sage-ink: #4f6b35; --sage-soft: #eef4e6;
  --bg: #f4f5f0; --paper: #fbfbf8; --card: #ffffff; --hover: #f7f8f3; --head: #f6f7f2;
  --ink: #131826; --ink-2: #3d4454; --muted: #6b7280; --faint: #9aa1ad;
  --line: #e3e6dd; --line-2: #d4d8cd;
  --primary: var(--navy); --primary-ink: #fff; --primary-hover: var(--navy-2);
  --focus: 0 0 0 3px rgba(160,187,131,.55);
  --ok: #23704a; --ok-bg: #e5f2ea; --warn: #8a5a00; --warn-bg: #fff3d4; --bad: #b42318; --bad-bg: #fdecea;
  --blue: #1d4ea3; --blue-bg: #e8eefb; --teal: #0d6d83; --teal-bg: #e0f1f4; --purple: #5b3cb4; --purple-bg: #efeafb; --gray: #525b6b; --gray-bg: #eceef1;
  --side: #021448; --side-ink: #c9d2e8; --side-on: rgba(160,187,131,.16);
  --r: 10px; --r-sm: 7px;
  --shadow: 0 1px 2px rgba(10,20,50,.05), 0 1px 1px rgba(10,20,50,.03);
  --shadow-lg: 0 20px 50px -12px rgba(2,20,72,.35);
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --paper: #0f1527; --card: #121a2e; --hover: #172038; --head: #151d33;
    --ink: #e8ebf2; --ink-2: #c3c9d6; --muted: #98a1b4; --faint: #6c7589;
    --line: #232d47; --line-2: #2e3a59;
    --primary: #A0BB83; --primary-ink: #0b1020; --primary-hover: #b4cc99;
    --ok: #7cd3a1; --ok-bg: rgba(60,170,110,.16); --warn: #f2c25b; --warn-bg: rgba(242,194,91,.14); --bad: #ff8a80; --bad-bg: rgba(255,120,110,.14);
    --blue: #93b4ff; --blue-bg: rgba(110,150,255,.15); --teal: #7fd3e4; --teal-bg: rgba(90,200,220,.13); --purple: #c2b0ff; --purple-bg: rgba(170,140,255,.15); --gray: #b4bcc9; --gray-bg: rgba(180,188,201,.12);
    --side: #070c1a; --side-ink: #aeb8d0; --sage-soft: rgba(160,187,131,.12); --sage-ink: #b8d29c;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --paper: #0f1527; --card: #121a2e; --hover: #172038; --head: #151d33;
  --ink: #e8ebf2; --ink-2: #c3c9d6; --muted: #98a1b4; --faint: #6c7589;
  --line: #232d47; --line-2: #2e3a59;
  --primary: #A0BB83; --primary-ink: #0b1020; --primary-hover: #b4cc99;
  --ok: #7cd3a1; --ok-bg: rgba(60,170,110,.16); --warn: #f2c25b; --warn-bg: rgba(242,194,91,.14); --bad: #ff8a80; --bad-bg: rgba(255,120,110,.14);
  --blue: #93b4ff; --blue-bg: rgba(110,150,255,.15); --teal: #7fd3e4; --teal-bg: rgba(90,200,220,.13); --purple: #c2b0ff; --purple-bg: rgba(170,140,255,.15); --gray: #b4bcc9; --gray-bg: rgba(180,188,201,.12);
  --side: #070c1a; --side-ink: #aeb8d0; --sage-soft: rgba(160,187,131,.12); --sage-ink: #b8d29c;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); font-feature-settings: "tnum" 0; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 650; line-height: 1.2; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--head); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; word-break: break-all; }
pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; margin: 6px 0 0; }
small { font-size: 12px; }
.num, .r.num, td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums slashed-zero; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .strong { font-weight: 650; }
.r { text-align: right; } .c { text-align: center; } .nowrap { white-space: nowrap; }
.ok-t { color: var(--ok); } .warn-t { color: var(--warn); font-style: normal; } .bad-t { color: var(--bad); font-style: normal; }
.mt { margin-top: 12px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 99; }
.skip:focus { left: 8px; }
.ic { flex: none; vertical-align: middle; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px 12px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: #fff; text-decoration: none !important; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
.brand-mono { display: inline-flex; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-family: var(--display); font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand-txt small { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--sage); font-weight: 600; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px; color: var(--side-ink); font-weight: 500; position: relative; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: var(--side-on); color: #fff; }
.nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--sage); }
.nav a.on .ic { color: var(--sage); }
.nav span { flex: 1; }
.nb { font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.nb.bad { background: #c2402f; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 6px 2px; border-top: 1px solid rgba(255,255,255,.08); }
.who { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--side-ink); font-size: 11.5px; }
.av { width: 32px; height: 32px; border-radius: 50%; background: var(--sage); color: var(--navy); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.side .iconbtn { color: var(--side-ink); }
.side .iconbtn:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-scrim { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.gsearch { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--muted); }
.gsearch input { border: 0; background: transparent; height: 36px; flex: 1; min-width: 0; outline: none; color: var(--ink); font: inherit; }
.gsearch:focus-within { box-shadow: var(--focus); border-color: var(--sage-2); }
kbd { font: 11px var(--mono); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 22px 24px 40px; width: 100%; max-width: 1480px; display: flex; flex-direction: column; gap: 16px; }
.foot { padding: 14px 24px 22px; color: var(--faint); font-size: 12px; }
.iconbtn.only-m, .only-m { display: none; }

/* ---------- Page head, tabs */
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.phead h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phead .sub { color: var(--muted); margin: 6px 0 0; max-width: 820px; }
.phead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ph-badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs span { color: var(--faint); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 13px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--sage-2); }
.tabs em { font-style: normal; font-size: 11.5px; background: var(--gray-bg); color: var(--gray); border-radius: 10px; padding: 0 7px; font-weight: 650; }
.tabs a.on em { background: var(--sage-soft); color: var(--sage-ink); }
.h-sec { font-size: 15px; margin-top: 4px; }
.h-sm { font-size: 14px; margin-bottom: 10px; }
.h-xs { font-size: 13px; margin: 14px 0 4px; }

/* ---------- Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--hover); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.sage { background: var(--sage); border-color: var(--sage); color: #0f2108; }
.btn.sage:hover { background: #b2cb96; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); border-color: var(--line); }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.disabled { opacity: .45; pointer-events: none; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.iconbtn:hover { background: var(--hover); color: var(--ink); }
.iconbtn.sm { width: 26px; height: 26px; }
form.inline { display: inline; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; height: 36px; width: 100%; min-width: 0; }
textarea { padding: 8px 10px; height: auto; resize: vertical; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--navy); padding: 0; flex: none; }
:root[data-theme="dark"] input[type=checkbox], :root[data-theme="dark"] input[type=radio] { accent-color: var(--sage); }
input[type=color] { padding: 3px; width: 64px; }
input[type=file] { height: auto; padding: 8px; border-style: dashed; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sage-2); box-shadow: var(--focus); }
input[readonly], input:disabled, select:disabled { background: var(--head); color: var(--muted); }
input.r { text-align: right; font-variant-numeric: tabular-nums; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld.grow { flex: 1; }
.lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.hint { color: var(--muted); font-size: 12px; }
.req { color: var(--bad); font-style: normal; }
.chk { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; cursor: pointer; line-height: 1.4; }
.chk input { margin-top: 2px; }
.grid2, .grid3, .grid4, .grid5 { display: grid; gap: 12px 16px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid5 { grid-template-columns: 2fr .7fr 1fr 1fr 1fr auto; align-items: end; }
.grid2.tight { gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow { max-width: 440px; }
fieldset { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
legend { font-family: var(--display); font-weight: 650; font-size: 15px; padding: 0; margin-bottom: 10px; }
.form-sections fieldset { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.form-sections fieldset:last-of-type { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font: 600 11.5px var(--font); border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); padding: 3px 8px; border-radius: 20px; cursor: pointer; text-decoration: none !important; }
.chip:hover { border-color: var(--sage-2); background: var(--sage-soft); }

/* ---------- Cards, flashes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.pad { padding: 18px; } .pad-x { padding: 4px 18px 14px; } .pad-h { padding: 16px 18px 10px; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h2 { display: flex; align-items: center; gap: 8px; }
.card-h h2 small { font-family: var(--font); font-weight: 500; color: var(--muted); font-size: 12.5px; }
.cards { gap: 16px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--r); border: 1px solid; font-weight: 500; }
.flash > span { flex: 1; }
.flash a { color: inherit; text-decoration: underline; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash .iconbtn { color: inherit; width: 22px; height: 22px; }
.fineprint { color: var(--muted); font-size: 12px; margin: 0; }
.note { background: var(--blue-bg); color: var(--blue); padding: 10px 12px; border-radius: 8px; }
.callout { display: flex; gap: 10px; align-items: flex-start; background: var(--sage-soft); border: 1px solid color-mix(in srgb, var(--sage) 40%, transparent); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }

/* ---------- Badges */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 650; white-space: nowrap; letter-spacing: .01em; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; opacity: .85; }
.b-draft { background: var(--gray-bg); color: var(--gray); }
.b-review { background: var(--warn-bg); color: var(--warn); }
.b-posted { background: var(--blue-bg); color: var(--blue); }
.b-sent { background: color-mix(in srgb, var(--navy) 10%, var(--card)); color: var(--navy-3); }
:root[data-theme="dark"] .b-sent { color: #b9c7ef; background: rgba(120,145,220,.16); }
.b-partial { background: var(--teal-bg); color: var(--teal); }
.b-paid { background: var(--ok-bg); color: var(--ok); }
.b-overdue, .b-failed { background: var(--bad-bg); color: var(--bad); }
.b-credited, .b-credit { background: var(--purple-bg); color: var(--purple); }
.b-hist { background: transparent; color: var(--muted); border: 1px dashed var(--line-2); }
.b-hist::before { display: none; }
td.badges, .badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
td.badges { display: table-cell; }
td.badges .badge { margin: 1px 2px 1px 0; }

/* ---------- Tables */
.tbl-card { overflow: hidden; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--head); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th a { color: inherit; }
.tbl th.r { text-align: right; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.muted td { color: var(--muted); }
.tbl tr.is-od td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.tbl td small { display: block; color: var(--muted); }
.tbl td .cl { font-weight: 600; color: var(--ink); }
.tbl td .src { display: block; font-family: var(--font); color: var(--muted); font-size: 11px; }
.tbl tfoot td { background: var(--head); font-size: 13px; border-top: 1px solid var(--line); border-bottom: 0; padding: 9px 12px; }
.tbl tfoot tr.grand td, .tbl tr.grand td { font-weight: 700; font-size: 14px; }
.tbl.compact td, .tbl.compact th { padding: 7px 10px; }
.tbl .chk { width: 36px; padding-right: 0; }
.tbl .act { width: 44px; text-align: right; }
.tbl input, .tbl select, .tbl textarea { height: 34px; }
.tbl textarea { min-height: 34px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.pager > div { display: flex; gap: 6px; align-items: center; }
.pager .per select { width: auto; height: 30px; margin-left: 4px; }
.pager .pg { padding: 0 6px; }
.bulkbar { display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: var(--sage-soft); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bulkbar > span { margin-right: 6px; }

/* ---------- Filters */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px; }
.filters select { width: auto; max-width: 240px; }
.f-search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; color: var(--muted); flex: 1 1 220px; min-width: 180px; max-width: 360px; background: var(--card); }
.f-search input { border: 0; padding: 0; height: 34px; box-shadow: none !important; background: transparent; }
.f-search:focus-within { box-shadow: var(--focus); border-color: var(--sage-2); }
.f-date { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.f-date input { width: auto; height: 36px; }
.f-date i { font-style: normal; }
.f-more summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.f-more summary::-webkit-details-marker { display: none; }
.f-more[open] summary { border-style: solid; background: var(--hover); }
.f-more-in { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; width: 100%; }
.f-more[open] { flex-basis: 100%; order: 10; }

/* ---------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 3px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 16px 14px; color: var(--ink); text-decoration: none !important; box-shadow: var(--shadow); overflow: hidden; transition: border-color .15s, transform .15s; }
a.kpi:hover { border-color: var(--line-2); transform: translateY(-1px); }
.kpi::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: transparent; }
.kpi-ic { position: absolute; right: 14px; top: 14px; width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--head); color: var(--muted); }
.kpi-l { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; padding-right: 36px; }
.kpi-v { font-family: var(--display); font-size: 25px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; }
.kpi small { color: var(--muted); }
.kpi.t-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.kpi.t-navy .kpi-l, .kpi.t-navy small { color: #c3cde6; }
.kpi.t-navy .kpi-ic { background: rgba(255,255,255,.1); color: var(--sage); }
:root[data-theme="dark"] .kpi.t-navy { background: #16245a; border-color: #23347a; }
.kpi.t-sage::after { background: var(--sage); } .kpi.t-sage .kpi-ic { background: var(--sage-soft); color: var(--sage-ink); }
.kpi.t-amber::after { background: #e0a91b; } .kpi.t-amber .kpi-ic { background: var(--warn-bg); color: var(--warn); }
.kpi.t-red::after { background: var(--bad); } .kpi.t-red .kpi-ic { background: var(--bad-bg); color: var(--bad); }
.kpis.sm .kpi-v { font-size: 20px; }

/* ---------- Dashboard */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.queue { display: flex; flex-direction: column; }
.q-group { padding: 12px 18px 14px; border-bottom: 1px solid var(--line); }
.q-group:last-child { border-bottom: 0; }
.q-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.q-head b { font-weight: 650; }
.q-head em { font-style: normal; font-weight: 700; font-size: 12px; color: var(--muted); background: var(--head); border-radius: 10px; padding: 0 7px; }
.q-head a { margin-left: auto; font-size: 12.5px; }
.q-ic { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; background: var(--head); color: var(--muted); }
.q-ic.t-amber { background: var(--warn-bg); color: var(--warn); } .q-ic.t-red { background: var(--bad-bg); color: var(--bad); } .q-ic.t-navy { background: var(--blue-bg); color: var(--blue); }
.q-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 7px 8px; margin: 0 -8px; border-radius: 7px; color: var(--ink); text-decoration: none !important; }
.q-row:hover { background: var(--hover); }
.q-row span { min-width: 0; }
.q-row small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-row i { font-style: normal; }
.q-empty { color: var(--faint); font-size: 12.5px; margin: 2px 0 0 35px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.b1, .chart .b1 { background: var(--navy); fill: var(--navy); }
.sw.b2, .chart .b2 { background: var(--sage); fill: var(--sage); }
:root[data-theme="dark"] .chart .b1, :root[data-theme="dark"] .sw.b1 { fill: #6f86d6; background: #6f86d6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chart .b1, :root:not([data-theme="light"]) .sw.b1 { fill: #6f86d6; background: #6f86d6; } }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart rect:hover { opacity: .8; }
.facts { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 7px 14px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts.cols { grid-template-columns: repeat(4, auto 1fr); }
.facts.tight { gap: 3px 10px; font-size: 13px; }
.feed { list-style: none; margin: 0; padding: 8px 18px 14px; }
.feed li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed p { margin: 0; font-size: 13px; }
.feed small { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sage); margin-top: 6px; flex: none; }
.checklist .card-h { border-bottom: 0; padding-bottom: 6px; }
.meter { height: 5px; background: var(--head); margin: 0 18px; border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--sage-2), var(--sage)); }
.checklist ol { list-style: none; margin: 0; padding: 12px 14px 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.checklist li a { display: inline-flex; gap: 6px; align-items: center; padding: 6px 11px; border-radius: 20px; border: 1px solid var(--line-2); color: var(--ink); font-weight: 550; font-size: 13px; text-decoration: none; }
.checklist li a:hover { border-color: var(--sage-2); background: var(--sage-soft); }
.checklist li.done a { color: var(--ok); background: var(--ok-bg); border-color: transparent; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---------- Empty */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .ic { color: var(--sage-2); }
.empty h3 { color: var(--ink); font-size: 17px; }
.empty p { max-width: 520px; margin: 0; }

/* ---------- Invoice form */
.inv-form { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.inv-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sec h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lines-sec h2 { margin-bottom: 0; }
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff; font: 700 12px var(--font); display: inline-flex; align-items: center; justify-content: center; flex: none; }
:root[data-theme="dark"] .step { background: var(--sage); color: var(--navy); }
.client-card { margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: var(--paper); border: 1px dashed var(--line-2); }
.cc-grid { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr 1fr; gap: 12px; }
.cc-grid p { margin: 2px 0 0; font-size: 13px; }
.lines { table-layout: fixed; min-width: 760px; }
.lines td { vertical-align: top; }
.lines .ln-d { width: auto; }
.lines .ln-d .svc { margin-bottom: 6px; height: 30px; font-size: 12.5px; color: var(--muted); }
.lines .ln-q { width: 86px; } .lines .ln-p { width: 130px; } .lines .ln-x { width: 78px; } .lines .ln-t { width: 132px; } .lines .ln-a { width: 130px; padding-top: 16px; font-weight: 600; } .lines .ln-r { width: 40px; padding-top: 14px; }
.lines textarea { resize: none; overflow: hidden; }
.lines-foot { padding: 12px 18px 16px; }
.inv-side .sticky { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; }
.inv-side h2 { display: flex; align-items: center; gap: 10px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 4px 0 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .grand { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--ink); padding-top: 8px; border-top: 1px solid var(--line); }
.actions-stack { display: flex; flex-direction: column; gap: 8px; }
.side-links { border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- Detail views */
.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.view-main, .view-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.doc-frame { background: #525659; border-bottom: 1px solid var(--line); }
.doc-frame iframe { display: block; width: 100%; height: 720px; border: 0; }
.integrity { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 12px; }
.integrity.ok { color: var(--ok); background: var(--ok-bg); } .integrity.bad { color: var(--bad); background: var(--bad-bg); }
.check-panel .card-h { background: var(--paper); border-radius: var(--r) var(--r) 0 0; }
.check-panel.focus { border-color: var(--sage-2); box-shadow: 0 0 0 4px var(--sage-soft), var(--shadow); }
.issues { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.issues li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; }
.issues li .ic { margin-top: 2px; }
.issues.bad li { background: var(--bad-bg); color: var(--bad); } .issues.warn li { background: var(--warn-bg); color: var(--warn); } .issues.ok li { background: var(--ok-bg); color: var(--ok); }
.timeline { list-style: none; margin: 0; padding: 14px 18px 8px; position: relative; }
.timeline li { display: flex; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: -2px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline p { margin: 0; font-size: 13.5px; }
.timeline small { color: var(--muted); }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); margin-top: 6px; flex: none; position: relative; z-index: 1; }
.tl-dot.a-post { background: var(--ok); } .tl-dot.a-email { background: var(--blue); } .tl-dot.a-payment { background: var(--sage-2); } .tl-dot.a-draft { background: var(--faint); } .tl-dot.a-review { background: #e0a91b; } .tl-dot.a-fail { background: var(--bad); }
.mini { list-style: none; margin: 0 0 8px; padding: 0; }
.mini li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; align-items: center; }
.mini li small { grid-column: 1; color: var(--muted); }
.mini li b, .mini li .badge { grid-row: 1 / span 2; grid-column: 2; }
.mail-frame { width: 100%; height: 640px; border: 0; display: block; background: #eef0ea; border-radius: 0 0 var(--r) var(--r); }

/* ---------- Dropdown & modal */
.dd { position: relative; display: inline-block; }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 90; max-height: calc(100vh - 24px); overflow-y: auto; min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; display: none; }
.dd-menu.right { left: auto; right: 0; }
.dd.open .dd-menu { display: block; }
.dd-menu a, .dd-menu button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; border: 0; background: none; color: var(--ink); font: 500 13.5px var(--font); text-align: left; cursor: pointer; text-decoration: none; white-space: nowrap; }
.dd-menu a:hover, .dd-menu button:hover { background: var(--hover); }
.dd-menu form { margin: 0; }
.dd-note { display: block; padding: 6px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(5,10,30,.5); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(2px); }
.modal-card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; padding: 22px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); overflow-y: auto; border: 1px solid var(--line); }
.modal-card h3 { font-size: 18px; }
.modal-card p { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.radio-cards { display: grid; gap: 8px; }
.radio-cards.three { grid-template-columns: repeat(3, 1fr); }
.radio-cards label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: 9px; padding: 11px 12px; cursor: pointer; }
.radio-cards label:has(input:checked) { border-color: var(--sage-2); background: var(--sage-soft); box-shadow: 0 0 0 1px var(--sage-2) inset; }
.radio-cards input { margin-top: 3px; }
.radio-cards small { display: block; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 20px; font-weight: 600; z-index: 99; box-shadow: var(--shadow-lg); }

/* ---------- Runs, calendar */
.run-strip { display: flex; gap: 28px; flex-wrap: wrap; }
.run-strip > div { display: flex; flex-direction: column; gap: 2px; }
.cal { list-style: none; margin: 0; padding: 0; }
.cal li { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.cal li.due { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.cal-d { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line-2); border-radius: 9px; padding: 4px 0; background: var(--card); line-height: 1.1; }
.cal-d b { font-family: var(--display); font-size: 20px; }
.cal-d span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.cal-d small { font-size: 10.5px; color: var(--faint); }
.cal-items a { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; color: var(--ink); text-decoration: none; }
.cal-items a:hover span { text-decoration: underline; }
.cal-sum { text-align: right; font-weight: 700; padding-top: 4px; }
.cal-sum small { display: block; font-weight: 600; }
.runlist { list-style: none; margin: 0; padding: 0; }
.runlist a { display: flex; justify-content: space-between; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.runlist a:hover { background: var(--hover); }
.runlist small { display: block; color: var(--muted); }
.runlist .r { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

/* ---------- Settings, misc */
.copybox { display: flex; gap: 8px; align-items: center; background: var(--head); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 4px 0 8px; }
.copybox code { flex: 1; border: 0; background: none; padding: 0; font-size: 12px; }
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-prev { width: 88px; height: 88px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 6px; }
.logo-prev.empty { display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 12px; }
.perm-list { display: flex; flex-direction: column; }
.perm-list .chk { margin: 3px 0; font-size: 13px; }
.checks { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); }
.checks li.bad { background: var(--bad-bg); color: var(--bad); }
.checks small { color: var(--ink-2); opacity: .8; margin-left: 6px; word-break: break-all; }
.log { font-size: 12.5px; color: var(--muted); max-height: 220px; overflow: auto; }
.add-line summary { cursor: pointer; font-weight: 600; color: var(--blue); display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Corrections */
.danger-t { color: var(--bad) !important; }
.bulk-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.bulk-reason { width: 230px; height: 30px; }
.bulk-client { width: 200px; height: 30px; }
.dup-card { border-color: color-mix(in srgb, #e0a91b 45%, var(--line)); }
.dup-card .card-h .ic { color: var(--warn); }
.dup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dup-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 9px; }
.dup-item { color: var(--ink); padding: 4px 10px; border-radius: 7px; background: var(--head); text-decoration: none !important; }
.dup-item.keep { background: var(--ok-bg); }

/* ---------- Import */
.drop { border: 2px dashed var(--line-2); background: var(--paper); text-align: center; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--sage-2); background: var(--sage-soft); }
.drop-in { padding: 30px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop-in .ic { color: var(--sage-2); }
.drop-in h2 { font-size: 19px; }
.link { color: var(--blue); cursor: pointer; text-decoration: underline; }
.drop-notes { text-align: left; margin: 0 auto; padding: 0 18px 18px 36px; max-width: 720px; color: var(--muted); }

/* ---------- Auth & install */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
body.auth.split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); padding: 0; align-items: stretch; }
.auth-art { background: radial-gradient(1200px 600px at -10% 110%, rgba(160,187,131,.35), transparent 60%), linear-gradient(160deg, #021448 0%, #0a2366 60%, #13327f 100%); color: #dfe6f7; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.art-brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 650; font-size: 18px; color: #fff; }
.art-brand img { width: 46px; height: 46px; object-fit: contain; background: #fff; border-radius: 50%; padding: 3px; }
.art-copy { max-width: 460px; position: relative; z-index: 1; }
.art-copy h2 { font-size: 40px; line-height: 1.05; color: #fff; font-weight: 700; letter-spacing: -.03em; margin-bottom: 14px; }
.art-copy p { font-size: 16px; color: #c7d1ea; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 700; color: var(--sage) !important; margin-bottom: 14px !important; }
.art-ledger { position: absolute; right: -10px; bottom: 24px; width: 430px; max-width: 70%; color: #fff; }
.art-ledger .bars rect { fill: rgba(255,255,255,.12); }
.art-ledger .bars rect.hi { fill: var(--sage); }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; gap: 18px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 30px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.auth-card.wide { max-width: 760px; }
.auth-card h1 { font-size: 26px; }
.auth-card .lead { color: var(--muted); margin: -6px 0 2px; }
.auth-card .alt { text-align: center; margin: 0; font-size: 13px; }
.auth-foot { color: var(--faint); font-size: 12px; }
.auth-foot a { color: inherit; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-brand small { display: block; color: var(--muted); }

/* ---------- Portal & public pay */
body.portal { background: var(--bg); }
.p-wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; width: 100%; }
.p-top { background: var(--navy); color: #fff; }
.p-top .p-wrap { display: flex; align-items: center; gap: 20px; min-height: 64px; flex-wrap: wrap; }
.p-top .brand { padding: 10px 0; }
.p-nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.p-nav a { color: #c9d2e8; padding: 8px 12px; border-radius: 8px; font-weight: 550; white-space: nowrap; text-decoration: none; }
.p-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.p-nav a.on { background: rgba(160,187,131,.18); color: #fff; }
.p-who { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid rgba(255,255,255,.18); color: #fff; border-radius: 22px; padding: 3px 12px 3px 3px; cursor: pointer; font: 600 13px var(--font); }
.p-main { padding-top: 26px; padding-bottom: 40px; display: flex; flex-direction: column; gap: 16px; }
.narrow-main { max-width: 820px; }
.p-hello h1 { font-size: 30px; }
.p-foot { color: var(--faint); font-size: 12px; padding-bottom: 30px; }
.back { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.inv-pay { overflow: hidden; }
.ip-head { display: flex; justify-content: space-between; gap: 16px; padding: 20px; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--paper), var(--card)); }
.ip-head h2 { font-size: 22px; margin: 2px 0; }
.ip-amt { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ip-amt b { font-family: var(--display); font-size: 32px; letter-spacing: -.02em; }
.ip-actions { display: flex; gap: 8px; padding: 14px 20px; flex-wrap: wrap; }
.ip-pay { padding: 4px 20px 20px; }
.ip-pay h3 { margin-bottom: 10px; }
.pay-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 10px; }
.pay-opts form { margin: 0; display: flex; }
.pay-opt { flex: 1; display: flex; flex-direction: column; gap: 4px; text-align: left; border: 1px solid var(--line-2); background: var(--card); border-radius: 12px; padding: 14px 16px; font: inherit; color: var(--ink); cursor: pointer; }
button.pay-opt:hover { border-color: var(--sage-2); background: var(--sage-soft); }
button.pay-opt b::after { content: " →"; color: var(--sage-2); }
.pay-opt small { color: var(--muted); }
.pay-opt.eft { cursor: default; background: var(--paper); }

/* ---------- Responsive */
@media (max-width: 1180px) {
  .dash-grid, .view-grid { grid-template-columns: minmax(0, 1fr); }
  .inv-form { grid-template-columns: minmax(0, 1fr); }
  .inv-side .sticky { position: static; }
  .cc-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 70; transform: translateX(-102%); transition: transform .2s ease; }
  body.side-open .side { transform: none; box-shadow: var(--shadow-lg); }
  body.side-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(5,10,30,.45); z-index: 60; }
  .iconbtn.only-m, .only-m { display: inline-flex; }
  .top { padding: 8px 16px; }
  .gsearch kbd { display: none; }
  .content { padding: 16px 16px 32px; }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid5 { grid-template-columns: 1fr 1fr; }
  .radio-cards.three { grid-template-columns: 1fr; }
  .facts.cols { grid-template-columns: auto 1fr; }
  body.auth.split { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .doc-frame iframe { height: 520px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 10px; }
}
@media (max-width: 600px) {
  h1 { font-size: 22px; }
  .tbl td, .tbl th { white-space: nowrap; }
  .tbl.compact td:first-child { white-space: normal; min-width: 170px; }
  .lines { min-width: 0; table-layout: auto; }
  .lines thead { display: none; }
  .lines, .lines tbody { display: block; }
  .lines tr[data-line] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .lines tr[data-line] td { display: block; padding: 0; border: 0; width: auto !important; white-space: normal; }
  .lines td.ln-d { grid-column: 1 / -1; }
  .lines td.ln-q::before { content: "Qty"; } .lines td.ln-p::before { content: "Unit price"; } .lines td.ln-x::before { content: "Disc %"; } .lines td.ln-t::before { content: "Tax"; }
  .lines tr[data-line] td::before { display: block; font-size: 11px; font-weight: 650; color: var(--muted); margin-bottom: 3px; }
  .lines td.ln-a { padding-top: 22px; text-align: left; font-size: 15px; }
  .lines td.ln-r { padding-top: 18px; text-align: right; }
  .p-top .p-wrap { gap: 8px 12px; padding-top: 4px; }
  .p-nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  .p-top .dd { margin-left: auto; }
  .grid2, .grid3, .grid4, .grid5, .cc-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi-v { font-size: 19px; }
  .kpi-ic { display: none; }
  .kpi-l { padding-right: 0; }
  .filters > * { flex: 1 1 100%; max-width: none; }
  .filters select { max-width: none; width: 100%; }
  .f-date { flex-wrap: wrap; }
  .f-date input { flex: 1; min-width: 0; }
  .phead-actions { width: 100%; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .ip-amt { text-align: left; align-items: flex-start; }
  .p-hello h1 { font-size: 24px; }
  .hide-s { display: none; }
  .cal li { grid-template-columns: 50px minmax(0, 1fr); }
  .cal-sum { grid-column: 2; text-align: left; }
  .auth-card { padding: 22px; }
  .doc-frame { display: none; }
}
@media print {
  .side, .top, .foot, .phead-actions, .filters, .pager, .bulkbar { display: none !important; }
  .shell { display: block; } body { background: #fff; }
}

/* v3.2.0 — foreign-currency invoice items and client type */
.fx-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 6px; padding: 6px 8px; border: 1px dashed var(--line-2); border-radius: 8px; background: var(--head); font-size: 12.5px; color: var(--ink-2); }
.fx-note[hidden], .fx-box[hidden], [data-fx-ratewrap][hidden] { display: none; }
.fx-note .fx-in { width: 70px; height: 28px; padding: 0 6px; text-align: right; font: inherit; font-variant-numeric: tabular-nums; border: 1px solid var(--line-2); border-radius: 6px; background: var(--card); color: var(--ink); }
.fx-note .fx-rate { width: 84px; }
.fx-note b { font-weight: 650; color: var(--ink); }
.fx-note .linkbtn { margin-left: auto; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }
.linkbtn:hover { color: var(--ink); }
input[readonly][data-price] { background: var(--head); color: var(--ink-2); }
.fx-box { display: grid; gap: 6px; padding: 10px 12px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--head); }
.fx-box p { margin: 0; display: grid; }
.fx-box .hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
.ctype { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.ctype label { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; cursor: pointer; font-weight: 550; color: var(--ink-2); }
.ctype input { accent-color: var(--primary); }
.ctype label:has(input:checked) { background: var(--head); color: var(--ink); }
.ctype label + label { border-left: 1px solid var(--line-2); }
[data-company-only][hidden] { display: none !important; }
.tag-ind { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--head); border: 1px solid var(--line); color: var(--muted); vertical-align: 1px; }

/* v3.2.0: more room for descriptions — tighter number columns; Tax column hidden when LaMotheo is not VAT registered */
@media (min-width: 601px) {
  .lines .ln-q { width: 66px; } .lines .ln-p { width: 112px; } .lines .ln-x { width: 64px; } .lines .ln-a { width: 104px; } .lines .ln-r { width: 42px; padding-left: 4px; padding-right: 8px; }
}
.lines.novat .ln-t { display: none !important; }
.lines.novat { min-width: 620px; }

/* v3.3.0 two-step sign-in */
.qr { width: 210px; height: 210px; background: #fff; border-radius: 12px; padding: 6px; margin: 8px 0 12px; border: 1px solid var(--line, #dde); }
.qr svg { width: 100%; height: 100%; display: block; }
.setup-key { font-size: 15px; letter-spacing: .06em; user-select: all; word-break: break-all; }
pre.codes { font: 600 16px/1.9 ui-monospace, Menlo, Consolas, monospace; background: var(--bg-2, #f4f4f8); border-radius: 10px; padding: 12px 16px; columns: 2; max-width: 360px; user-select: all; }
ol.steps { padding-left: 1.2em; margin: 6px 0; }
#two-step { margin-bottom: 16px; }

/* ---------- v3.4.0 */
.foot a, .p-foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* WhatsApp */
.btn.wa { color: #0b6b3a; border-color: color-mix(in srgb, #25d366 45%, var(--line)); }
.btn.wa:hover { background: color-mix(in srgb, #25d366 12%, var(--card)); }
:root[data-theme="dark"] .btn.wa { color: #6fe3a0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.wa { color: #6fe3a0; } }
.wa-float { position: fixed; right: 18px; bottom: 18px; z-index: 40; display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px 11px 13px; border-radius: 999px;
  background: #1f9d55; color: #fff; font-weight: 600; font-size: 14px; text-decoration: none; box-shadow: 0 10px 24px -8px rgba(0,0,0,.45); }
.wa-float:hover { background: #17864a; }
.wa-float:focus-visible { outline: 3px solid var(--sage); outline-offset: 2px; }
@media (max-width: 560px) { .wa-float span { display: none; } .wa-float { padding: 13px; right: 14px; bottom: 14px; } }
@media print { .wa-float { display: none; } }
/* segmented period switch */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg a { padding: 4px 10px; font-size: 12.5px; color: var(--muted); text-decoration: none; border-left: 1px solid var(--line-2); }
.seg a:first-child { border-left: 0; }
.seg a.on { background: var(--sage-soft); color: var(--ink); font-weight: 600; }
/* horizontal bars (cost by description) */
.hbars { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 11px; }
.hb-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 4px; }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--ink-2); }
.hb-top b { white-space: nowrap; }
.hb-track { display: flex; align-items: center; gap: 8px; }
.hb-track small { color: var(--faint); font-size: 11px; width: 30px; text-align: right; flex: none; }
.hb-bar { display: block; height: 9px; border-radius: 5px; background: var(--sage); min-width: 2px; flex: none; max-width: calc(100% - 38px); }
.hb-bar.hi { background: var(--navy); }
:root[data-theme="dark"] .hb-bar.hi { background: #6f86d6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hb-bar.hi { background: #6f86d6; } }
/* terms & conditions */
.legal { max-width: 72ch; line-height: 1.6; }
.legal h2 { font-size: 16px; margin: 22px 0 6px; }
.legal h2:first-child { margin-top: 4px; }
.legal ul { margin: 0 0 8px; padding-left: 20px; }
.legal li { margin: 4px 0; }
textarea.mono-ish { font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.ct-lines th:first-child { width: 48%; }
.ct-lines td:first-child { min-width: 300px; }
.ct-lines td:first-child > select, .ct-lines td:first-child > input[data-desc] { width: 100%; }
.ct-lines .ln-q { width: 90px; } .ct-lines .ln-p { width: 140px; } .ct-lines .ln-t { width: 140px; }
/* conversation */
.chat .chat-list { max-height: 460px; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { margin: 4px 0; }
.msg { max-width: 82%; display: flex; flex-direction: column; gap: 3px; }
.msg.theirs { align-self: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-b { padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.theirs .msg-b { background: var(--head); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.mine .msg-b { background: var(--sage-soft); border: 1px solid color-mix(in srgb, var(--sage) 45%, transparent); border-bottom-right-radius: 4px; }
.msg.k-reject .msg-b { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-bg); }
.msg-tag { margin-bottom: 4px; }
.msg small { color: var(--faint); font-size: 11.5px; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chat-form textarea { flex: 1 1 260px; min-height: 44px; }
.chat-form .fld { flex: 1 1 100%; margin: 0; }
/* inbox icon in the top bar */
.inbox-btn { position: relative; }
.inbox-btn .nb { position: absolute; top: -4px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-style: normal; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; background: var(--bad); color: #fff; }
.p-nav .nb { font-style: normal; font-size: 11px; background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; margin-left: 4px; }
/* query / reject */
details.dispute summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
details.dispute[open] summary { color: var(--bad); }
.dispute-banner { align-items: center; }
.dispute-banner .btn { margin-left: auto; flex: none; }
.ok-t { color: var(--ok); font-style: normal; }
.client-card:empty { display: none; }
/* licence tracker */
.stepper { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 14px; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 13px; color: var(--muted); }
.stepper li span { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--head); font-weight: 700; font-size: 12px; }
.stepper li.done { color: var(--ink); border-color: color-mix(in srgb, var(--sage) 50%, var(--line)); }
.stepper li.done span { background: var(--sage); color: #0f2108; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); align-items: flex-start; flex-wrap: wrap; }
.alerts li:first-child { border-top: 0; }
.alerts li > div:first-child { flex: 1 1 380px; min-width: 0; }
.alerts li.is-new { background: color-mix(in srgb, var(--warn-bg) 60%, transparent); }
.alerts p { margin: 4px 0; }
/* assets */
.qr.qr-sm { width: 140px; height: 140px; margin: 0 auto 6px; }
.labels-page { background: #fff; color: #111; padding: 16px; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, 63mm); gap: 4mm; }
.label { width: 63mm; height: 30mm; border: 1px dashed #bbb; border-radius: 2mm; display: flex; gap: 3mm; align-items: center; padding: 2mm; box-sizing: border-box; overflow: hidden; break-inside: avoid; }
.label .qr { width: 25mm; height: 25mm; flex: none; margin: 0; padding: 0; border: 0; border-radius: 0; }
.label b { display: block; font-size: 13pt; font-family: var(--mono); }
.label span { display: block; font-size: 8.5pt; line-height: 1.25; }
.label small { display: block; font-size: 6.5pt; color: #555; margin-top: 1mm; line-height: 1.2; }
@media print { .no-print { display: none; } .labels-page { padding: 0; } .label { border-color: #ddd; } }
/* v3.4.1: portal — next invoice beside the spend chart */
.p-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; margin: 16px 0 6px; }
.p-split .inv-pay, .p-split .card { margin: 0; }
.p-split-cost .card-h { gap: 8px; }
@media (max-width: 900px) { .p-split { grid-template-columns: 1fr; } }
/* v3.4.2: month picker on monthly-in-advance lines */
.ln-month { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.ln-month input { width: auto; padding: 4px 8px; font-size: 13px; }
/* v3.4.2: Ozow as the main way to pay */
.pay-opt.pay-main { border-color: var(--navy); background: color-mix(in srgb, var(--navy) 6%, var(--card)); }
.pay-opt.pay-main b { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); }
:root[data-theme="dark"] .pay-opt.pay-main b { color: var(--sage); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pay-opt.pay-main b { color: var(--sage); } }
.paynow { text-align: center; max-width: 520px; margin: 10px auto; }
.paynow h1 { font-size: 40px; margin: 6px 0 8px; }
.paynow form { margin: 18px 0 10px; }
/* v3.4.5: B-BBEE seal */
.ip-right { display: flex; align-items: flex-start; gap: 14px; }
.bbbee-badge { width: 86px; flex: none; filter: drop-shadow(0 4px 8px rgba(2,20,72,.18)); }
.bbbee-badge svg, .bbbee-prev svg { width: 100%; height: auto; display: block; }
.bbbee-set { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.bbbee-set > div:last-child { flex: 1 1 420px; }
.bbbee-prev { width: 130px; flex: none; }
@media (max-width: 560px) { .bbbee-badge { width: 64px; } }

/* v3.5.0: banking */
.bank-tbl .bank-memo { font-family: var(--mono, ui-monospace, monospace); font-size: 12.5px; max-width: 340px; overflow-wrap: anywhere; }
.bank-tbl .bank-memo a { color: var(--ink); text-decoration: none; }
.bank-tbl td small { display: block; }
.score { font-style: normal; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 12px; background: var(--blue-bg); color: var(--blue); white-space: nowrap; }
.score.shi { background: var(--ok-bg); color: var(--ok); } .score.smid { background: var(--warn-bg); color: var(--warn); } .score.slo { background: var(--paper); color: var(--muted); }
.bank-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bank-bulk select, .bank-bulk input { max-width: 240px; }
.filters.flat { box-shadow: none; border: 0; padding: 0; background: none; margin: 0 0 12px; }
.card .pad.filters.flat, form.pad.filters.flat { padding: 14px 18px; border-top: 1px solid var(--line); margin: 0; }
.btn.xs { padding: 3px 8px; font-size: 12px; min-height: 0; gap: 4px; }
.rule-box { margin: 4px 0 14px; padding: 10px 14px; border: 1px dashed var(--line-2); border-radius: 10px; background: var(--paper); }
.rule-box summary { list-style: none; cursor: pointer; }
.rule-box summary::-webkit-details-marker { display: none; }
.rule-box[open] summary { margin-bottom: 8px; }
.cat-row { display: grid; grid-template-columns: minmax(160px, 1fr) 170px 60px 110px auto; gap: 8px; align-items: center; }
.prose ol, .prose ul { padding-left: 20px; margin: 6px 0 14px; } .prose li { margin: 4px 0; line-height: 1.5; }
.prose h3 { font-size: 14px; margin: 4px 0 6px; } .prose pre { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; overflow-x: auto; white-space: pre; }
.bank-import { align-items: start; }
.bank-import .drop { margin-bottom: 14px; }
.kpis .kpi-v.ok-t { color: var(--ok); }
@media (max-width: 720px) { .cat-row { grid-template-columns: 1fr 1fr; } .bank-tbl .bank-memo { max-width: 200px; } }
.bank-save { margin: 14px 0 18px; }

/* v3.6.0: service providers and tax */
.sup-grid th, .sup-grid td { padding-left: 8px; padding-right: 8px; font-size: 12.5px; }
.sup-grid tbody th { text-align: left; white-space: nowrap; }
.card-h .seg { display: flex; gap: 4px; }
.btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.yr-pick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tax-profile { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.tax-profile > div { display: flex; flex-direction: column; gap: 2px; }
.tax-profile > a { margin-left: auto; }
.tax-warn { margin: 0 0 12px; }
.flash.warn { background: var(--warn-bg); color: var(--ink); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.meter { height: 10px; border-radius: 6px; background: var(--paper); border: 1px solid var(--line); overflow: hidden; margin: 10px 0 6px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--sage), var(--navy)); border-radius: 6px; }
.tax-mini > div { display: flex; flex-direction: column; gap: 2px; } .tax-mini b { font-size: 20px; }
.tbl.compact td, .tbl.compact th { padding: 6px 8px; font-size: 13px; }
.checks-list { padding-left: 18px; } .checks-list li { margin: 4px 0; }
.kpi.t-red::after { background: var(--bad); } .kpi.t-red .kpi-v { color: var(--bad); }
