:root {
  /* New Starts Books: deep navy workspace, brand blue for action, orange for "create". Sidebar + workspace; bottom bar on phones. */
  --brand: #2453e6;
  --brand-2: #1a3fb8;
  --brand-ink: #ffffff;
  --brand-soft: #eaf0ff;
  --accent: #f28c1b;
  --accent-ink: #1d1203;
  --accent-soft: #fff2e3;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafd;
  --ink: #121a2a;
  --ink-2: #44506a;
  --ink-3: #6e7a92;
  --line: #e1e6ef;
  --line-2: #edf0f6;
  --side: #0d1730;
  --side-2: #121f40;
  --side-ink: #b9c5dd;
  --side-hi: #ffffff;
  --good: #128046; --good-soft: #e2f6ea;
  --warn: #a85b06; --warn-soft: #fdf0dc;
  --bad: #c42b1c; --bad-soft: #fde8e5;
  --info: #2453e6; --info-soft: #eaf0ff;
  --muted-soft: #edf0f6;
  --shadow-sm: 0 1px 2px rgba(13, 23, 48, .06);
  --shadow: 0 1px 2px rgba(13, 23, 48, .05), 0 8px 24px -8px rgba(13, 23, 48, .12);
  --shadow-lg: 0 20px 50px -12px rgba(13, 23, 48, .35);
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --r: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #6b93ff; --brand-2: #4d78f0; --brand-ink: #0a1020; --brand-soft: #172447;
    --accent: #ff9d3b; --accent-ink: #1d1203; --accent-soft: #3a2614;
    --bg: #0a101e; --panel: #111a2c; --panel-2: #0e1627;
    --ink: #e8edf6; --ink-2: #b5c0d4; --ink-3: #8592ab;
    --line: #223050; --line-2: #19243c;
    --side: #070c18; --side-2: #0c1428; --side-ink: #9eb0cf;
    --good: #4ade80; --good-soft: #0f2e1c; --warn: #fbbf24; --warn-soft: #33270c;
    --bad: #f87171; --bad-soft: #3a1716; --info: #8aa9ff; --info-soft: #172447; --muted-soft: #1a2540;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #6b93ff; --brand-2: #4d78f0; --brand-ink: #0a1020; --brand-soft: #172447;
  --accent: #ff9d3b; --accent-ink: #1d1203; --accent-soft: #3a2614;
  --bg: #0a101e; --panel: #111a2c; --panel-2: #0e1627;
  --ink: #e8edf6; --ink-2: #b5c0d4; --ink-3: #8592ab;
  --line: #223050; --line-2: #19243c;
  --side: #070c18; --side-2: #0c1428; --side-ink: #9eb0cf;
  --good: #4ade80; --good-soft: #0f2e1c; --warn: #fbbf24; --warn-soft: #33270c;
  --bad: #f87171; --bad-soft: #3a1716; --info: #8aa9ff; --info-soft: #172447; --muted-soft: #1a2540;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5); --shadow-lg: 0 20px 50px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}
/* high contrast: stronger ink, borders and focus */
:root[data-contrast] { --ink: #000; --ink-2: #1b1f27; --ink-3: #333b49; --line: #6b7385; --line-2: #9aa2b2; --brand: #0b3fd1; --side-ink: #ffffff; }
@media (prefers-color-scheme: dark) { :root[data-contrast]:not([data-theme="light"]) { --ink: #fff; --ink-2: #eef2f8; --ink-3: #cdd6e6; --line: #8a97b3; --line-2: #5a6784; --brand: #9fb9ff; } }
:root[data-theme="dark"][data-contrast] { --ink: #fff; --ink-2: #eef2f8; --ink-3: #cdd6e6; --line: #8a97b3; --line-2: #5a6784; --brand: #9fb9ff; }
:root[data-contrast] :focus-visible { outline-width: 3px; }
:root[data-dyslexia] body { letter-spacing: .02em; word-spacing: .08em; line-height: 1.75; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
#root { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -.015em; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
kbd { font: 600 11px var(--font-body); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: 60px 1fr; height: 100%; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: linear-gradient(90deg, var(--side) 0, var(--side-2) 100%); color: var(--side-ink); border-bottom: 1px solid rgba(255,255,255,.06); z-index: 20; }
.brandmark { display: flex; align-items: center; gap: 10px; color: var(--side-hi); min-width: 220px; background: none; border: 0; padding: 6px 8px; margin-left: -8px; border-radius: 10px; cursor: pointer; text-align: left; }
button.brandmark:hover { background: rgba(255,255,255,.07); }
.brandmark .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #2c5bf0 0 52%, #f28c1b 52% 100%); color: #fff; font: 800 17px var(--font-display); box-shadow: 0 4px 12px rgba(36,83,230,.4); flex: none; }
.bm-text { display: grid; line-height: 1.2; min-width: 0; }
.bm-text > span { font: 700 15px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.bm-text small { font: 500 11.5px var(--font-body); color: var(--side-ink); white-space: nowrap; }
.search-btn { flex: 1; max-width: 520px; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: var(--side-ink); cursor: pointer; text-align: left; transition: background .15s var(--ease); }
.search-btn:hover { background: rgba(255,255,255,.1); }
.search-btn span { flex: 1; }
.search-btn kbd { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: var(--side-ink); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { height: 38px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: var(--side-hi); cursor: pointer; padding: 0 10px; font-weight: 700; transition: background .15s var(--ease), transform .15s var(--ease); }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.icon-btn.orange { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px rgba(242,140,27,.35); }
.icon-btn.orange:hover { transform: translateY(-1px); background: var(--accent); }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); background: linear-gradient(135deg, #2c5bf0, #6b93ff); color: #fff; font: 700 13px var(--font-display); cursor: pointer; }
.sync { font-size: 12px; color: var(--side-ink); display: flex; align-items: center; gap: 6px; padding: 0 6px; white-space: nowrap; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; box-shadow: 0 0 0 3px rgba(74,222,128,.18); }
.sync.local i { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251,191,36,.18); }
.sync.wait i { background: #94a3b8; box-shadow: none; }
.sync.err i { background: #f87171; }
.menu-toggle { display: none; }

.side { background: var(--side); color: var(--side-ink); overflow-y: auto; padding: 12px 10px 24px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 11px; border: 0; background: none; color: var(--side-ink); border-radius: 9px; cursor: pointer; text-align: left; font-weight: 600; font-size: 14px; transition: background .15s var(--ease), color .15s var(--ease); }
.nav-item span { flex: 1; }
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--side-hi); }
.nav-item.active { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 6px 16px -6px rgba(36,83,230,.7); }
:root[data-theme="dark"] .nav-item.active { color: #0a1020; }
.nav-item svg { flex: none; opacity: .9; }
.nav-head .chev { transition: transform .2s var(--ease); opacity: .6; }
.nav-group:not(.open) .chev { transform: rotate(-90deg); }
.nav-sub { padding-left: 29px; display: grid; gap: 1px; margin: 1px 0 6px; overflow: hidden; }
.nav-group:not(.open) .nav-sub { display: none; }
.nav-sub .nav-item { font-weight: 500; padding: 7px 11px; font-size: 13.5px; }
.side-foot { margin-top: auto; padding-top: 16px; }
.side-note { font-size: 11.5px; color: #7f8fb0; padding: 10px 11px; }
.side-note kbd { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: var(--side-ink); }

.main { overflow-y: auto; min-width: 0; outline: none; scroll-behavior: smooth; }
.page { padding: 22px 28px 72px; max-width: 1320px; margin: 0 auto; animation: pagein .22s var(--ease); }
@keyframes pagein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 23px; }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.crumb { color: var(--ink-3); font-size: 13px; margin-bottom: 4px; }
.crumb button { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font-weight: 600; }
.viewer-banner { background: var(--info-soft); color: var(--info); font-weight: 700; text-align: center; padding: 8px; font-size: 13px; }
.bottom-bar, .scrim { display: none; }

/* ---------- controls ---------- */
.btn { height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; box-shadow: var(--shadow-sm); transition: border-color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease); }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-color: var(--brand-2); color: var(--brand-ink); box-shadow: 0 6px 16px -8px var(--brand); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.orange { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px -8px var(--accent); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: none; border-color: transparent; color: var(--brand); box-shadow: none; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.big { height: 46px; font-size: 15px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field > span.req::after { content: " *"; color: var(--bad); }
.field small { color: var(--ink-3); font-size: 12px; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=email], input[type=tel], input[type=password], select, textarea {
  height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); padding: 0 11px; width: 100%; min-width: 0; transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input[type=file] { font-size: 13px; }
textarea { height: auto; min-height: 72px; padding: 9px 11px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
input:disabled { opacity: .6; }
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--brand); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; min-height: 40px; }
.radio-row label, .check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 7px 13px; cursor: pointer; font-weight: 650; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.pw { display: flex; gap: 6px; }
.meter { height: 4px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s var(--ease); }

/* ---------- cards & tables ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.card-h { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h3 { font-size: 15px; }
.card-b { padding: 18px; }
.card + .card { margin-top: 16px; }
.tiles > .card + .card, .dash > .card + .card, .report-list > .card + .card, .hero-empty > .card + .card, .detail > .card + .card, .org-grid > .card + .card, .cal > .card + .card, .board .card + .card { margin-top: 0; }
.cal { display: grid; gap: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 750; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
tr.ok-row td { background: color-mix(in srgb, var(--good-soft) 50%, transparent); }
tfoot td { font-weight: 800; border-top: 2px solid var(--line); background: var(--panel-2); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 17px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 750; }
.link { color: var(--brand); cursor: pointer; border: 0; background: none; padding: 0; font-weight: 700; }
.link:hover { text-decoration: underline; }

.pill { display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; background: var(--muted-soft); color: var(--ink-2); white-space: nowrap; }
.pill.paid, .pill.accepted, .pill.closed, .pill.invoiced, .pill.published, .pill.recorded, .pill.active, .pill.saved { background: var(--good-soft); color: var(--good); }
.pill.overdue, .pill.declined, .pill.void, .pill.deleted { background: var(--bad-soft); color: var(--bad); }
.pill.partially, .pill.open, .pill.paused { background: var(--warn-soft); color: var(--warn); }
.pill.sent { background: var(--info-soft); color: var(--info); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 13px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-2); transition: all .15s var(--ease); }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.filters input[type=text] { max-width: 280px; height: 34px; }

/* ---------- dashboard ---------- */
.quick-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.quick { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 700; text-align: left; box-shadow: var(--shadow-sm); transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease); color: var(--ink); }
.quick svg { color: var(--brand); background: var(--brand-soft); padding: 7px; width: 34px; height: 34px; border-radius: 10px; }
.quick:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { padding: 18px; position: relative; overflow: hidden; }
.tile .label { font-size: 12.5px; color: var(--ink-3); font-weight: 700; }
.tile .value { font: 750 24px var(--font-display); margin: 4px 0 10px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-soft); opacity: .55; pointer-events: none; }
.bar { height: 7px; border-radius: 5px; background: var(--line-2); overflow: hidden; display: flex; position: relative; }
.bar.tall { height: 10px; overflow: visible; }
.bar i { display: block; height: 100%; border-radius: 5px; transition: width .5s var(--ease); }
.bar .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 2px; }
.tile .split { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; margin-top: 8px; color: var(--ink-2); position: relative; z-index: 1; }
.dash { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.dash-even { grid-template-columns: 1fr 1fr; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 9px 16px; }
.kv .num { font-weight: 750; }
.checklist { display: grid; gap: 10px; }
.checklist div { display: flex; gap: 10px; align-items: center; }
.checklist .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 11px; flex: none; }
.checklist .done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.checklist .done { color: var(--ink-3); text-decoration: line-through; }
.hero-empty { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.hero-empty .card:first-child { background: linear-gradient(135deg, var(--brand) 0, var(--brand-2) 70%, #f28c1b 160%); color: #fff; border: 0; }
.hero-empty .card:first-child .muted { color: rgba(255,255,255,.85); }
.hero-empty .card-b h2 { font-size: 21px; margin-bottom: 8px; }
.dl-list { display: grid; gap: 10px; }
.dl { display: flex; gap: 12px; align-items: center; }
.dl.done { opacity: .55; }
.dl-main { flex: 1; display: grid; }
.dl-date { width: 48px; height: 50px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; align-content: center; font-size: 11px; font-weight: 750; text-transform: uppercase; flex: none; line-height: 1.1; }
.dl-date b { font: 800 18px var(--font-display); }
.dl-date.warn { background: var(--warn-soft); color: var(--warn); }
.dl-date.bad { background: var(--bad-soft); color: var(--bad); }
.kpis .kpi { padding: 18px; border-left: 4px solid var(--line); }
.kpi .label { font-size: 12.5px; color: var(--ink-3); font-weight: 700; }
.kpi .value { font: 750 24px var(--font-display); margin: 4px 0 6px; }
.kpi.good { border-left-color: var(--good); } .kpi.good .value { color: var(--good); }
.kpi.warn { border-left-color: var(--warn); } .kpi.warn .value { color: var(--warn); }
.kpi.bad { border-left-color: var(--bad); } .kpi.bad .value { color: var(--bad); }
.tips { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.bgt-list { display: grid; gap: 14px; }
.bgt { display: grid; gap: 6px; margin-bottom: 8px; }
.bgt-h { display: flex; justify-content: space-between; gap: 8px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.lane { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.lane h3 { font-size: 14px; display: grid; gap: 2px; }
.lane-empty { padding: 10px 2px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 4px; box-shadow: var(--shadow-sm); }
.k-top { display: flex; justify-content: space-between; gap: 8px; }
.k-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.org-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.org-card.current { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow); }
.org-top { display: flex; gap: 12px; align-items: center; }
.org-dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font: 800 13px var(--font-display); flex: none; text-transform: uppercase; }
.org-dot.big { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }

/* ---------- document form ---------- */
.doc-form .lines th, .doc-form .lines td { padding: 7px 6px; }
.doc-form .lines td { border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.doc-form .lines input, .doc-form .lines select { height: 36px; }
.doc-form .lines .desc { margin-top: 5px; height: 30px; font-size: 12.5px; }
.doc-form .lines .amt { font-weight: 750; text-align: right; min-width: 96px; font-variant-numeric: tabular-nums; }
.doc-foot { display: grid; grid-template-columns: 1fr 400px; gap: 24px; margin-top: 16px; align-items: start; }
.totals { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: grid; gap: 9px; }
.totals .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; }
.totals .row input, .totals .row select { width: 110px; height: 32px; }
.totals .grand { font: 750 19px var(--font-display); border-top: 1px solid var(--line); padding-top: 11px; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 12px 28px; display: flex; gap: 8px; z-index: 5; margin: 24px -28px -72px; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 13px; font-weight: 700; }
.err:empty { display: none; }
.notice { padding: 11px 15px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 650; margin-bottom: 16px; }
.notice.info { background: var(--info-soft); color: var(--info); }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.detail > div:last-child { display: grid; gap: 16px; }
.detail > div:last-child > .card + .card { margin-top: 0; }
.ribbon { display: flex; gap: 8px; align-items: center; padding: 12px 16px; flex-wrap: wrap; }
.paper { background: #fff; color: #1a2230; padding: 40px 44px; border-radius: 6px; box-shadow: 0 0 0 1px #e3e7ee, 0 12px 30px -16px rgba(13,23,48,.35); font-size: 12.5px; margin: 18px; color-scheme: light; }
.paper h2 { font-size: 22px; color: #1a2230; letter-spacing: .05em; }
.paper .ph { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #2453e6; padding-bottom: 14px; margin-bottom: 14px; }
.paper .orgname { font: 700 17px var(--font-display); color: #2453e6; }
.paper .meta { display: grid; grid-template-columns: auto auto; gap: 2px 14px; text-align: right; }
.paper .meta b { text-align: left; }
.paper .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 10px 0 16px; }
.paper .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6b7588; font-weight: 700; margin-bottom: 2px; }
.paper table th { background: #2453e6; color: #fff; font-size: 10.5px; padding: 7px 8px; border: 0; }
.paper table td { padding: 7px 8px; border-bottom: 1px solid #e8ebf1; color: #1a2230; }
.paper .ptot { display: grid; grid-template-columns: 1fr 300px; gap: 20px; margin-top: 12px; }
.paper .ptot .r { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.paper .ptot .g { font-weight: 800; font-size: 14px; border-top: 1px solid #c8cfdb; margin-top: 4px; padding-top: 6px; }
.paper .bal { background: #fff2e3; padding: 6px 8px; border-radius: 4px; font-weight: 800; }
.paper .foot { display: grid; grid-template-columns: 1fr auto; gap: 20px; margin-top: 22px; align-items: end; }
.paper .sign { text-align: center; border-top: 1px solid #9aa3b2; padding-top: 6px; min-width: 180px; }
.paper .qr { display: flex; gap: 10px; align-items: center; }
.paper .qr .q { width: 92px; height: 92px; }
.paper .qr .q img, .paper .qr .q canvas { width: 92px !important; height: 92px !important; }
.paper .stamp { display: inline-block; border: 2px solid #128046; color: #128046; font-weight: 800; padding: 2px 10px; border-radius: 4px; transform: rotate(-6deg); letter-spacing: .1em; }

/* ---------- reports ---------- */
.report-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.report-list .card-b { display: grid; gap: 2px; }
.report-list button { text-align: left; border: 0; background: none; color: var(--brand); padding: 6px 0; cursor: pointer; font-weight: 650; }
.report-list button:hover { text-decoration: underline; }
.rep { max-width: 1000px; margin: 0 auto; }
.rep-title { text-align: center; padding: 20px 16px 8px; }
.rep-title h2 { font-size: 19px; }
.rep td.lvl1 { padding-left: 30px; }
.rep tr.sec td { font-weight: 750; background: var(--panel-2); }
.rep tr.tot td { font-weight: 750; }
.rep tr.big td { font-weight: 800; font-size: 15px; border-top: 2px solid var(--ink-3); }

/* ---------- modal, popover, toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(7, 12, 24, .55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 16px; animation: fade .15s ease-out; }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(660px, 100%); max-height: 90vh; overflow: auto; animation: rise .2s var(--ease); border: 1px solid var(--line); }
.modal.wide { width: min(900px, 100%); }
.modal.palette { align-self: start; margin-top: 10vh; }
.modal-h { padding: 15px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal-h h3 { font-size: 16.5px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 18px; display: grid; gap: 12px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--panel); }
.pal-list { display: grid; gap: 2px; max-height: 50vh; overflow: auto; }
.pal-list button { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 0; border-radius: 9px; background: none; cursor: pointer; text-align: left; font-weight: 600; }
.pal-list button.on, .pal-list button:hover { background: var(--brand-soft); color: var(--brand); }
.pop { position: fixed; z-index: 70; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); min-width: 270px; max-width: 340px; padding: 6px; animation: rise .15s var(--ease); max-height: 80vh; overflow: auto; }
.pop-h { padding: 10px 12px 6px; font: 700 13px var(--font-display); display: grid; }
.pop-h small { font: 500 12px var(--font-body); color: var(--ink-3); }
.pop-b { padding: 6px 12px 12px; display: grid; gap: 12px; }
.pop-i { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; text-align: left; font-weight: 600; }
.pop-i span { display: grid; }
.pop-i small { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.pop-i:hover, .pop-i.on { background: var(--panel-2); }
.pop-i .tick { margin-left: auto; color: var(--brand); font-weight: 800; }
.pop-sep { height: 1px; background: var(--line-2); margin: 6px 0; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--panel); padding: 11px 15px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 650; animation: rise .22s var(--ease); max-width: 400px; display: flex; gap: 10px; align-items: flex-start; transition: opacity .3s, transform .3s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast .t-ic { width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.bad .t-ic { background: rgba(255,255,255,.25); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.skeleton { background: linear-gradient(90deg, var(--line-2), var(--panel-2), var(--line-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 8px; height: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
:root[data-calm] *, :root[data-calm] *::before, :root[data-calm] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 11px 14px; cursor: pointer; font-weight: 700; color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }

/* ---------- auth & onboarding ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.auth-art { background: radial-gradient(1200px 500px at -10% -10%, #2c5bf0 0, transparent 60%), radial-gradient(800px 400px at 120% 110%, rgba(242,140,27,.55) 0, transparent 60%), var(--side); color: #dfe7f7; padding: 48px 56px; display: flex; flex-direction: column; gap: 18px; justify-content: center; }
.auth-art .brandmark { color: #fff; }
.auth-art h1 { font-size: clamp(28px, 3.4vw, 42px); color: #fff; line-height: 1.12; max-width: 14ch; }
.auth-art p { font-size: 16px; max-width: 46ch; color: #c6d2ea; }
.auth-points { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 10px; }
.auth-points li { padding-left: 28px; position: relative; }
.auth-points li::before { content: "✓"; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.12); color: #8fffbf; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.steps { display: grid; gap: 8px; padding-left: 20px; color: #aebbd6; }
.steps .on { color: #fff; font-weight: 700; }
.auth-card { align-self: center; justify-self: center; width: min(460px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 8px 26px 26px; margin: 32px 0; }
.auth-card form { display: grid; gap: 14px; }
.auth-card h2 { font-size: 21px; margin-top: 6px; }
.brandmark.static { cursor: default; }

/* ---------- print ---------- */
@media print {
  .top, .side, .bottom-bar, .ribbon, .page-head, .crumb, .detail > div:last-child, .toasts, .sticky-actions { display: none !important; }
  .app { display: block; } .main { overflow: visible; } .page { padding: 0; }
  .detail { display: block; } .card { border: 0; box-shadow: none; } .paper { margin: 0; box-shadow: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash, .detail, .hero-empty { grid-template-columns: 1fr; }
  .report-list, .org-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-foot { grid-template-columns: 1fr; }
  .search-btn span { display: none; } .search-btn { flex: 0 0 auto; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56px 1fr auto; }
  .main { grid-column: 1; }
  .top { padding: 0 10px; gap: 8px; }
  .side { position: fixed; top: 0; bottom: 0; left: 0; width: 286px; z-index: 55; transform: translateX(-100%); transition: transform .25s var(--ease); padding-top: 18px; box-shadow: var(--shadow-lg); }
  .app.nav-open .side { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(7,12,24,.5); z-index: 54; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: inline-flex; }
  .brandmark { min-width: 0; }
  .bm-text small, .sync span, .hide-sm, .search-btn kbd { display: none; }
  .bm-text > span { max-width: 120px; }
  .bottom-bar { display: grid; grid-template-columns: repeat(5, 1fr); position: sticky; bottom: 0; background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 30; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-bar button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--ink-3); padding: 6px 0; cursor: pointer; border-radius: 10px; }
  .bottom-bar button.active { color: var(--brand); }
  .bottom-bar .fab { width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); justify-self: center; align-self: center; margin-top: -22px; box-shadow: 0 8px 20px -6px var(--accent); display: grid; place-items: center; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: 16px 14px 40px; }
  .page-head h1 { font-size: 20px; }
  .sticky-actions { margin: 24px -14px -40px; padding: 10px 14px; bottom: 0; }
  .paper { padding: 22px 16px; margin: 8px; }
  .paper .parties, .paper .ptot { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 22px; }
  .auth-art .auth-points, .auth-art .steps { display: none; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tiles, .g2, .g3, .g4, .report-list, .org-grid, .quick-row { grid-template-columns: 1fr; }
  .tiles.kpis, .quick-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2 { grid-column: auto; }
  .tile .value { font-size: 20px; }
  .filters input[type=text] { max-width: none; flex: 1 1 100%; }
  .detail > div:last-child { order: -1; }
  /* tables become stacked cards */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tfoot, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.stack td { border: 0; padding: 4px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.stack td::before { content: attr(data-label); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 750; text-align: left; flex: none; max-width: 45%; }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td:empty { display: none; }
  table.stack td.num { white-space: normal; }
  table.stack .row-actions { justify-content: flex-end; }
  table.stack td[colspan] { display: block; text-align: center; }
  .modal-bg { padding: 0; align-items: end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; width: 100%; }
  .modal.palette { margin-top: 0; align-self: end; }
  .toasts { left: 12px; right: 12px; bottom: 84px; }
  .btn { height: 42px; }
  .btn.sm { height: 34px; }
}
.brandmark.static .bm-text > span { max-width: none; }
