/* FD Suite - light/dark themes. Chart palette = validated dataviz reference palette. */
:root {
  color-scheme: light;
  --page: #f4f4f1; --surface: #fcfcfb; --surface-2: #f0efec; --surface-3: #e8e7e2;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,0.10); --border-strong: rgba(11,11,11,0.18);
  --accent: #2a78d6; --accent-ink: #ffffff; --accent-soft: rgba(42,120,214,0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --bad: #d03b3b;
  --good-ink: #006300; --bad-ink: #b42323; --warn-ink: #8a5a00;
  --good-soft: rgba(12,163,12,0.12); --warn-soft: rgba(250,178,25,0.18); --bad-soft: rgba(208,59,59,0.12);
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
  --radius: 10px; --sidebar: 236px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10); --border-strong: rgba(255,255,255,0.18);
  --accent: #3987e5; --accent-soft: rgba(57,135,229,0.16);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-ink: #0ca30c; --bad-ink: #e66767; --warn-ink: #fab219;
  --good-soft: rgba(12,163,12,0.18); --warn-soft: rgba(250,178,25,0.16); --bad-soft: rgba(208,59,59,0.20);
  --shadow: 0 1px 2px rgba(0,0,0,0.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .ink2 { color: var(--ink-2); }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.hidden, [hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: -0.5px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; background: #fff; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { padding: 4px 10px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }

/* collapsible sidebar: icon strip */
.app { transition: grid-template-columns 0.18s ease; }
.icon-btn { padding: 6px; margin-left: -6px; }
.icon-btn svg { width: 18px; height: 18px; }
:root[data-sidebar="collapsed"] { --sidebar: 60px; }
:root[data-sidebar="collapsed"] .sidebar { overflow-x: hidden; scrollbar-width: none; }
:root[data-sidebar="collapsed"] .sidebar::-webkit-scrollbar { display: none; }
.brand-mark { flex: none; }
:root[data-sidebar="collapsed"] .brand { padding: 18px 15px 14px; }
:root[data-sidebar="collapsed"] .brand > div:last-child,
:root[data-sidebar="collapsed"] .nav a span,
:root[data-sidebar="collapsed"] .sidebar-foot { display: none; }
:root[data-sidebar="collapsed"] .nav { padding: 4px 8px 16px; }
:root[data-sidebar="collapsed"] .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
:root[data-sidebar="collapsed"] .nav-group:first-child { border-top: 0; padding-top: 0; }
:root[data-sidebar="collapsed"] .nav-group-title { display: none; }
:root[data-sidebar="collapsed"] .nav a { justify-content: center; padding: 9px 0; }
:root[data-sidebar="collapsed"] .nav a svg { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .app { transition: none; } }

/* AI assistant panel (right-hand side). On wide screens the page narrows to make room. */
:root { --ai-w: 420px; }
.ai-panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--ai-w); max-width: 100vw; z-index: 40; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,0.08); }
.ai-panel[hidden] { display: none; }
.ai-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--border); }
.ai-head .spacer { flex: 1; }
.ai-title { font-weight: 700; font-size: 15px; }
.ai-note { font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); padding: 8px 18px; border-bottom: 1px solid var(--border); }
.ai-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.ai-body .banner { margin: 0; }
.ai-suggest { display: grid; gap: 8px; }
.ai-chip { text-align: left; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 9px 12px; cursor: pointer; font-size: 13px; color: var(--ink); }
.ai-chip:hover { background: var(--surface-2); }
.ai-msg.user { display: flex; justify-content: flex-end; }
.ai-bubble { background: var(--accent-soft); color: var(--ink); border-radius: 12px 12px 2px 12px; padding: 8px 12px; max-width: 88%; font-size: 13.5px; }
.ai-answer { font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.ai-answer p { margin: 0 0 8px; }
.ai-answer h4 { margin: 12px 0 6px; font-size: 13.5px; }
.ai-answer ul, .ai-answer ol { margin: 0 0 8px; padding-left: 20px; }
.ai-answer li { margin-bottom: 3px; }
.ai-answer li > ul, .ai-answer li > ol { margin: 3px 0 4px; }
.ai-answer code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: 12.5px; }
.ai-answer .table-wrap { margin: 6px 0 10px; }
.ai-typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: aiDot 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: 0.15s; } .ai-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-typing i { animation: none; opacity: 0.6; } }
.ai-form { border-top: 1px solid var(--border); padding: 12px 18px 16px; display: grid; gap: 8px; }
.ai-form textarea { width: 100%; resize: vertical; min-height: 64px; max-height: 40vh; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; background: var(--page); font-size: 13.5px; }
.ai-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ai-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ai-statement { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 8px; padding: 10px 12px; }
#aiBtn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
@media (min-width: 1100px) { :root[data-ai="open"] .main { margin-right: var(--ai-w); } }
@media (max-width: 520px) { :root { --ai-w: 100vw; } }
@media print { .ai-panel { display: none !important; } }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 10px 24px; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.topbar .company { font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.status-dot.live { background: var(--good); } .status-dot.snap { background: var(--warn); } .status-dot.err { background: var(--bad); }
.content { padding: 22px 24px 60px; max-width: 1880px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- controls ---------- */
.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
select, input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 9px; font-size: 13px; }
input[type=number] { width: 110px; }
textarea { width: 100%; min-height: 80px; resize: vertical; }
select:focus, input:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-size: 12.5px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 20px; transition: 0.15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.equal > * > .card { height: 100%; } /* side-by-side cards share the row height */
.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: span 3; } .spanall { grid-column: 1 / -1; }
@media (max-width: 1150px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span3 { grid-column: span 2; } }
@media (max-width: 760px) { .app { grid-template-columns: 1fr !important; } .sidebar { position: static; height: auto; } :root[data-sidebar="collapsed"] .nav { display: none; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.section-gap { margin-top: 16px; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tile-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.tile-foot { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile svg.spark { width: 100%; height: 34px; margin-top: 4px; }
.delta-up { color: var(--good-ink); } .delta-down { color: var(--bad-ink); }

/* status chips (icon + label, never colour alone) */
.rag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 20px; white-space: nowrap; }
.rag::before { font-size: 10px; }
.rag.good { background: var(--good-soft); color: var(--good-ink); } .rag.good::before { content: "●"; }
.rag.watch { background: var(--warn-soft); color: var(--warn-ink); } .rag.watch::before { content: "▲"; }
.rag.action { background: var(--bad-soft); color: var(--bad-ink); } .rag.action::before { content: "■"; }
.rag.na { background: var(--surface-2); color: var(--muted); } .rag.na::before { content: "–"; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
table.t th.num { text-align: right; } /* headings sit over right-aligned figures */
table.t td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr.sub td { font-weight: 600; background: var(--surface-2); }
table.t tr.total td { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 2px solid var(--border-strong); }
table.t tr.head td { font-weight: 600; color: var(--ink-2); padding-top: 12px; }
table.t tr.ratio td { font-style: italic; color: var(--ink-2); }
table.t td.indent { padding-left: 22px; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.t input[type=number] { width: 92px; padding: 3px 6px; text-align: right; }
table.t.compact td, table.t.compact th { padding: 4px 6px; }
.neg { color: var(--bad-ink); }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .lbl { fill: var(--ink-2); font-size: 11px; }
.chart .lbl-strong { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hover-line { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.legend i.dash { height: 0; border-top: 2px dashed; width: 14px; border-radius: 0; background: none !important; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); box-shadow: 0 4px 16px rgba(0,0,0,0.15); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 120px; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }

/* sliders (planner) */
.slider-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.slider-row:last-child { border-bottom: 0; }
.slider-row .s-label { font-size: 13px; }
.slider-row .s-val { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; text-align: right; min-width: 70px; }
.slider-row input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.slider-row .s-hint { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.headline b { font-weight: 600; }
.module-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.module-toggle:last-child { border-bottom: 0; }
.module-toggle .mt-desc { font-size: 12px; color: var(--muted); }
/* report pack: re-orderable contents */
.pk-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); background: var(--surface); }
.pk-row:last-child { border-bottom: 0; }
.pk-row .module-toggle { flex: 1; border-bottom: 0; cursor: pointer; min-width: 0; }
.pk-grip { flex: none; width: 28px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: grab; border-radius: 6px; touch-action: none; padding: 0; }
.pk-grip:hover, .pk-grip:focus-visible { color: var(--ink); background: var(--surface-2); }
.pk-grip svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.pk-num { flex: none; width: 22px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); font-size: 13px; }
.pk-row.off .module-toggle > div { opacity: 0.55; }
.pk-move { flex: none; display: flex; flex-direction: column; }
.pk-move .btn { padding: 0 6px; font-size: 9px; line-height: 16px; color: var(--muted); }
.pk-move .btn:hover { color: var(--ink); }
.pk-list.sorting { cursor: grabbing; user-select: none; }
.pk-list.sorting .pk-grip { cursor: grabbing; }
.pk-row.dragging { position: relative; z-index: 2; box-shadow: 0 4px 16px rgba(0,0,0,0.18); border-radius: 8px; outline: 2px solid var(--accent); }

/* notes / commentary */
.notes { margin-top: 16px; }
.notes textarea { min-height: 70px; }
.notes .saved { font-size: 11px; color: var(--muted); }

/* banners & toasts */
.print-only { display: none; }
.banner { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner.error { background: var(--bad-soft); border-color: transparent; }
.banner.ok { background: var(--good-soft); border-color: transparent; }
.toast-wrap { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--page); padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); max-width: 380px; }
.toast.error { background: var(--bad); color: #fff; }

/* connector cards */
.conn-card { display: flex; flex-direction: column; gap: 10px; }
.conn-logo { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; }

/* progress bullet */
.bullet { position: relative; height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bullet > .bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--s1); }
.bullet > .mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }

.dl-row { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(200px, 2fr) auto; gap: 10px; align-items: end; margin-bottom: 8px; }
.dl-row input, .dl-row select { width: 100%; }

.pk-queries { margin-top: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.pk-queries summary { cursor: pointer; font-weight: 600; }
.pk-queries .ai-answer { margin-top: 6px; }

/* company details form */
.ch-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.ch-field.wide { grid-column: 1 / -1; }
.ch-field input, .ch-field select, .ch-field textarea { width: 100%; }
.ch-field textarea { min-height: 56px; }
.ch-yearend { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.ch-field.overridden input, .ch-field.overridden select, .ch-field.overridden textarea { border-color: var(--accent); }
.ch-diff { font-size: 12px; color: var(--ink-2); margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ch-diff[hidden] { display: none; }
[data-client][hidden] { display: none; }

/* report pack: the page that builds it */
.pk-versions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.pk-version { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; }
.pk-version input { margin-top: 3px; flex: none; }
.pk-version.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pk-version .t1 { font-weight: 600; }
.pk-version .t2 { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.pk-ai { margin-bottom: 16px; }
.pk-ai-accept { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; margin: 12px 0; }
.pk-ai-accept input { margin-top: 3px; flex: none; }
.pk-draft { border-top: 1px solid var(--border); padding: 14px 0; }
.pk-draft:last-child { padding-bottom: 0; }
.pk-draft-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pk-draft-head .ttl { font-weight: 600; flex: 1; min-width: 160px; }
.pk-draft textarea { width: 100%; min-height: 150px; font: inherit; font-size: 13px; line-height: 1.5; }
.pk-draft .pk-approve { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; }

/* report pack: the printed document (fixed colours, whichever theme the app is in) */
.pack-src .grid { display: block !important; }
.pack-src .card { padding: 0; border: 0; box-shadow: none; }
.print-root { display: none; }
.pk-doc { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; line-height: 1.38; color: #1A1A1A; }
.pk-doc * { box-sizing: border-box; }
.pk-page { position: relative; width: 210mm; height: 296.8mm; overflow: hidden; background: #fff; page-break-after: always; break-after: page; }
.pk-page:last-child { page-break-after: auto; break-after: auto; }
.pkp-header { position: absolute; left: 20mm; right: 20mm; top: 10mm; padding-bottom: 5px; border-bottom: 1px solid #C9D1DC; text-align: right; font-size: 8.5pt; line-height: 1.2; color: #5A6475; }
.pkp-footer { position: absolute; left: 20mm; right: 20mm; bottom: 10mm; text-align: center; font-size: 8.5pt; line-height: 1.2; color: #5A6475; }
.pkp-body { position: absolute; left: 20mm; right: 20mm; top: 20mm; bottom: 20mm; display: flex; flex-direction: column; align-items: stretch; }
.pk-doc .pkp-muted { color: #5A6475; }
.pk-doc .pkp-h1 { margin: 0 0 13px; padding-bottom: 8px; border-bottom: 1.5px solid #2A9D8F; font-size: 16pt; line-height: 1.2; font-weight: 700; color: #1F3A5F; letter-spacing: 0; }
.pk-doc .pkp-h2 { margin: 16px 0 6px; font-size: 12pt; line-height: 1.25; font-weight: 700; color: #1F3A5F; letter-spacing: 0; }
.pk-doc .pkp-h3 { margin: 11px 0 5px; font-size: 10.5pt; line-height: 1.25; font-weight: 700; color: #2A9D8F; letter-spacing: 0; }
.pk-doc .pkp-p { margin: 0 0 7px; }
.pk-doc .pkp-cap { margin: 0 0 6px; font-size: 8.5pt; line-height: 1.25; font-style: italic; color: #5A6475; }
.pk-doc .pkp-cap.plain { font-style: normal; }
.pkp-bullet { display: flex; gap: 8px; margin: 0 0 5px 5px; }
.pkp-bullet .dot { flex: none; }
.pkp-bullet > div { flex: 1; min-width: 0; }
.pkp-tablewrap { margin: 0 0 11px; flex: none; }
.pk-doc .pkp-table { width: 100%; border-collapse: collapse; table-layout: fixed; line-height: 1.2; color: #1A1A1A; }
.pk-doc .pkp-table th, .pk-doc .pkp-table td { padding: 3.3px var(--pkp-pad, 6px); border-top: 1px solid #C9D1DC; border-bottom: 1px solid #C9D1DC; text-align: left; vertical-align: middle; overflow-wrap: anywhere; background: #fff; font-size: inherit; color: inherit; font-weight: 400; white-space: normal; position: static; text-transform: none; letter-spacing: 0; }
.pk-doc .pkp-table th.num, .pk-doc .pkp-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pk-doc .pkp-table td.indent { padding-left: calc(var(--pkp-pad, 6px) * 2); }
.pk-doc .pkp-table .k-header th { background: #1F3A5F; color: #fff; font-weight: 700; border-color: #1F3A5F; }
.pk-doc .pkp-table .k-head td { background: #EEF2F7; font-weight: 700; }
.pk-doc .pkp-table .k-sub td { background: #F5F7FA; font-weight: 700; border-top: 1px solid #1F3A5F; }
.pk-doc .pkp-table .k-total td { background: #D6DEE9; font-weight: 700; border-top: 1px solid #1F3A5F; border-bottom: 3px double #1F3A5F; }
.pk-doc .pkp-table .k-ratio td { font-style: italic; }
.pkp-tiles { display: flex; gap: 4px; margin: 0 0 8px; }
.pkp-tile { border-top: 3px solid #2A9D8F; background: #EEF2F7; padding: 9px 4px; text-align: center; min-width: 0; line-height: 1.22; }
.pkp-tile .v { font-size: 15pt; font-weight: 700; color: #1F3A5F; }
.pkp-tile .l { font-size: 8.5pt; font-weight: 700; margin-top: 2px; }
.pkp-tile .f { font-size: 7.5pt; color: #5A6475; }
.pkp-tile .s { font-size: 7.5pt; font-weight: 700; margin-top: 1px; }
.pkp-chart { margin: 3px 0 11px; flex: none; }
.pkp-chart svg { display: block; width: 100%; height: auto; }
.pkp-toc { display: flex; align-items: baseline; gap: 6px; text-decoration: none; color: #1A1A1A; font-size: 9pt; line-height: 1.25; margin: 0 0 2px 12px; }
.pkp-toc i { flex: 1; border-bottom: 1px dotted #8A94A6; transform: translateY(-3px); }
.pkp-toc b { font-weight: 400; }
.pkp-toc.l1 { font-size: 10pt; font-weight: 700; color: #1F3A5F; margin: 7px 0 3px; }
.pkp-toc.l1 b { font-weight: 700; }
.pkp-cover { padding-top: 30mm; }
.pkp-cover .logo { display: block; max-height: 60px; max-width: 220px; object-fit: contain; margin-bottom: 18mm; }
.pkp-cover .eyebrow { font-size: 14pt; font-weight: 700; color: #2A9D8F; text-transform: uppercase; }
.pkp-cover .name { font-size: 32pt; line-height: 1.15; font-weight: 700; color: #1F3A5F; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 2px solid #2A9D8F; }
.pkp-cover .period { font-size: 18pt; color: #1F3A5F; }
.pkp-cover .sub { font-size: 11pt; color: #5A6475; margin-top: 8px; }
.pk-doc .pkp-cover .rows { width: 100%; border-collapse: collapse; margin-top: 34mm; font-size: 10.5pt; }
.pk-doc .pkp-cover .rows th, .pk-doc .pkp-cover .rows td { padding: 4.5px 7px; border-top: 1px solid #C9D1DC; border-bottom: 1px solid #C9D1DC; text-align: left; vertical-align: top; font-size: inherit; color: #1A1A1A; background: #fff; white-space: normal; text-transform: none; letter-spacing: 0; }
.pk-doc .pkp-cover .rows th { width: 33%; font-weight: 700; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; margin: 0; padding: 0; }
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; }
  .pk-doc, .pk-doc * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-notes { display: none; white-space: pre-wrap; }

/* ---------- sign-in (Phase 5) ---------- */
.signin-root { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--page); }
.signin-card { width: min(440px, 100%); padding: 28px 30px; }
.signin-card h1 { font-size: 20px; margin: 18px 0 10px; }
.signin-card p { color: var(--ink-2); margin: 0 0 12px; }
.signin-brand { display: flex; align-items: center; gap: 10px; }
.signin-form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.signin-form input { width: 100%; padding: 9px 10px; font-size: 15px; }
.signin-form .btn.primary { justify-content: center; padding: 9px 12px; font-size: 14px; }
.signin-msg { min-height: 1.3em; color: var(--bad-ink); font-size: 13px; }
.signin-msg.ok { color: var(--good-ink); }
.signin-steps { padding-left: 18px; color: var(--ink-2); }
.signin-steps li { margin-bottom: 10px; }
.signin-qr { margin: 10px 0; background: #fff; display: block; width: max-content; padding: 6px; border-radius: 8px; }
.signin-qr svg { display: block; width: 180px; height: 180px; }
.signin-key { font-size: 13px; letter-spacing: 0.04em; user-select: all; }

/* ---------- team and AUXIMA admin (Phase 5) ---------- */
.invite-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 6px 0; }
.invite-form .field { min-width: 260px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.access-editor { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 8px; }
.access-staff { display: grid; gap: 4px; padding-left: 22px; }
.card + .card { margin-top: 14px; }
/* An AUXIMA admin without a firm has no clients: hide the client controls */
body.admin-only #clientSelect, body.admin-only #sourceDot, body.admin-only #sourceText,
body.admin-only label[for="periodSelect"], body.admin-only #periodSelect, body.admin-only #refreshBtn, body.admin-only #aiBtn { display: none; }
.access-editor .btn { justify-self: start; }
