/* ==========================================================================
   SYMMETRA reports — the report toolbar and the statement sheet (P&L, balance
   sheet, cash flow, actual vs budget, trial balance, general ledger), single
   period and comparative, solo and group, screen and print.

   Statement typography: fixed sizes (14px lines on desktop, 13px on phones),
   tabular figures on every amount, negatives in red, subtotals flat with a top
   rule, final totals with the accounting double underline. The label column
   stays sticky while amounts scroll, so no amount is ever hidden.
   ========================================================================== */

@layer reports {

  .report-page-stack, .report-workspace { display: flex; flex-direction: column; gap: var(--space-4); }

  /* --------------------------------------------------------------- toolbar */
  .report-filter-bar, .report-toolbar-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-1), var(--inner-highlight);
    padding: var(--space-3);
  }
  .report-toolbar, .rtb {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) minmax(0, .8fr) minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: var(--space-2-5);
    align-items: end;
  }
  .rtb-group { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
  .rtb-kicker {
    font-size: var(--text-2xs); font-weight: var(--fw-semibold); color: var(--muted);
    letter-spacing: var(--tracking-caps); text-transform: uppercase; line-height: 16px;
  }
  .rtb-row { display: flex; gap: var(--space-1-5); min-width: 0; }
  .rtb-row > select, .rtb-select, .rtb-input { width: 100%; min-width: 0; height: var(--control-md); }
  .rtb-group--compare .rtb-row > select { flex: 1 1 0; }
  .rtb-actions { display: flex; align-items: center; gap: var(--space-1-5); }
  .rtb-actions-spacer { display: none; }
  .report-custom-dates {
    display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
    margin-top: var(--space-3); padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--text-xs); color: var(--muted);
  }
  .report-custom-dates > span { font-weight: var(--fw-semibold); color: var(--text-2); }
  .report-custom-dates label { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--muted); }
  .report-custom-dates input { width: 150px; }
  @media (max-width: 1100px) {
    .report-toolbar, .rtb { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
  }
  @media (max-width: 640px) {
    .report-toolbar, .rtb { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rtb-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .report-custom-dates label { flex: 1 1 140px; }
    .report-custom-dates input { width: 100%; }
  }

  /* older scope bar (company/group pickers above some reports) */
  .report-scope, .report-scope-shell { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
  .report-scope__group { display: flex; flex-direction: column; gap: var(--space-1); }
  .report-scope__kicker { font-size: var(--text-2xs); font-weight: var(--fw-semibold); color: var(--muted); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
  .report-scope__actions { margin-left: auto; display: flex; gap: var(--space-2); }

  /* ------------------------------------------------------------ the sheet */
  .report-wrap {
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-1), var(--inner-highlight);
    padding: var(--space-6) var(--space-6) var(--space-5);
    min-width: 0;
  }
  .report-wrap[data-compare-count="1"] { max-width: 1040px; }
  .report-wrap[data-compare-count="2"], .report-wrap[data-compare-count="3"] { max-width: 1200px; }
  .report-wrap[data-compare-count]:not([data-compare-count="0"]):not([data-compare-count="1"]):not([data-compare-count="2"]):not([data-compare-count="3"]),
  .report-wrap[data-report-type="bva"], .report-wrap[data-report-type="gl"], .report-wrap[data-report-type="tb"] { max-width: none; }

  .report-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
  }
  .report-title-block { min-width: 0; max-width: 100%; display: flex; flex-direction: column; gap: var(--space-1); }
  .report-title, .report-title-row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
  .report-title, .report-entity-print {
    font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-tighter); color: var(--text);
  }
  select.report-entity-select {
    height: auto;
    max-width: 100%;
    padding: 0 26px 0 0;
    border: 0; border-radius: var(--radius-sm);
    background-color: transparent;
    background-position: right 4px center;
    background-size: 14px;
    font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-tighter); color: var(--text);
    box-shadow: none;
    text-overflow: ellipsis;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }
  select.report-entity-select:hover { background-color: var(--surface-2); }
  select.report-entity-select:focus { box-shadow: var(--focus-ring); }
  .report-entity-print { display: none; }
  .report-subtitle {
    font-size: var(--text-2xs); font-weight: var(--fw-semibold); color: var(--text-2);
    letter-spacing: .09em; text-transform: uppercase;
  }
  .report-date { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
  .report-date-sep { color: var(--border-strong); margin: 0 6px; }
  .report-head-meta { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2); flex: none; }
  .report-export-actions { display: inline-flex; gap: var(--space-1); }
  .report-export-actions .btn, .report-export-btn { width: 30px; height: 30px; padding: 0; }
  .office-export-icon {
    display: inline-block;
    width: var(--export-icon-size, 18px); height: var(--export-icon-size, 18px);
    background: center / contain no-repeat;
  }
  .report-export-btn .office-export-icon { --export-icon-size: 17px !important; width: 17px; height: 17px; }
  .office-export-icon--word { background-image: url("../assets/export-word-icon.png"); }
  .office-export-icon--excel { background-image: url("../assets/export-excel-icon.png"); }
  .office-export-icon--pdf { background-image: url("../assets/export-pdf-icon.png"); }
  .report-freshness { font-variant-numeric: tabular-nums; }
  .report-company-logo, .report-logo-slot img { max-height: 40px; width: auto; }

  /* in-sheet notices (mapping gate, stale-mapping banner, readiness) */
  .report-wrap > .panel, .report-wrap .notice, .report-wrap .mapping-status {
    margin: var(--space-3) 0; box-shadow: none; border-radius: var(--radius-md);
  }

  /* scroll container: label column sticky, amounts scroll */
  .report-table-viewport {
    position: relative;
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    margin-top: var(--space-2);
  }
  .report-table-viewport:focus-visible { outline: 2px solid var(--focus-border); outline-offset: 2px; border-radius: var(--radius-sm); }
  .report-top-scroll { overflow-x: auto; height: 12px; margin-top: var(--space-2); }
  .report-top-scroll__inner { height: 1px; }

  /* ----------------------------------------------------- statement table */
  table.report, table.report-bs, table.bva-report, table.cashflow-report-table, table.bva-compare-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-md);
    line-height: 20px;
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum", "lnum", "cv11";
    color: var(--text);
  }
  table.report thead th, table.bva-report thead th, table.cashflow-report-table thead th, table.bva-compare-table thead th {
    height: 34px;
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--rule-total);
    background: var(--surface);
    color: var(--muted);
    font-size: var(--text-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
    vertical-align: bottom;
    padding-bottom: 8px;
  }
  table.report thead th.right, table.report thead th.bs-header-amount { text-align: right; }
  table.report td, table.bva-report td, table.cashflow-report-table td, table.bva-compare-table td {
    height: 32px;
    padding: 6px var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface);
    vertical-align: middle;
  }
  table.report td.right, table.bva-report td.right, table.cashflow-report-table td.right, table.bva-compare-table td.right {
    text-align: right; white-space: nowrap; min-width: 112px; color: var(--amount);
  }
  table.report td:first-child, table.report th:first-child,
  table.bva-report td:first-child, table.bva-report th:first-child,
  table.cashflow-report-table td:first-child, table.cashflow-report-table th:first-child {
    position: sticky; left: 0; z-index: 1;
    padding-left: var(--space-2);
  }
  table.report-multi td:first-child, table.bva-report td:first-child { min-width: 220px; max-width: 360px; }
  table.report tbody tr:hover td, table.bva-report tbody tr:hover td, table.cashflow-report-table tbody tr:hover td { background: var(--row-hover); }
  tr.report-line-clickable { cursor: pointer; }
  tr.report-line-clickable:hover td:first-child { color: var(--accent-fg); }

  /* item lines under a heading */
  table.report td.indent, table.report td.bs-line-name, .bva-report td.indent, .cashflow-report-table td.indent {
    padding-left: calc(var(--space-2) + 20px);
    color: var(--text-2);
    font-weight: var(--fw-regular);
  }
  table.report td.indent-2, table.report td.indent2 { padding-left: calc(var(--space-2) + 40px); }

  /* section headings: REVENUE, ASSETS, OPERATING ACTIVITIES */
  tr.pnl-group-row td, tr.bs-group-row td, tr.bva-subhead td, tr.report-group-section td {
    height: 40px;
    padding-top: 16px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: var(--text-2xs);
    font-weight: var(--fw-bold);
    letter-spacing: .08em;
    text-transform: uppercase;
    background: var(--surface);
  }
  tbody tr.pnl-group-row:first-child td, tbody tr.bs-group-row:first-child td { padding-top: 10px; height: 32px; }
  /* sub-headings: Current assets, Equity */
  tr.bs-subsection-row td, tr.section-row td, tr.bud-section-total td {
    font-weight: var(--fw-semibold);
    color: var(--text);
  }
  tr.section-row[data-toggle] td:first-child::before, tr.section-row[onclick] td:first-child::before {
    content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 8px 2px 0;
    border-right: 1.5px solid var(--subtle); border-bottom: 1.5px solid var(--subtle);
    transform: rotate(45deg); vertical-align: middle;
  }
  tr.section-row.collapsed td:first-child::before, tr.section-row.is-collapsed td:first-child::before { transform: rotate(-45deg); }

  /* subtotals: Total revenue, Gross profit, Total current assets */
  tr.total-row td, tr.bs-subtotal td, tr.bud-subtotal td, tr.breakdown-total td, tr.report-row--summary-soft td,
  tr.report-row--summary-blue td, tr.report-row--summary-green td {
    font-weight: var(--fw-semibold);
    color: var(--text);
    background: var(--row-subtotal);
    border-top: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border);
  }
  tr.total-row.heavy td, tr.bs-subtotal td { font-weight: var(--fw-semibold); }
  /* final totals: Profit for the period, Total assets, Total liabilities and equity */
  tr.pnl-final td, tr.bs-total-row td, tr.report-row--closing-balance td {
    font-weight: var(--fw-bold);
    color: var(--text);
    background: var(--row-total);
    border-top: 1px solid var(--rule-total);
    border-bottom: 3px double var(--rule-total);
  }
  tr.cf-opening td, tr.report-row--opening-balance td { font-weight: var(--fw-semibold); background: var(--row-subtotal); }
  tbody tr + tr.pnl-final td, tbody tr + tr.bs-total-row td { }
  tr.total-row + tr.total-row td { border-top-color: var(--border); }
  .bs-subtotal-label { font-weight: var(--fw-semibold); }
  .bs-balance-check { margin-top: var(--space-3); font-size: var(--text-xs); color: var(--muted); }
  .bs-toggle {
    display: inline-block; width: 6px; height: 6px; margin: 0 10px 2px 2px;
    border-right: 1.5px solid var(--subtle); border-bottom: 1.5px solid var(--subtle);
    transform: rotate(45deg); vertical-align: middle; transition: transform var(--dur-2);
  }
  .bs-toggle.is-collapsed { transform: rotate(-45deg); }
  tr.bs-subsection-row { cursor: pointer; }

  /* negatives everywhere in statements (set by the renderer / applyReportAmountColors) */
  table.report td.is-negative, table.bva-report td.is-negative, table.cashflow-report-table td.is-negative,
  .report-wrap td.right.is-negative { color: var(--amount-negative); }
  tr.pnl-final td.is-negative, tr.bs-total-row td.is-negative, tr.total-row td.is-negative { color: var(--amount-negative); }

  /* actual vs budget */
  .bva-scroll-shell, .bva-compare-scroll { width: 100%; overflow-x: auto; }
  .bva-period-head { text-align: center; border-bottom: 1px solid var(--border); }
  .bva-name-col { min-width: 220px; }
  .bva-top-scroll { overflow-x: auto; height: 12px; }
  .bva-top-scroll__inner { height: 1px; }
  .budget-report-basis { font-size: var(--text-xs); color: var(--muted); margin: var(--space-2) 0; }
  td.var-fav, .variance-fav, .bva-fav { color: var(--amount-positive-delta); }
  td.var-unfav, .variance-unfav, .bva-unfav { color: var(--amount-negative); }

  /* trial balance / GL inside the sheet use the grid table */
  .report-wrap table.grid { font-size: var(--text-sm); }
  .report-wrap table.grid td.right { font-variant-numeric: tabular-nums; }
  .report-wrap .table-scroll { border-radius: var(--radius-md); }
  .gl-report-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }

  /* smart summary / KPIs above a report */
  .rss-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); margin: var(--space-3) 0; }
  .rss-kpi { padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
  .rss-kpi__label { font-size: var(--text-2xs); color: var(--muted); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
  .rss-kpi__value { font-size: var(--text-lg); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
  .rss-kpi__delta { font-size: var(--text-xs); color: var(--muted); }
  .rss-kpi__delta--up { color: var(--amount-positive-delta); }
  .rss-kpi__delta--down { color: var(--amount-negative); }
  .report-smart-summary { font-size: var(--text-sm); color: var(--text-2); }

  /* --------------------------------------------------------- responsive */
  @media (max-width: 900px) {
    .report-wrap { padding: var(--space-4); }
    .report-head { flex-direction: column; align-items: stretch; gap: var(--space-3); }
    .report-head-meta { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; }
  }
  @media (max-width: 640px) {
    .report-wrap { padding: var(--space-4) var(--space-3); border-radius: var(--radius-md); }
    select.report-entity-select, .report-title { font-size: var(--text-xl); line-height: var(--lh-xl); }
    table.report, table.bva-report, table.cashflow-report-table { font-size: var(--text-sm); }
    table.report td, table.bva-report td, table.cashflow-report-table td { padding: 6px var(--space-2); }
    table.report td.right { min-width: 96px; }
    table.report td:first-child { max-width: 52vw; white-space: normal; }
    table.report td.indent, table.report td.bs-line-name { padding-left: calc(var(--space-2) + 12px); }
    .report-table-viewport.is-scrolled table.report td:first-child { box-shadow: 6px 0 8px -8px rgba(16, 24, 40, .25); }
  }
}

/* ---------------------------------------------------------------- print */
@layer print {
  @media print {
    @page { margin: 14mm 12mm; }
    html, body { background: #fff !important; color: #000 !important; }
    :root, :root[data-theme="dark"] {
      --surface: #fff; --surface-2: #fff; --row-subtotal: #fff; --row-total: #fff; --row-hover: #fff;
      --text: #000; --text-2: #111; --muted: #444; --border: #bbb; --border-subtle: #ddd; --border-strong: #888;
      --rule-total: #000; --amount-negative: #000;
    }
    .sidebar, .report-filter-bar, .report-toolbar-shell, .no-print, .sym-mnav-toggle, #sym-copilot-fab, #sym-copilot-panel,
    .toast-viewport, .page-head .actions, .report-head-meta, .report-top-scroll { display: none !important; }
    .app { display: block; }
    .main { padding: 0; }
    .report-wrap { max-width: none !important; border: 0; box-shadow: none; padding: 0; }
    .report-entity-print { display: inline; }
    select.report-entity-select { display: none; }
    .report-table-viewport { overflow: visible; }
    table.report, table.bva-report, table.cashflow-report-table { font-size: 9.5pt; }
    table.report td, table.bva-report td { height: auto; padding: 3pt 6pt; }
    table.report td:first-child { position: static; box-shadow: none; }
    tr { break-inside: avoid; }
    table.report td.is-negative { color: #000; }
  }
}

/* ------------------------------------------------- financial statements (full set) + server BvA */
@layer reports {
  .fs-bar { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-subtle); }
  .fs-bar__field { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-2xs); color: var(--muted); font-weight: var(--fw-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
  .fs-bar__field select { min-width: 190px; text-transform: none; letter-spacing: 0; }
  .fs-bar__check { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-md); font-size: var(--text-sm); color: var(--text-2); }
  .fs-bar__spacer { flex: 1; }

  .fs-summary { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) 0 var(--space-2); }
  .fs-summary__title { font-size: var(--text-md); font-weight: var(--fw-semibold); color: var(--text); }
  .fs-checks { position: relative; max-width: 100%; }
  .fs-checks > summary { list-style: none; cursor: pointer; }
  .fs-checks > summary::-webkit-details-marker { display: none; }
  .fs-checks ul { position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-dropdown); width: min(520px, 86vw); margin: 0; padding: var(--space-2); list-style: none; display: grid; gap: 2px;
    background: var(--surface-overlay, var(--surface)); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--elev-3); }
  .fs-check-item { display: flex; gap: var(--space-2); padding: 6px var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); line-height: var(--lh-xs); }
  .fs-check-item--ok > span:first-child { color: var(--success-fg); }
  .fs-check-item--fail { background: var(--danger-soft); }
  .fs-check-item--fail > span:first-child { color: var(--danger-fg); font-weight: var(--fw-bold); }
  .fs-check { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); font-size: var(--text-2xs); font-weight: var(--fw-medium); border: 1px solid; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fs-check--ok { border-color: var(--success-line); background: var(--success-soft); color: var(--success-fg); }
  .fs-check--fail { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger-fg); }

  .fs-warnings { margin: var(--space-2) 0; padding: var(--space-2) var(--space-3); border: 1px solid var(--warning-line); background: var(--warning-soft); color: var(--warning-fg); border-radius: var(--radius-md); font-size: var(--text-sm); }
  .fs-warnings summary { cursor: pointer; font-weight: var(--fw-semibold); }
  .fs-warnings ul, .fs-warning-list { margin: var(--space-2) 0 0; padding-left: var(--space-5); display: grid; gap: var(--space-1); }

  .fs-tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin: var(--space-3) 0 var(--space-4); }
  .fs-tab { appearance: none; border: 0; background: none; padding: var(--space-2) var(--space-3); font: inherit; font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
  .fs-tab:hover { color: var(--text); }
  .fs-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

  .fs-statements { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }
  .fs-studio { min-width: 0; max-width: 100%; }
  .fs-statement__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
  .fs-statement__head h3 { margin: 0; font-size: var(--text-lg); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }

  .fs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.fs-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
  table.fs-table th { font-size: var(--text-2xs); font-weight: var(--fw-semibold); color: var(--muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); padding: 6px var(--space-2); border-bottom: 1px solid var(--border-strong); white-space: nowrap; text-align: left; }
  table.fs-table th.right, table.fs-table td.right { text-align: right; }
  table.fs-table td { padding: 5px var(--space-2); border-bottom: 1px solid var(--border-subtle); color: var(--text); vertical-align: top; }
  table.fs-table td.num { white-space: nowrap; min-width: 92px; }
  table.fs-table td.num.neg { color: var(--amount-negative); }
  table.fs-table .fs-note-col { width: 56px; text-align: center; color: var(--muted); }
  .fs-row--heading td { font-weight: var(--fw-semibold); padding-top: var(--space-3); border-bottom-color: transparent; color: var(--text); }
  table.fs-table .fs-row--subtotal td { font-weight: var(--fw-semibold); background: var(--row-subtotal); }
  .fs-row--subtotal td.num { border-top: 1px solid var(--border-strong); }
  table.fs-table .fs-row--total td { font-weight: var(--fw-bold); background: var(--row-total); border-bottom: 3px double var(--rule-total); }
  .fs-row--total td.num { border-top: 1px solid var(--rule-total); }
  .fs-l1 td:first-child { padding-left: calc(var(--space-2) + 14px); }
  .fs-l2 td:first-child { padding-left: calc(var(--space-2) + 28px); }
  .fs-l3 td:first-child { padding-left: calc(var(--space-2) + 42px); }
  .fs-note-link { appearance: none; border: 0; background: var(--accent-soft); color: var(--accent-fg); font: inherit; font-size: var(--text-2xs); font-weight: var(--fw-semibold); min-width: 24px; height: 20px; border-radius: var(--radius-pill); cursor: pointer; }
  .fs-note-link:hover { background: var(--accent-soft-2); }

  .fs-notes { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); max-width: 920px; }
  .fs-note { padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); scroll-margin-top: 80px; }
  .fs-note__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
  .fs-note__head h4 { margin: 0; font-size: var(--text-md); font-weight: var(--fw-semibold); }
  .fs-note__meta { display: flex; align-items: center; gap: var(--space-2); flex: none; }
  .fs-note h5 { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-sm); font-weight: var(--fw-semibold); }
  .fs-note p { margin: 0 0 var(--space-2); color: var(--text-2); line-height: var(--lh-md); font-size: var(--text-sm); }
  table.fs-table--note { margin-top: var(--space-2); }
  .fs-note-modal textarea { width: 100%; min-height: 220px; font: inherit; line-height: var(--lh-md); }
  .fs-note-modal .field { display: grid; gap: var(--space-1); margin-bottom: var(--space-3); }

  .srv-report__loading { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-8) var(--space-4); color: var(--muted); font-size: var(--text-sm); justify-content: center; }
  .srv-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: srv-spin .8s linear infinite; }
  @keyframes srv-spin { to { transform: rotate(360deg); } }
  @media (prefers-reduced-motion: reduce) { .srv-spinner { animation: none; } }

  table.bva-table .bva-period { border-left: 1px solid var(--border-subtle); }
  table.bva-table td.bva-fav { color: var(--success-fg); }
  table.bva-table td.bva-unfav { color: var(--danger-fg); }
  .fs-footnote { font-size: var(--text-xs); margin-top: var(--space-2); }

  /* ------------------------------------------------------ format designer */
  .fsd-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warning-fg, var(--accent)); margin-left: var(--space-1); vertical-align: middle; }
  .fsd-banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
  .fsd-banner__msg { margin-right: auto; }
  .fsd-head { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); }
  .fsd-head input { min-width: 240px; }
  .fsd-help { font-size: var(--text-xs); margin: var(--space-2) 0 var(--space-4); }
  .fsd-statement { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: var(--space-3); margin-bottom: var(--space-3); }
  .fsd-statement__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
  .fsd-title { font-weight: var(--fw-semibold); min-width: 260px; }
  .fsd-kind { font-size: var(--text-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: var(--fw-medium); }
  table.fsd-lines { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
  table.fsd-lines th { font-size: var(--text-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: var(--fw-semibold); text-align: left; padding: 4px var(--space-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
  table.fsd-lines td { padding: 6px var(--space-2); border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
  table.fsd-lines select, table.fsd-lines input.fsd-label { height: var(--control-sm, 28px); font-size: var(--text-sm); }
  table.fsd-lines input.fsd-label { width: 100%; min-width: 180px; }
  .fsd-line--heading td { background: var(--surface-2); }
  .fsd-line--subtotal td, .fsd-line--total td { background: var(--row-subtotal); }
  .fsd-move { white-space: nowrap; width: 1%; }
  .fsd-move button, .fsd-x { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); width: 24px; height: 24px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; line-height: 1; }
  .fsd-move button + button { margin-left: 2px; }
  .fsd-move button:hover, .fsd-x:hover { color: var(--text); border-color: var(--border-strong); }
  .fsd-x:hover { color: var(--danger-fg); }
  .fsd-src { min-width: 280px; }
  .fsd-note { text-align: center; width: 1%; }
  .fsd-chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
  .fsd-chips + .fsd-chips { margin-top: var(--space-1); }
  .fsd-chip { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 2px var(--space-2-5); font: inherit; font-size: var(--text-xs); cursor: pointer; line-height: 1.6; }
  .fsd-chip:hover { border-color: var(--border-strong); color: var(--text); }
  .fsd-chip.is-on { background: var(--accent-soft, var(--surface-3)); border-color: var(--accent); color: var(--accent); font-weight: var(--fw-medium); }
  .fsd-chip.is-on.is-minus { border-color: var(--danger-fg); color: var(--danger-fg); background: transparent; }
  .fsd-add-src { height: 24px; font-size: var(--text-xs); max-width: 180px; padding-top: 0; padding-bottom: 0; }
  .fsd-empty { font-size: var(--text-xs); color: var(--subtle); align-self: center; }
  .fsd-add { margin-top: var(--space-2); }
  .fsd-add-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: var(--space-2) 0 var(--space-3); }
  .fsd-add-row input { min-width: 260px; }

  @media (max-width: 640px) {
    .fs-bar__field select { min-width: 0; width: 100%; }
    .fs-bar__field { flex: 1 1 140px; }
    .fs-summary { flex-direction: column; }
    .fs-checks ul { left: 0; right: auto; }
    table.fs-table td.num { min-width: 76px; padding-left: var(--space-1); }
    table.fs-table th { white-space: normal; }
    table.fs-table td:first-child, table.fs-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); white-space: normal; min-width: 40vw; max-width: 50vw; }
    table.fs-table .fs-row--subtotal td:first-child { background: var(--row-subtotal); }
    table.fs-table .fs-row--total td:first-child { background: var(--row-total); }
    table.fs-table .fs-note-col { width: 30px; padding: 5px 2px; }
    .fs-note { padding: var(--space-3); }
  }
}

/* ---- Management | Financial statements, and the statement sheet (2026-10 peak plan E) ------------------ */
@layer reports {
  .report-mode { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); padding: var(--space-1);
    border-radius: var(--radius-lg); background: var(--surface-2); border: 1px solid var(--border-subtle); }
  .report-mode__btn { appearance: none; border: 1px solid transparent; background: transparent; border-radius: var(--radius-md); padding: var(--space-2) var(--space-4);
    text-align: left; cursor: pointer; font: inherit; color: var(--text-2); display: flex; flex-direction: column; gap: 2px;
    transition: background var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
  .report-mode__btn:hover { background: var(--surface); color: var(--text); }
  .report-mode__btn.is-active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--elev-1); }
  .report-mode__btn.is-active .report-mode__title { color: var(--accent); }
  .report-mode__title { font-size: var(--text-md); font-weight: var(--fw-semibold); }
  .report-mode__sub { font-size: var(--text-xs); color: var(--muted); }
  @media (max-width: 640px) { .report-mode__sub { display: none; } }

  .fs-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--elev-1);
    padding: var(--space-8) var(--space-8) var(--space-6); max-width: 980px; width: 100%; margin: 0 auto; }
  .fs-sheet__head { position: relative; text-align: center; margin-bottom: var(--space-6); padding-bottom: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
  .fs-sheet__entity { font-size: var(--text-sm); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-2); }
  .fs-sheet__title { margin: var(--space-1) 0; font-size: var(--text-xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); color: var(--text); }
  .fs-sheet__period { font-size: var(--text-sm); color: var(--text-2); }
  .fs-sheet__units { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
  .fs-status { position: absolute; top: 0; right: 0; padding: 2px var(--space-2); border-radius: var(--radius-pill); font-size: var(--text-2xs); font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-caps); text-transform: uppercase; border: 1px solid; }
  .fs-status--draft { color: var(--warning-fg); background: var(--warning-soft); border-color: var(--warning-line); }
  .fs-status--issued { color: var(--success-fg); background: var(--success-soft); border-color: var(--success-line); }
  .fs-sheet table.fs-table td { border-bottom-color: transparent; padding-top: 4px; padding-bottom: 4px; }
  .fs-sheet table.fs-table th { border-bottom: 1px solid var(--border-strong); }
  .fs-sheet table.fs-table .fs-amount-col { width: 140px; }
  .fs-sheet table.fs-table .fs-prior { color: var(--text-2); }
  .fs-sheet table.fs-table .fs-row--subtotal td, .fs-sheet table.fs-table .fs-row--total td { background: transparent; }
  .fs-sheet table.fs-table .fs-row--subtotal td.num { border-top: 1px solid var(--text-2); }
  .fs-sheet table.fs-table .fs-row--total td { border-bottom: 0; }
  .fs-sheet table.fs-table .fs-row--total td.num { border-top: 1px solid var(--text); border-bottom: 3px double var(--text); }
  .fs-sheet table.fs-table .fs-row--heading td { text-transform: none; font-size: var(--text-sm); padding-top: var(--space-4); }
  @media (max-width: 640px) { .fs-sheet { padding: var(--space-4); } .fs-status { position: static; display: inline-block; margin-top: var(--space-2); } }

  .fs-compliance { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); margin: var(--space-2) 0;
    border-radius: var(--radius-md); font-size: var(--text-sm); border: 1px solid; }
  .fs-compliance .btn { margin-left: auto; flex: none; }
  .fs-compliance--ready { background: var(--success-soft); border-color: var(--success-line); color: var(--success-fg); }
  .fs-compliance--draft { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
  .fs-issued { margin: var(--space-2) 0; font-size: var(--text-sm); }
  .fs-issued summary { cursor: pointer; color: var(--accent); font-weight: var(--fw-medium); }
  .fs-issued ul { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: grid; gap: var(--space-1); }
  .fs-issued li { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
  .fs-issued__files { margin-left: auto; display: flex; gap: var(--space-1); }
  @media print { .report-mode, .fs-compliance, .fs-issued { display: none !important; } .fs-sheet { box-shadow: none; border: 0; break-after: page; } }
}

/* ---- Financial statements as one report: cover, contents, statements, notes (audit-package layout) ---- */
@layer reports {
  .fs-report { display: grid; gap: var(--space-6); font-family: Arial, "Liberation Sans", Helvetica, sans-serif; }
  .fs-report .fs-sheet { max-width: 860px; padding: var(--space-8) var(--space-10, 56px) var(--space-8); }
  .fs-report .fs-sheet__head { text-align: left; border-bottom: 2px solid var(--accent); padding-bottom: var(--space-3); margin-bottom: var(--space-5); }
  .fs-report .fs-sheet__entity { font-size: var(--text-2xs); color: var(--accent); }
  .fs-report .fs-sheet__title { font-size: 20px; margin: var(--space-1) 0 2px; }
  .fs-report .fs-status { top: var(--space-1); }

  /* cover */
  .fs-sheet--cover { min-height: 520px; display: flex; flex-direction: column; padding-top: 110px; }
  .fs-cover__name { font-size: 32px; font-weight: 700; line-height: 1.15; color: var(--text); }
  .fs-cover__rule { width: 72px; height: 3px; background: var(--accent); margin: var(--space-4) 0 var(--space-5); }
  .fs-cover__title { font-size: 20px; color: var(--text); }
  .fs-cover__period { font-size: 14px; color: var(--muted); margin-top: var(--space-1); }
  .fs-cover__draft { position: static; align-self: flex-start; margin-top: var(--space-5); }
  .fs-cover__foot { margin-top: auto; padding-top: var(--space-8); font-size: var(--text-xs); line-height: 1.7; color: var(--muted); }

  /* contents */
  .fs-contents__list, .fs-contents__notes { list-style: none; margin: 0; padding: 0; }
  .fs-contents__list > li { padding: var(--space-2) 0; font-size: var(--text-md); border-bottom: 1px dotted var(--border); }
  .fs-contents__list a { color: var(--text); text-decoration: none; }
  .fs-contents__list a:hover { color: var(--accent); text-decoration: underline; }
  .fs-contents__notes { margin: var(--space-2) 0 0 var(--space-5); }
  .fs-contents__notes li { font-size: var(--text-sm); padding: 3px 0; color: var(--muted); }
  .fs-contents__notes li a { color: var(--text-2); }
  .fs-contents__notes li span { display: inline-block; min-width: 24px; color: var(--muted); }

  /* statements: ruled, aligned, no zebra */
  .fs-report table.fs-table th { text-transform: none; letter-spacing: 0; font-size: var(--text-xs); color: var(--text); border-bottom: 1.5px solid var(--text); vertical-align: bottom; }
  .fs-report .fs-th-sub { display: block; font-weight: 400; font-size: var(--text-2xs); color: var(--muted); }
  .fs-report table.fs-table td { padding-top: 5px; padding-bottom: 5px; }
  .fs-report table.fs-table .fs-row--heading td { padding-top: var(--space-5); }
  .fs-report table.fs-table .fs-row--heading:first-child td { padding-top: var(--space-3); }
  .fs-report table.fs-table--paren td.fs-amount:not(.neg)::after,
  .fs-report table.fs-table--paren.fs-table--note td.num:not(.neg)::after { content: ")"; visibility: hidden; }
  .fs-report table.fs-table td.num.neg { color: inherit; }
  .fs-report .fs-note-link { background: none; color: var(--text); font-size: var(--text-xs); font-weight: 400; min-width: 0; height: auto; border-radius: 0; text-decoration: underline dotted; text-underline-offset: 3px; }
  .fs-report .fs-note-link:hover { color: var(--accent); }
  .fs-sheet__foot { margin: var(--space-6) 0 0; font-size: var(--text-xs); font-style: italic; color: var(--muted); }

  /* notes: one flowing section, not cards */
  .fs-report .fs-sheet--notes .fs-note { border: 0; border-radius: 0; box-shadow: none; background: none; padding: 0 0 var(--space-5); }
  .fs-report .fs-note__head h4 { color: var(--accent); font-size: var(--text-md); }
  .fs-report .fs-note__head { align-items: baseline; margin-top: var(--space-5); }
  .fs-report .fs-note > h5, .fs-report .fs-note > p, .fs-report .fs-note > .fs-scroll { margin-left: 28px; }
  .fs-report .fs-note p { color: var(--text); font-size: var(--text-sm); line-height: 1.55; }
  .fs-report .fs-note__meta .btn { opacity: .55; }
  .fs-report .fs-note:hover .fs-note__meta .btn { opacity: 1; }
  @media (max-width: 640px) { .fs-report .fs-sheet { padding: var(--space-4); } .fs-sheet--cover { padding-top: var(--space-8); } .fs-report .fs-note > h5, .fs-report .fs-note > p, .fs-report .fs-note > .fs-scroll { margin-left: 0; } }
}

/* Rules sit under the figures only (short, one per column), never as one line across the page */
@layer reports {
  .fs-report .fs-sheet__head { border-bottom: 0; }
  .fs-report .fs-sheet table.fs-table th { border-bottom: 0; }
  .fs-report .fs-sheet table.fs-table th.fs-amount-col,
  .fs-report .fs-sheet table.fs-table--note th.right { background: linear-gradient(var(--text), var(--text)) center bottom / calc(100% - 16px) 1.5px no-repeat; }
  .fs-report .fs-sheet table.fs-table .fs-row--subtotal td.num { border-top: 0; background: linear-gradient(var(--text-2), var(--text-2)) center top / calc(100% - 16px) 1px no-repeat; }
  .fs-report .fs-sheet table.fs-table .fs-row--total td.num { border: 0;
    background: linear-gradient(var(--text), var(--text)) center top / calc(100% - 16px) 1px no-repeat,
                linear-gradient(var(--text), var(--text)) center calc(100% - 4px) / calc(100% - 16px) 1px no-repeat,
                linear-gradient(var(--text), var(--text)) center bottom / calc(100% - 16px) 1px no-repeat; }
}

/* Top of every sheet: company name, page title right under it, logo opposite, one rule across; boxed column head */
@layer reports {
  .fs-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); padding-bottom: var(--space-2); margin-bottom: var(--space-4); border-bottom: 1.5px solid var(--text); }
  .fs-top__name { font-size: 22px; font-weight: 700; line-height: 1.15; color: var(--text); }
  .fs-top__title { margin: 3px 0 0; font-size: 17px; font-weight: 700; line-height: 1.2; color: var(--text); letter-spacing: 0; }
  .fs-top__side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); flex: none; }
  .fs-top__side .fs-status { position: static; }
  .fs-top__logo { max-height: 56px; max-width: 160px; object-fit: contain; }
  .fs-top__period { font-size: var(--text-sm); color: var(--muted); margin: 0 0 var(--space-3); }
  .fs-report .fs-sheet table.fs-table th.fs-box { text-align: center; font-weight: 700; font-size: var(--text-xs); color: var(--text); text-transform: none; letter-spacing: 0; padding: 5px 8px; border-bottom: 1px solid var(--text); background: none; }
  .fs-report .fs-sheet table.fs-table th.fs-box--period { border-top: 1px solid var(--text); }
  .fs-report .fs-sheet table.fs-table .fs-box-row th:not(.fs-box) { border: 0; font-weight: 700; color: var(--text); text-align: center; font-size: var(--text-xs); text-transform: none; letter-spacing: 0; }
  .fs-report .fs-sheet table.fs-table .fs-box-row th.fs-label-col { width: auto; }
  @media (max-width: 640px) { .fs-top { flex-wrap: wrap; } .fs-top__name { font-size: 18px; } }
}

