/* GenEx Invoice.  GenEx navy and blue from the brand files in project-data/00-brand-assets.
   No inline styles anywhere in the app: every rule lives here (estate rule, CSP style-src 'self'). */

@font-face { font-family: 'Plex'; src: url('../fonts/ibm-plex-sans-latin.woff2') format('woff2'); font-weight: 100 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex'; src: url('../fonts/ibm-plex-sans-latin-ext.woff2') format('woff2'); font-weight: 100 700; font-display: swap; unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --navy: #233145;
  --navy-2: #1a2535;
  --navy-3: #2d3e57;
  --blue: #27789d;
  --blue-2: #1f6585;
  --blue-soft: #e6f1f6;
  --blue-line: #b9d8e6;
  --ink: #1c2430;
  --ink-2: #4a5666;
  --muted: #677385;
  --line: #e1e6ec;
  --line-2: #eef1f5;
  --bg: #f4f6f9;
  --card: #ffffff;
  --good: #1b7a50;
  --good-soft: #e3f4ea;
  --warn: #9a5b00;
  --warn-soft: #fff3dc;
  --bad: #b02e2e;
  --bad-soft: #fbe7e7;
  --chart-a: #1c7fb3;
  --chart-b: #c2851a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 2px 8px rgba(20, 30, 45, .05);
  --font: 'Plex', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--blue-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
code, .mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: .86em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.pad { padding: 18px 20px; }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }
.bad-link { color: var(--bad); font-weight: 600; }

