/* BooksBat reports, dashboard and cash flow planner. Solid colours only; chart colours are the --viz-* tokens. */
:root {
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #eda100; --viz-5: #e87ba4;
  --viz-good: #0ca30c; --viz-critical: #d03b3b; --viz-neutral: #b9b8b0;
  --viz-grid: #e1e0d9; --viz-base: #c3c2b7; --viz-axis: #6f6e69; --viz-track: #ecebe6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500; --viz-5: #d55181; --viz-neutral: #6c6b66;
    --viz-grid: #34363f; --viz-base: #4a4c56; --viz-axis: #9a9c94; --viz-track: #34363f; }
}
:root[data-theme="dark"] { --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500; --viz-5: #d55181; --viz-neutral: #6c6b66;
  --viz-grid: #34363f; --viz-base: #4a4c56; --viz-axis: #9a9c94; --viz-track: #34363f; }

/* ---------- charts ---------- */
.viz { position: relative; }
.viz-wrap { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-base { stroke: var(--viz-base); stroke-width: 1; }
.viz-axis { fill: var(--viz-axis); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.viz-hit { fill: transparent; cursor: crosshair; outline: none; }
.viz-group { outline: none; }
.viz-group .viz-hit { cursor: default; }
.viz-group.on .viz-hit, .viz-group:focus-visible .viz-hit { fill: var(--surface-2); }
.viz-group.on .viz-bar { opacity: .85; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { stroke: var(--surface); stroke-width: 2; }
.viz-dot.hidden { display: none; }
.viz-cross { stroke: var(--viz-base); stroke-width: 1; opacity: 0; }
.viz-cross.on { opacity: 1; }
.viz-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; min-width: 140px; opacity: 0; transition: opacity .1s; }
.viz-tip.on { opacity: 1; }
.viz-tip-title { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.viz-tip-row b { font-variant-numeric: tabular-nums; color: var(--text); }
.viz-tip-row span:last-child { color: var(--muted); }
.viz-key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.viz-swatch.line { height: 2px; width: 14px; border-radius: 1px; }
.viz-hbars { display: grid; gap: 10px; }
.viz-hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr 104px; align-items: center; gap: 10px; font-size: 13px; }
.viz-hbar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-hbar-track { height: 10px; background: var(--viz-track); border-radius: 0 4px 4px 0; overflow: hidden; }
.viz-hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.viz-hbar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.viz-stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--viz-track); }
.viz-stack-seg { display: block; min-width: 3px; }
.viz-stack-empty { flex: 1; }
.viz-stack-keys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.viz-stack-key { display: flex; gap: 8px; align-items: flex-start; color: var(--text); text-decoration: none; min-width: 0; }
a.viz-stack-key:hover { text-decoration: none; }
a.viz-stack-key:hover b { text-decoration: underline; }
.viz-stack-key .viz-swatch { margin-top: 5px; }
.viz-stack-text { display: flex; flex-direction: column; min-width: 0; }
.viz-stack-text b { font-size: 15px; font-variant-numeric: tabular-nums; }
.viz-stack-text span { font-size: 12.5px; color: var(--text-2); }
.viz-stack-text small { font-size: 12px; color: var(--muted); }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.dash > .card { padding: 18px; min-width: 0; }
.dash .span-12 { grid-column: span 12; } .dash .span-8 { grid-column: span 8; } .dash .span-7 { grid-column: span 7; } .dash .span-6 { grid-column: span 6; }
.dash .span-5 { grid-column: span 5; } .dash .span-4 { grid-column: span 4; }
.dash-hero { display: flex; flex-direction: column; gap: 4px; }
.dash-hero .big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.dash-delta { font-size: 13px; color: var(--muted); }
.dash-delta.up { color: var(--success); } .dash-delta.down { color: var(--danger); }
.dash-sub { color: var(--muted); font-size: 12.5px; }
.dash-banks { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 2px; }
.dash-banks li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.dash-banks li b { font-variant-numeric: tabular-nums; }
.dash-banks li .muted { font-size: 12px; }
.dash-pl-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.dash-pl-figs div { display: flex; flex-direction: column; }
.dash-pl-figs span { color: var(--muted); font-size: 12.5px; }
.dash-pl-figs b { font-size: 18px; font-variant-numeric: tabular-nums; }
.dash-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dash-two > a, .dash-two > div { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.dash-two > a:hover { text-decoration: none; border-color: var(--border-strong); }
.dash-two span { color: var(--muted); font-size: 12.5px; }
.dash-two b { font-size: 20px; font-variant-numeric: tabular-nums; }
.dash-two small { color: var(--danger); font-size: 12.5px; }
.dash-two small.ok { color: var(--muted); }
.seg-toggle { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.seg-toggle button { border: 0; background: none; font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.seg-toggle button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li { display: flex; gap: 10px; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.dash-list li:first-child { border-top: 0; }
.dash-list time, .dash-list .muted { white-space: nowrap; font-size: 12.5px; }
.dash .kpis { grid-column: span 12; margin: 0; }
.dash-empty { color: var(--muted); font-size: 13.5px; padding: 12px 0; }

/* ---------- report centre ---------- */
.rc-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.rc-bar input[type=search] { flex: 1; min-width: 200px; max-width: 420px; }
.rc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rc-group { padding: 6px 0; }
.rc-group h2 { font-size: 14px; margin: 0; padding: 12px 16px 6px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.rc-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; border-top: 1px solid var(--border); }
.rc-item:first-of-type { border-top: 0; }
.rc-item a.rc-name { flex: 1; min-width: 0; color: var(--text); display: flex; flex-direction: column; }
.rc-item a.rc-name:hover { text-decoration: none; }
.rc-item a.rc-name:hover b { color: var(--accent-text); }
.rc-item b { font-weight: 600; font-size: 14px; }
.rc-item small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.rc-star { border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--muted); display: inline-flex; }
.rc-star:hover { background: var(--surface-2); color: var(--text); }
.rc-star.on { color: var(--viz-4); }
.rc-lock { font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.rc-saved { margin-bottom: 16px; }
.rc-saved .rc-item small .badge { margin-left: 4px; }
.rc-section-title { font-size: 16px; margin: 22px 0 10px; }

/* ---------- report viewer ---------- */
.rv-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; padding: 14px 16px; margin-bottom: 14px; }
.rv-filters .field { margin: 0; min-width: 130px; flex: 0 1 auto; }
.rv-filters .field select, .rv-filters .field input { min-width: 0; width: 100%; }
.rv-filters .rv-more { margin-left: auto; display: flex; gap: 8px; }
.rv-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rv-card { padding: 0; overflow: hidden; }
.rv-head { text-align: center; padding: 22px 16px 14px; border-bottom: 1px solid var(--border); }
.rv-head .co { font-weight: 700; font-size: 15px; }
.rv-head h2 { margin: 2px 0; font-size: 19px; }
.rv-head p { margin: 0; color: var(--muted); font-size: 13px; }
.rv-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.rv-card.loading .rv-scroll { opacity: .5; transition: opacity .15s; }
table.rpt { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.rpt th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); font-weight: 600; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12.5px; z-index: 2; }
table.rpt td { padding: 7px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; color: var(--text); background: var(--surface); }
table.rpt td.wrap { white-space: normal; min-width: 160px; max-width: 320px; }
table.rpt th.num, table.rpt td.num { text-align: right; }
table.rpt td.neg { color: var(--danger); }
table.rpt th:first-child, table.rpt td:first-child { position: sticky; left: 0; z-index: 1; }
table.rpt th:first-child { z-index: 3; }
table.rpt td:first-child { min-width: 180px; max-width: 360px; white-space: normal; box-shadow: inset -1px 0 0 var(--border); }
table.rpt tr.section td { font-weight: 600; }
table.rpt tr.subtotal td, table.rpt tr.total td { font-weight: 600; }
table.rpt tr.subtotal td.num, table.rpt tr.total td.num { box-shadow: inset 0 1px 0 var(--border-strong); }
table.rpt tr.grand td { font-weight: 700; background: var(--surface-2); }
table.rpt tr.grand td.num { box-shadow: inset 0 1px 0 var(--text), inset 0 -3px 0 var(--surface-2), inset 0 -4px 0 var(--text); }
table.rpt tr.hidden { display: none; }
table.rpt a { color: inherit; }
table.rpt td.num a, table.rpt a.drill { color: var(--accent-text); }
table.rpt tr.row:hover td { background: var(--surface-2); }
.rv-toggle { border: 0; background: none; padding: 0 4px 0 0; margin: 0; cursor: pointer; color: var(--muted); vertical-align: -3px; }
.rv-toggle .ic { transition: transform .12s; }
tr.collapsed .rv-toggle .ic { transform: rotate(-90deg); }
.rv-notes { padding: 12px 16px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); }
.rv-notes p { margin: 2px 0; }
.rv-empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.rv-indent-0 { padding-left: 12px !important; }
.rv-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.rv-chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; color: var(--text-2); }
.rv-check { display: grid; gap: 6px; max-height: 200px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }
.rv-check label { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.rv-upgrade { margin-bottom: 14px; }

/* ---------- cash flow planner ---------- */
.cf-tiles { margin-bottom: 14px; }
.cf-chart { padding: 18px; margin-bottom: 14px; }
.cf-controls { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.cf-controls label.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; cursor: pointer; }
.cf-controls .field { margin: 0; }
.cf-controls select { width: auto; }
.cf-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }
.cf-grid > .card { padding: 18px; min-width: 0; }
.cf-items { list-style: none; margin: 0; padding: 0; }
.cf-items li { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.cf-items li:first-child { border-top: 0; }
.cf-items .amt { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.cf-items .amt.in { color: var(--success); }
.cf-items .cf-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-items .cf-lbl small { display: block; color: var(--muted); font-size: 12px; }
.cf-items time { color: var(--muted); font-size: 12.5px; }
.cf-planned li { grid-template-columns: minmax(0, 1fr) auto auto; }
.cf-warn { display: flex; gap: 8px; align-items: center; color: var(--danger); font-size: 13.5px; margin: 0 0 10px; }

@media (max-width: 1100px) {
  .dash .span-8, .dash .span-7, .dash .span-6, .dash .span-5, .dash .span-4 { grid-column: span 12; }
  .cf-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .dash { gap: 10px; }
  .dash > .card { padding: 14px; }
  .dash-hero .big { font-size: 28px; }
  .dash-pl-figs b { font-size: 15px; }
  .viz-stack-keys { grid-template-columns: 1fr 1fr; }
  .viz-axis { font-size: 11px; }
  .cf-planned .cf-lbl { white-space: normal; }
  .rv-filters { padding: 12px; gap: 8px; }
  .rv-filters .field { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }
  .rv-filters .rv-more { margin-left: 0; width: 100%; }
  .rv-filters .rv-more .btn { flex: 1; justify-content: center; }
  table.rpt { font-size: 13px; }
  table.rpt td, table.rpt th { padding: 7px 9px; }
  table.rpt td:first-child { min-width: 150px; max-width: 190px; }
  .rc-grid { grid-template-columns: 1fr; }
  .cf-items li { grid-template-columns: 74px minmax(0, 1fr) auto; }
  .rv-head h2 { font-size: 17px; }
}