/* Compact: tighter rows, narrower figure columns (the rules end where the figures end), smaller top block */
@layer reports {
  .fs-report { gap: var(--space-4); }
  .fs-report .fs-sheet { padding: var(--space-5) var(--space-8) var(--space-5); }
  .fs-top { padding-bottom: 6px; margin-bottom: var(--space-2); }
  .fs-top__name { font-size: 18px; }
  .fs-top__title { font-size: 14px; margin-top: 1px; }
  .fs-top__logo { max-height: 42px; }
  .fs-report table.fs-table td { padding-top: 2px; padding-bottom: 2px; line-height: 1.35; }
  .fs-report table.fs-table td.num { min-width: 0; width: 92px; }
  .fs-report table.fs-table .fs-row--heading td { padding-top: 9px; }
  .fs-report table.fs-table .fs-row--heading:first-child td { padding-top: 4px; }
  .fs-report .fs-sheet table.fs-table th.fs-box { padding: 3px 6px; }
  .fs-report .fs-sheet table.fs-table .fs-box-row th:not(.fs-box) { padding: 3px 6px; }
  .fs-sheet__foot { margin-top: var(--space-3); }
  .fs-sheet--cover { min-height: 420px; padding-top: 80px; }
  .fs-contents__list > li { padding: var(--space-1) 0; }
  .fs-top__period { margin-bottom: var(--space-2); }
  .fs-report .fs-note { padding-bottom: var(--space-3); }
  .fs-report .fs-note__head { margin-top: var(--space-3); margin-bottom: 2px; }
  .fs-report .fs-note p { line-height: 1.45; margin-bottom: 4px; font-size: var(--text-xs); }
  .fs-report .fs-note h5 { margin: 6px 0 1px; font-size: var(--text-xs); }
  .fs-report table.fs-table--note td { padding-top: 1px; padding-bottom: 1px; }
}