/* ---- icons ---- */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ms { width: 18px; height: 18px; flex: none; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { background: var(--navy); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px; }
.rail-brand { display: flex; align-items: flex-end; gap: 8px; padding: 0 10px 24px; color: #fff; }
.rail-brand:hover { text-decoration: none; }
.rail-brand img { width: 108px; height: auto; display: block; }
.rail-app { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: #8ec9e3; padding-bottom: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #c9d3df; font-weight: 500; position: relative; }
.nav a:hover { background: var(--navy-3); color: #fff; text-decoration: none; }
.nav a.on { background: var(--navy-3); color: #fff; }
.nav a.on::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: #5fb3d6; }
.badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 7px; }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--navy-3); }
.rail-user { font-size: 13px; color: #c9d3df; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.page-title { font-size: 21px; font-weight: 600; color: var(--navy); margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: var(--muted); width: 260px; }
.search input { border: 0; background: transparent; padding: 8px 0; font: inherit; width: 100%; color: var(--ink); outline: none; }
.search:focus-within { border-color: var(--blue); }
#view { padding: 24px 28px 48px; outline: none; max-width: 1440px; width: 100%; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--blue-line); background: var(--blue-soft); text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-3); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue-2); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { border-color: #e9b8b8; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.muted { opacity: .55; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.on-dark { color: #c9d3df; }
.icon-btn.on-dark:hover { background: var(--navy-3); color: #fff; }
.link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- cards, tabs, chips ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card.flush .card-h { margin-bottom: 0; border-bottom: 1px solid var(--line); }
.card-h h2, .card-title { font-size: 16px; font-weight: 600; color: var(--navy); }
.card-title { margin: 6px 0 14px; }
.card-title:not(:first-child) { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line-2); }
.card-h p { font-size: 13px; margin-top: 2px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.bar .tabs { margin-bottom: 0; }
.tabs a { padding: 7px 13px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.tabs a:hover { background: var(--card); text-decoration: none; }
.tabs a.on { background: var(--navy); color: #fff; }
.count { font-size: 12px; opacity: .7; margin-left: 2px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.st-draft { background: var(--warn-soft); color: var(--warn); }
.st-issued { background: var(--blue-soft); color: var(--blue-2); }
.st-part { background: #ece8fb; color: #4b3a99; }
.st-overdue { background: var(--bad-soft); color: var(--bad); }
.st-paid { background: var(--good-soft); color: var(--good); }
.st-void { background: var(--line-2); color: var(--muted); text-decoration: line-through; }
.empty { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--good-soft); color: var(--good); }
.fine { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: #f9fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tbody tr:hover td { background: #fafcfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact td, .table.compact th { padding: 6px 10px; }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.compact { gap: 10px; margin-top: 12px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; }
.row > .field.narrow { flex: 0 1 150px; }
.row > .field.grow { flex: 3 1 260px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #cfd7e1; border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(39, 120, 157, .15); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: auto; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.actions.sticky { position: sticky; bottom: 0; background: var(--card); padding: 14px 0 4px; border-top: 1px solid var(--line-2); margin-top: 6px; }
.section-h { font-size: 15px; font-weight: 600; color: var(--navy); margin-top: 8px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.two-col > aside { display: flex; flex-direction: column; gap: 20px; }
.narrow-card { max-width: 720px; }

/* ---- flash ---- */
.flashes { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(460px, calc(100vw - 32px)); }
.flash { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 10px; background: var(--navy); color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-size: 14px; }
.flash.warn { background: #7a4a00; }
.flash .icon-btn { color: #fff; }
.flash .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.flash.gone { display: none; }

/* ---- sign in ---- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr minmax(360px, 480px); background: var(--bg); }
.login-side { background: var(--navy); color: #c9d3df; display: flex; flex-direction: column; justify-content: center; padding: 60px; gap: 22px; position: relative; overflow: hidden; }
.login-side img { width: min(340px, 80%); height: auto; }
.login-side p { font-size: 18px; max-width: 360px; }
.login-side::after { content: ''; position: absolute; right: -60px; top: 18%; width: 260px; height: 64px; background: var(--blue); transform: skewX(-38deg); opacity: .9; }
.login-card { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 48px 44px; background: var(--card); }
.login:not(:has(.login-side)) { grid-template-columns: 1fr; place-items: center; }
.login:not(:has(.login-side)) .login-card { max-width: 440px; border-radius: var(--radius); box-shadow: var(--shadow); }
.login-logo { width: 170px; height: auto; margin-bottom: 4px; }
.login-host { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.login-host .ic { width: 14px; height: 14px; }
.login-card h1 { font-size: 24px; color: var(--navy); margin-top: 10px; }
.ms-btn { justify-content: center; gap: 10px; padding: 11px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.code-in { font-size: 26px; letter-spacing: .3em; text-align: center; font-family: Consolas, monospace; }
.qr { width: 180px; height: 180px; align-self: center; border: 1px solid var(--line); border-radius: 8px; }
.key { font-family: Consolas, monospace; background: var(--bg); padding: 10px; border-radius: 8px; text-align: center; letter-spacing: .08em; word-break: break-all; }
.codes { columns: 2; font-family: Consolas, monospace; padding: 12px 12px 12px 30px; background: var(--bg); border-radius: 8px; margin: 0; }
.login-foot { margin-top: 24px; font-size: 12px; color: var(--muted); }

/* ---- dashboard ---- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.lede { color: var(--ink-2); margin-top: 4px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg a { padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg a.on { background: var(--navy); color: #fff; }
.seg a:hover { text-decoration: none; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.tile::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.tile.tile-bad::before { background: var(--bad); }
.tile-k { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-k .ic { color: var(--blue); width: 16px; height: 16px; }
.tile-v { font-size: 26px; font-weight: 600; color: var(--navy); margin: 8px 0 6px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.amt { white-space: nowrap; }
.tile-v .plus { display: none; }
.tile-v .amt:not(:first-child) { display: block; font-size: 17px; color: var(--ink-2); margin-top: 2px; }
.tile-v .amt:not(:first-child)::before { content: '+ '; color: var(--muted); font-weight: 400; }
.tile-v .unit { font-size: 16px; color: var(--muted); margin-left: 3px; font-weight: 500; }
.tile-s { font-size: 13px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.legend { display: flex; gap: 14px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.key-invoiced { background: var(--chart-a); }
.key-received { background: var(--chart-b); }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-t { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.axis-now { fill: var(--ink); font-weight: 600; }
.hit { cursor: default; }
.hit:hover, .hit.on { fill: rgba(39, 120, 157, .07); }
.chart-empty { position: absolute; inset: 0 0 26px 44px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.tip { position: absolute; top: 0; left: 0; background: var(--navy); color: #fff; border-radius: 8px; padding: 9px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); white-space: nowrap; z-index: 3; }
.tip[hidden] { display: none; }
.tip span { display: flex; align-items: center; gap: 6px; color: #c9d3df; }
.tip b { color: #fff; margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.table-view { margin-top: 10px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--blue-2); }
.ranks, .bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ranks li, .bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; }
.rank-name { font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-v, .bar-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-s { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.bar-k { font-size: 14px; }
.rank-bar { grid-column: 1 / -1; width: 100%; height: 6px; display: block; }
.rank-track { fill: var(--line-2); }
.rank-fill { fill: var(--chart-a); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list li > a, .list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list li > a { flex: 1; min-width: 0; padding: 10px 0; color: var(--ink); }
.list li > a:hover { text-decoration: none; color: var(--blue-2); }
.list.tight li { padding: 8px 0; }
.list.tight li > a { padding: 0; }
.list-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.list-side { display: flex; align-items: center; gap: 10px; flex: none; font-variant-numeric: tabular-nums; font-size: 14px; }
.list-side form { display: contents; }

/* ---- builder ---- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.preview .paper { padding: 0 24px 22px; }
.preview .paper-band { margin: 0 -24px 22px; }
.add-client { margin-bottom: 2px; }
.lines { display: flex; flex-direction: column; gap: 12px; }
.line { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fbfcfd; display: flex; flex-direction: column; gap: 10px; }
.line-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; grid-template-areas: 'date kind kind del' 'hours rate amt amt'; gap: 10px; align-items: end; }
.line-top .f-date { grid-area: date; }
.line-top .f-kind { grid-area: kind; }
.line-top .f-hours { grid-area: hours; }
.line-top .f-rate { grid-area: rate; }
.line-top .line-amt { grid-area: amt; }
.line-top [data-del-line] { grid-area: del; align-self: start; }
.line-amt { display: flex; flex-direction: column; gap: 5px; text-align: right; padding-bottom: 9px; }
.line-amt b { font-variant-numeric: tabular-nums; color: var(--navy); }
.lines-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); flex: 1; }
.lines-total { font-size: 15px; }
.lines-total b { color: var(--navy); font-size: 18px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.preview { position: sticky; top: 92px; }
.preview-h { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; font-size: 13px; }
.paper-wrap { min-width: 0; }
.preview .paper-wrap { max-height: calc(100vh - 140px); overflow: auto; border-radius: var(--radius); }
.preview .paper-wrap.loading { opacity: .6; }

/* ---- the invoice on screen ---- */
.paper { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 0 34px 26px; font-size: 13px; position: relative; overflow: hidden; }
.paper-band { height: 6px; background: var(--navy); margin: 0 -34px 24px; position: relative; }
.paper-band i { position: absolute; right: 10%; top: 0; width: 64px; height: 6px; background: var(--blue); transform: skewX(-38deg); }
.paper-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.paper-logo { width: 140px; height: auto; display: block; margin-bottom: 8px; }
.paper-co { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.paper-word { text-align: right; position: relative; }
.paper-word h2 { font-size: 30px; letter-spacing: .02em; color: var(--navy); font-weight: 700; }
.paper-no { color: var(--blue); font-weight: 700; font-size: 15px; }
.paper-draft { color: var(--warn); font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.stamp { display: inline-block; margin-top: 10px; border: 2px solid; padding: 3px 14px; font-weight: 800; letter-spacing: .12em; font-size: 15px; border-radius: 3px; transform: rotate(-4deg); }
.stamp-paid { color: var(--good); }
.stamp-void { color: var(--bad); }
.paper-facts { display: grid; grid-template-columns: repeat(3, auto) 1fr; gap: 14px 26px; margin: 22px 0; padding: 14px 18px; background: #f0f6f9; border-left: 4px solid var(--blue); border-radius: 3px; }
.paper-facts dt { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.paper-facts dd { margin: 2px 0 0; font-weight: 600; white-space: nowrap; }
.paper-facts .due { text-align: right; }
.paper-facts .due dd { font-size: 18px; color: var(--navy); }
.paper-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.paper-parties p { line-height: 1.55; }
.paper-k { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 3px; }
.paper-parties .paper-k:not(:first-child) { margin-top: 10px; }
.paper-lines { width: 100%; border-collapse: collapse; font-size: 12px; }
.paper-lines th { background: var(--navy); color: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-align: left; padding: 8px 7px; white-space: nowrap; }
.paper-lines td { padding: 9px 7px; border-bottom: 1px solid var(--line); vertical-align: top; }
.paper-lines td:nth-child(3) { width: 40%; }
.paper-lines tbody tr:nth-child(even) td { background: #fafbfd; }
.paper-lines .num { text-align: right; font-variant-numeric: tabular-nums; }
.paper-lines .kind { color: var(--blue); font-weight: 700; font-size: 11px; }
.paper-totals { margin: 14px 0 0 auto; width: min(300px, 100%); display: flex; flex-direction: column; gap: 4px; }
.paper-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.paper-totals span { color: var(--muted); }
.paper-totals .grand { background: var(--navy); color: #fff; padding: 10px; margin-top: 6px; border-radius: 3px; }
.paper-totals .grand span { color: #fff; font-weight: 600; }
.paper-totals .grand b { font-size: 16px; }
.paper-foot { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; margin-top: 24px; }
.paper-bank { background: #f0f6f9; border-top: 3px solid var(--blue); padding: 12px 16px; border-radius: 3px; }
.paper-bank dl { margin: 6px 0 8px; display: flex; flex-direction: column; gap: 2px; }
.paper-bank dl div { display: grid; grid-template-columns: 110px 1fr; }
.paper-bank dt { color: var(--muted); }
.paper-bank dd { margin: 0; font-weight: 600; }
.paper-bank .ref dd { color: var(--navy); }
.paper-bank .fine { font-size: 11px; }
.paper-notes p { margin-bottom: 8px; }
.thanks { color: var(--blue); font-weight: 700; font-size: 14px; }
.paper-legal { margin-top: 22px; padding-top: 10px; border-top: 1px solid var(--line); text-align: center; font-size: 10.5px; color: var(--muted); }
.paper.is-draft::after { content: 'DRAFT'; position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%) rotate(-24deg); font-size: 110px; font-weight: 800; color: rgba(154, 91, 0, .06); pointer-events: none; letter-spacing: .1em; }

/* ---- one invoice ---- */
.inv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.inv-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 92px; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-amount { font-size: 28px; font-weight: 600; color: var(--navy); margin-top: 12px; font-variant-numeric: tabular-nums; }
.side-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.side-actions form { display: contents; }
.facts { margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; word-break: break-word; }
.void-box summary { cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--bad); font-weight: 500; }

/* ---- clients ---- */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.client-card { display: flex; flex-direction: column; gap: 10px; }
.client-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.client-card h2 { font-size: 16px; }
.client-card h2 a { color: var(--navy); }
.client-card footer { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.mini { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 13px; }
.mini dt { color: var(--muted); font-size: 12px; }
.mini dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
aside .mini { margin-bottom: 14px; }

/* ---- reports ---- */
.filters { margin-bottom: 18px; display: flex; flex-direction: column; gap: 12px; }
.ranges { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.exports { display: flex; gap: 8px; }
.totals-inline { display: flex; gap: 18px; font-size: 14px; flex-wrap: wrap; justify-content: flex-end; }
.totals-inline b { color: var(--navy); }

/* ---- smaller screens ---- */
@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .builder { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .preview { position: static; }
  .preview .paper-wrap { max-height: none; }
  .filter-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 8px; overflow-x: auto; }
  .rail-brand { padding: 0 6px 0 0; }
  .rail-brand img { width: 78px; }
  .rail-app { display: none; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a { padding: 8px 10px; }
  .nav a span { display: none; }
  .nav a.on::before { display: none; }
  .rail-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .rail-user, .rail-foot .avatar { display: none; }
  .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; }
  .search { order: 3; width: 100%; }
  .topbar .btn span { display: none; }
  #view { padding: 16px 16px 40px; }
  .two-col, .inv-layout { grid-template-columns: 1fr; }
  .inv-side { position: static; }
  .grid-3 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-card { padding: 32px 20px; }
  .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr; }
  .line-top { grid-template-columns: 1fr 1fr auto; grid-template-areas: 'date date del' 'kind kind kind' 'hours rate rate' 'amt amt amt'; }
  .line-amt { text-align: left; padding: 0; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .paper { padding: 0 16px 18px; }
  .paper-band { margin: 0 -16px 18px; }
  .paper-head, .paper-parties, .paper-foot { grid-template-columns: 1fr; display: grid; }
  .paper-word { text-align: left; }
  .paper-facts { grid-template-columns: 1fr 1fr; }
  .paper-facts .due { text-align: left; }
  .paper-lines th:nth-child(2), .paper-lines td:nth-child(2) { display: none; }
  .bar { align-items: stretch; }
}
@media print {
  .rail, .topbar, .inv-side, .flashes { display: none; }
  .shell, .inv-layout { display: block; }
  #view { padding: 0; }
  .paper { border: 0; box-shadow: none; }
}
