body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 2rem;
    color: #1a1a1a;
}

h1, h2 {
    font-weight: 600;
}

a {
    color: #0b66c3;
}

table {
    border-collapse: collapse;
    margin-top: 1rem;
    min-width: 24rem;
}

th, td {
    border: 1px solid #ddd;
    padding: 0.4rem 0.8rem;
    text-align: left;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- "Hide numbers" privacy mask (privacy.js) --------------------------- */
#privacy-toggle {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 1000;
    padding: 0.4rem 0.75rem;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.1;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

#privacy-toggle:hover {
    background: #f3f7fb;
}

/* Active state: solid pill so it's obvious numbers are currently masked. */
html.privacy-on #privacy-toggle {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* Each detected dollar amount is wrapped in <span class="pmask"> (or, for
   sankey SVG labels, the class is put on the <text> itself). Blur only bites
   while privacy is on, so toggling off restores the figures instantly. The
   blur radius is in em so it scales with the font and never leaves digits
   legible. */
html.privacy-on .pmask {
    filter: blur(0.5em);
    -webkit-filter: blur(0.5em);
    -webkit-user-select: none;
    user-select: none;
    cursor: default;
}

/* Consolidation account-mapping table (bookkeeping Part 5) */
.qbo-rpt-maptable { min-width: 0; margin-top: 0.35rem; }
.qbo-rpt-maptable td { padding: 0.25rem 0.6rem; }
.qbo-rpt-maptable select { max-width: 22rem; }

/* Primary actions in Part 5 ("Fetch QBO data" / "Refresh Preview") — sized up so
   they read as the main buttons of the section. */
.big-action {
    font-size: 1.15em;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
}

/* ---- Bookkeeping button chrome ---------------------------------------------
   Started as Part 5's (action-heavy, and its buttons were default-chrome small)
   and now covers every Part of bookkeeping.html (body.bk-page). The base rules
   are wrapped in :where() so they weigh no more than a bare `button`: any class
   rule wins over them. They used to be `#qbo-reports button`, and that id
   outranked `.qbo-rpt-ctl`, padding the preview's row-control buttons until
   their icons were squeezed out and the buttons rendered as empty boxes. */

/* Every button: bigger hit area, real weight, visible chrome. */
:where(.bk-page .panel) button {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.55rem 1.1rem;
    border: 1px solid #b9bec4;
    border-radius: 0.4rem;
    background: #f7f8f9;
    color: #1f2328;
    cursor: pointer;
    transition: background 0.12s, box-shadow 0.12s, transform 0.06s;
}
:where(.bk-page .panel) button:hover:not(:disabled) {
    background: #eceff1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}
:where(.bk-page .panel) button:active:not(:disabled) { transform: translateY(1px); }
:where(.bk-page .panel) button:focus-visible {
    outline: 3px solid rgba(11, 102, 195, 0.45);
    outline-offset: 2px;
}
:where(.bk-page .panel) button:disabled { opacity: 0.55; cursor: not-allowed; }
/* Locked by runLocked() while its request is out: busy, not forbidden. */
:where(.bk-page .panel) button[aria-busy="true"] { cursor: progress; }

/* The section's primary actions: solid blue, largest type, own shadow. */
#qbo-reports .big-action {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.8rem 1.8rem;
    letter-spacing: 0.01em;
    background: #0b66c3;
    border-color: #0b66c3;
    color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 2px 5px rgba(11, 102, 195, 0.32);
}
#qbo-reports .big-action:hover:not(:disabled) {
    background: #0a58a8;
    border-color: #0a58a8;
    box-shadow: 0 3px 9px rgba(11, 102, 195, 0.42);
}

/* Secondary actions (Refresh / Select all / Load settings): still lighter than
   the blue primaries, but no longer tiny. */
.bk-page .panel button.secondary {
    font-size: 0.98rem;
    font-weight: 600;
    padding: 0.45rem 0.95rem;
    background: #eef1f4;
    border: 1px solid #b9bec4;
    color: #1f2328;
    border-radius: 0.4rem;
}
.bk-page .panel button.secondary:hover:not(:disabled) { background: #e0e4e8; }

/* Consolidated preview tables (read-only, in-page) */
/* All previews live in one area; the tab strip picks which table is shown. */
.qbo-rpt-tabs {
    display: flex; flex-wrap: wrap; gap: 0.25rem;
    border-bottom: 1px solid #c7ccd1; margin-top: 0.5rem;
}
/* Scoped under the owning sections so these beat their generic button rules.
   Part 6 uses the same tab strip, so it is listed alongside Part 5 rather than
   given a near-identical copy of every rule. */
#qbo-reports .qbo-rpt-tab, #qbo-variance .qbo-rpt-tab {
    background: #eef1f4; border: 1px solid #c7ccd1; border-bottom: none;
    color: #1f2328; font-size: 0.9rem; font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: 0.35rem 0.35rem 0 0; cursor: pointer;
    margin-bottom: -1px;                 /* active tab merges into the strip */
}
#qbo-reports .qbo-rpt-tab:hover:not(:disabled),
#qbo-variance .qbo-rpt-tab:hover:not(:disabled) {
    background: #e2e6ea; box-shadow: none;
}
/* Consolidated tabs carry the row controls; tint their top edge so they read as
   a different kind of tab from the plain per-company ones. Part 6 reuses the
   same tint for its summed "All companies" tab, for the same reason. */
#qbo-reports .qbo-rpt-tab-consol,
#qbo-variance .qbo-rpt-tab-consol { border-top: 2px solid #0b66c3; }
/* The pooled briefing tab leads the row and is where a close starts, so it is
   the one tab that looks different when it is NOT selected. */
#qbo-variance .qbo-rpt-tab-brief {
    border-top: 2px solid #a56300;
    font-weight: 700;
}
#qbo-reports .qbo-rpt-tab.active, #qbo-variance .qbo-rpt-tab.active {
    background: #fff; border-bottom: 1px solid #fff; font-weight: 700;
}
.qbo-rpt-tabpanes {
    border: 1px solid #c7ccd1; border-top: none;
    padding: 0.5rem 0.6rem; margin-bottom: 0.75rem;
}
.qbo-rpt-preview-scroll { overflow-x: auto; max-width: 100%; }
.qbo-rpt-preview-table { min-width: 0; margin: 0.25rem 0 0.75rem; font-size: 0.9em; }
.qbo-rpt-preview-table th, .qbo-rpt-preview-table td { padding: 0.15rem 0.6rem; }
.qbo-rpt-preview-table td.num { white-space: nowrap; }
/* Per-row controls get four real columns of their own — collapse | redact |
   highlight | footnote — ahead of the account name, so the browser's table
   layout does the aligning. Each button is a fixed box with its icon centred
   inside it; a row that can't use a control still renders its button,
   disabled, keeping the columns readable top to bottom. */
.qbo-rpt-preview-table th.qbo-rpt-ctl-cell,
.qbo-rpt-preview-table td.qbo-rpt-ctl-cell {
    width: 1.9rem; padding: 0.15rem 0;
    text-align: center; vertical-align: middle;
}
/* The icons are inline SVG (bookkeeping.js, CTL_ICON), not emoji, so the box
   below holds a drawing of a known size rather than a glyph whose size came
   from the viewer's emoji font. Centring is done by flex: `overflow: hidden`
   on a <button> would turn it into a scroll container and switch OFF the UA's
   own centring of button contents, which is what used to push the glyph
   off-centre and clip it. Nothing here clips. */
.qbo-rpt-ctl, .qbo-rpt-ctl-head {
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto; box-sizing: border-box;
    width: 1.5rem; height: 1.5rem;
    color: #5b6873;
}
.qbo-rpt-ctl svg, .qbo-rpt-ctl-head svg {
    display: block; width: 1rem; height: 1rem;
}
.qbo-rpt-ctl {
    appearance: none; -webkit-appearance: none;
    background: none; border: 1px solid transparent; border-radius: 3px;
    padding: 0; cursor: pointer;
    /* Off = a thinner, quieter version of the same drawing. The icons carry
       their state in ink and fill now, so nothing needs the grayscale filter
       the emoji used to need. */
    opacity: 0.55;
}
.qbo-rpt-ctl:hover:not(:disabled) {
    opacity: 1; color: #33566b; background: #eef2f6;
}
.qbo-rpt-ctl[aria-pressed="true"] {
    opacity: 1; color: #22415a; background: #eef2f6; border-color: #b6c2cf;
}
.qbo-rpt-ctl:disabled { cursor: default; opacity: 0.18; }
/* ON fills the one shape each icon tags for it: the mask's bar goes solid, and
   the highlighter's nib fills with the exact yellow the export paints, so the
   control shows what it will do rather than only that it is pressed. */
.qbo-rpt-ctl[aria-pressed="true"] .qbo-rpt-ico-fill { fill: currentColor; }
.qbo-rpt-highlight-cb[aria-pressed="true"] .qbo-rpt-ico-fill { fill: #ffe599; }
/* The redact column's header button is a bulk control, so it has a third state:
   SOME of the rows redacted. It reads as a half-inked version of the pressed
   face — the same fill, thinned — rather than as a second colour, which would
   invent a meaning the column does not have. */
.qbo-rpt-ctl-bulk[aria-pressed="mixed"] {
    opacity: 1; color: #22415a; background: #f2f6f9; border-color: #d4dde5;
}
.qbo-rpt-ctl-bulk[aria-pressed="mixed"] .qbo-rpt-ico-fill {
    fill: currentColor; fill-opacity: 0.3;
}
/* It sits in the header among three inert legend labels, so it carries a hint
   that it is pressable at all: a dotted underline, like the legend's own
   cursor: help, but pointing at an action. */
.qbo-rpt-ctl-bulk { border-bottom-style: dotted; border-bottom-color: #9aa7b2; }
/* Legend icons in the header row: inert, and dimmed less than an off button so
   they read as column titles rather than as controls someone forgot to enable. */
.qbo-rpt-ctl-head { opacity: 0.7; cursor: help; }
.qbo-rpt-acct { white-space: pre; }     /* preserve the account-tree indentation */
/* Period-change columns (Δ $ / Δ %). The fill is a gradient computed per cell in
   bookkeeping.js, matching what the export paints (qbo_reports.py, _DELTA_*_END):
   white at no change, ramping to green $100k the good way for that line's
   section and to red $100k the other way.
   The colour arrives as a CUSTOM PROPERTY set on the cell, never as an inline
   `background`. An inline background wins over every rule in this file, so a
   redacted row would show its delta tint through the black bar and a
   highlighted row through the yellow. As a variable it carries the value
   without carrying the specificity, and the rules below still win by being
   more specific — the same layering the old per-tier classes had. */
.qbo-rpt-preview-table td.qbo-rpt-delta { border-left: 1px dotted #c7ccd1; }
.qbo-rpt-preview-table td.qbo-rpt-delta-fill { background: var(--qbo-delta-fill); }
/* The surviving total of a collapsed group: flagged so it's obvious the detail
   above it is folded away rather than missing. */
.qbo-rpt-preview-table tr.qbo-rpt-collapsed-total td {
    background: #eef4fb;
}
/* Highlighted row: the same soft yellow (#FFE599) the export paints, across the
   whole row. Declared before the mask rule so a row that is both highlighted and
   redacted keeps black bars over its figures (that rule is more specific). */
.qbo-rpt-preview-table tr.qbo-rpt-highlight td {
    background: #ffe599;
}
/* A masked row redacts its number cells only (the account label is kept): a solid
   black bar with the figure hidden, mirroring the exported sheet. */
.qbo-rpt-preview-table tr.qbo-rpt-masked td.num {
    background: #000;
    color: transparent;
}

/* Footnote marker on the account label, and the editor row beneath it. */
.qbo-rpt-fn-mark { color: #1a7f37; font-weight: 700; margin-left: 0.15rem; }
.qbo-rpt-preview-table tr.qbo-rpt-fn-row td {
    background: #f4faf5;
    border-top: none;
    padding: 0.2rem 0.6rem 0.4rem 1.6rem;
}
.qbo-rpt-fn-num {
    color: #1a7f37; font-weight: 700; margin-right: 0.4rem; vertical-align: top;
}
.qbo-rpt-fn-text {
    width: min(46rem, 80%); font: inherit; font-size: 0.95em;
    padding: 0.25rem 0.4rem; border: 1px solid #c7ccd1; border-radius: 0.25rem;
    resize: vertical;
}

/* Lighter-weight button (e.g. "Load settings" / "Refresh" in the run history) */
button.secondary {
    background: #f1f3f4; color: #333; border: 1px solid #ccc;
    padding: 0.2rem 0.6rem; font-size: 0.9em; border-radius: 0.3rem;
    cursor: pointer;
}
button.secondary:hover { background: #e4e6e8; }

/* Recent export runs ("last exports run" history, bookkeeping Part 5) */
.qbo-rpt-history-list { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.qbo-rpt-history-item {
    display: flex; justify-content: space-between; align-items: center;
    gap: 0.75rem; padding: 0.45rem 0; border-top: 1px solid #eee;
}
.qbo-rpt-history-head { display: flex; align-items: center; gap: 0.5rem; }
.qbo-rpt-history-ts { font-weight: 600; color: #333; }
.qbo-rpt-history-detail { color: #666; font-size: 0.9em; margin-top: 0.1rem; }
.qbo-rpt-history-actions {
    display: flex; align-items: center; gap: 0.6rem; white-space: nowrap;
}
.qbo-rpt-badge {
    font-size: 0.78em; padding: 0.05rem 0.4rem; border-radius: 0.65rem;
    white-space: nowrap;
}
.qbo-rpt-badge-success { background: #e6f4ea; color: #137333; }
.qbo-rpt-badge-partial { background: #fef7e0; color: #a56300; }
.qbo-rpt-badge-error   { background: #fce8e6; color: #b00020; }
.qbo-rpt-badge-empty   { background: #f1f3f4; color: #5f6368; }

#status {
    margin-left: 0.75rem;
    color: #666;
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.meta {
    color: #666;
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
}

/* Cashflow planner table */
#cashflow-table .day-row {
    cursor: pointer;
}

#cashflow-table .day-row:hover {
    background: #f3f7fb;
}

#cashflow-table .day-row td:first-child::before {
    content: "▸ ";
    color: #999;
}

#cashflow-table .day-row.open td:first-child::before {
    content: "▾ ";
}

td.drill {
    background: #fafafa;
    padding: 0.5rem 0.8rem;
}

.drill-table {
    margin: 0;
    min-width: 0;
    width: 100%;
    font-size: 0.9rem;
}

.drill-table th, .drill-table td {
    border: 1px solid #e6e6e6;
}

/* Per-week slack table: dim weeks that have already ended */
#weekly-table .past-week td {
    color: #999;
}

/* Import Bank CSV panel */
.panel {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem 1rem 1rem;
    margin: 1.5rem 0;
    background: #fafafa;
}

.panel h2 {
    margin-top: 0.5rem;
}

#reconcile-table {
    font-size: 0.85rem;
    margin-top: 0;
}

/* Step 1: keep the raw preview small + scrollable rather than a wall of rows */
.preview-box {
    max-height: 12rem;
    overflow: auto;
    margin-top: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fff;
}

#reconcile-status,
#match-status,
#commit-status {
    margin-left: 0.75rem;
    color: #666;
}

/* Step 2/3: proposed-change + commit-result tables */
#match-results h3 {
    font-weight: 600;
    font-size: 1rem;
    margin: 1rem 0 0;
}

/* Collapsible "Already posted" section: make the summary read like an h3 */
.posted-details > summary {
    font-weight: 600;
    font-size: 1rem;
    margin: 1rem 0 0;
    cursor: pointer;
}

.proposed-table {
    font-size: 0.85rem;
    width: 100%;
    /* Fixed layout: columns size to their assigned width and DON'T stretch to fit
       long Description / Bank Description text (which made the tables far too wide).
       Cells wrap instead, and each column can be dragged narrower/wider. */
    table-layout: fixed;
}

.proposed-table th, .proposed-table td {
    border: 1px solid #e6e6e6;
    padding: 0.25rem 0.4rem;
    vertical-align: top;
    /* pre-line: render the '\n'-joined multi-leg bank descriptions as separate
       lines. anywhere/hidden: wrap (and clip) long wire-ref tokens rather than
       forcing the column wider. */
    white-space: pre-line;
    overflow-wrap: anywhere;
    overflow: hidden;
}

/* Anchor for the drag-to-resize grip added in cashflow.js (enhanceTable). */
.proposed-table th {
    position: relative;
}

.proposed-table th .col-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 2;
}

body.col-resizing {
    cursor: col-resize;
    user-select: none;
}

/* Rows needing a human look (and drifted/error commit results) stand out */
.proposed-table tr.needs-review {
    background: #fff6e5;
}

.proposed-table tr.needs-review td {
    border-color: #f0d9a8;
}

/* Already-posted (no-change) rows: muted, display-only */
.proposed-table tr.posted-row td {
    color: #8a8a8a;
}

/* Provisional rows: posted from a bank "memo" (M: key), awaiting finalization */
.proposed-table tr.provisional td {
    border-left: 3px solid #5b8def;
}
.proposed-table tr.provisional td:first-child {
    box-shadow: inset 3px 0 0 #5b8def;
}

/* Per-store color coding: cornflower blue (BlueSkyBelleville), green
   (GoodVibesEcorse), light purple (GoodVibesPortHuron), yellow (BlueSkyAnnArbor).
   A translucent tint runs across the whole row; the Store cell gets the full,
   solid color. Any other table opts in with class="store-tinted" (reports.html's
   Pricing tab does); `table.store-tinted tbody` is there to out-rank a page's
   own zebra striping, which would otherwise repaint every other row. */
table.store-tinted tbody tr.store-BlueSkyBelleville td,
.proposed-table tr.store-BlueSkyBelleville td   { background: rgba(100, 149, 237, 0.16); }
table.store-tinted tbody tr.store-GoodVibesEcorse td,
.proposed-table tr.store-GoodVibesEcorse td     { background: rgba(52, 168, 83, 0.16); }
table.store-tinted tbody tr.store-GoodVibesPortHuron td,
.proposed-table tr.store-GoodVibesPortHuron td  { background: rgba(180, 167, 214, 0.28); }
table.store-tinted tbody tr.store-BlueSkyAnnArbor td,
.proposed-table tr.store-BlueSkyAnnArbor td     { background: rgba(255, 228, 30, 0.22); }

table.store-tinted tbody tr.store-BlueSkyBelleville td.store-cell,
.proposed-table tr.store-BlueSkyBelleville td.store-cell {
    background: #6495ed; color: #fff; font-weight: 600;
}
table.store-tinted tbody tr.store-GoodVibesEcorse td.store-cell,
.proposed-table tr.store-GoodVibesEcorse td.store-cell {
    background: #34a853; color: #fff; font-weight: 600;
}
table.store-tinted tbody tr.store-GoodVibesPortHuron td.store-cell,
.proposed-table tr.store-GoodVibesPortHuron td.store-cell {
    background: #b4a7d6; color: #2a2a2a; font-weight: 600;
}
table.store-tinted tbody tr.store-BlueSkyAnnArbor td.store-cell,
.proposed-table tr.store-BlueSkyAnnArbor td.store-cell {
    background: #ffe41e; color: #2a2a2a; font-weight: 600;
}

/* A store filter chip in the same palette (reports.html's Pricing tab). */
.store-chip.store-BlueSkyBelleville  { border-left-color: #6495ed; background: rgba(100, 149, 237, 0.16); }
.store-chip.store-GoodVibesEcorse    { border-left-color: #34a853; background: rgba(52, 168, 83, 0.16); }
.store-chip.store-GoodVibesPortHuron { border-left-color: #b4a7d6; background: rgba(180, 167, 214, 0.28); }
.store-chip.store-BlueSkyAnnArbor    { border-left-color: #ffe41e; background: rgba(255, 228, 30, 0.22); }

/* Keep empty old→new delta cells in the store tint too (override the default
   #fbfbfb empty-cell fill, which is otherwise more specific). */
.proposed-table tr.store-BlueSkyBelleville td.delta:empty   { background: rgba(100, 149, 237, 0.16); }
.proposed-table tr.store-GoodVibesEcorse td.delta:empty     { background: rgba(52, 168, 83, 0.16); }
.proposed-table tr.store-GoodVibesPortHuron td.delta:empty  { background: rgba(180, 167, 214, 0.28); }
.proposed-table tr.store-BlueSkyAnnArbor td.delta:empty     { background: rgba(255, 228, 30, 0.22); }

/* Per-field  old → new  change cells in the Rows-to-edit table */
.proposed-table td.delta {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: #444;
}

.proposed-table td.delta:empty {
    background: #fbfbfb;
}

.proposed-table td.delta .old {
    color: #c0392b;
}

.proposed-table td.delta .new {
    color: #1a7f37;
    font-weight: 600;
}

/* Unchanged field: shown so the row is complete, but visually muted. */
.proposed-table td.delta .same {
    color: #888;
}

/* Check-number confirmation column: bank CSV # vs matched CFPS row #. */
.proposed-table td.check-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: center;
}
.proposed-table td.check-cell .check-ok {
    color: #1a7f37;
    font-weight: 600;
}
.proposed-table td.check-cell .check-warn {
    color: #c0392b;
    font-weight: 600;
}
.proposed-table td.check-cell .check-one {
    color: #888;
}

/* Review column: the reason text, plus a chip naming the payee evidence the
   match rests on. Green when the bank line and the CFPS row share a distinctive
   word (the chip IS that word); amber when they share nothing and the match is
   amount-and-date only. Hover for both sides' word lists. */
.proposed-table td.review-cell .payee-chip {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(26, 127, 55, 0.14);
    color: #1a7f37;
    border: 1px solid rgba(26, 127, 55, 0.35);
    cursor: help;
}
.proposed-table td.review-cell .payee-chip-none {
    background: rgba(191, 138, 12, 0.16);
    color: #8a6212;
    border-color: rgba(191, 138, 12, 0.4);
}

/* Big, obvious transition arrow between old and new values */
.proposed-table td.delta .arrow {
    display: inline-block;
    margin: 0 0.5em;
    font-size: 1.5em;
    font-weight: 700;
    line-height: 1;
    color: #0b66c3;
    vertical-align: middle;
}

#diagnostics-box {
    margin-top: 1rem;
    color: #666;
    font-size: 0.9rem;
}

.num.neg {
    color: #c0392b;
}

.num.pos {
    color: #1a7f37;
}

/* Blocking precondition (e.g. a target tab has no "Bank Key" column) */
.warn {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e0b400;
    border-left: 4px solid #e0b400;
    border-radius: 4px;
    background: #fff8e0;
    color: #6b5200;
    font-size: 0.9rem;
}

/* Sortable / filterable reconcile tables --------------------------------- */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    background: #eef3f8;
}

/* Idle sort glyph; lights up blue with direction once a column is active. */
th.sortable::after {
    content: " \2195";
    color: #bbb;
    font-size: 0.85em;
}

th.sortable[data-sort="asc"]::after {
    content: " \2191";
    color: #0b66c3;
}

th.sortable[data-sort="desc"]::after {
    content: " \2193";
    color: #0b66c3;
}

tr.filter-row th {
    padding: 2px 4px;
    background: #f6f6f6;
}

tr.filter-row input.col-filter {
    width: 100%;
    min-width: 2rem;
    box-sizing: border-box;
    padding: 2px 4px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: normal;
    border: 1px solid #ccc;
    border-radius: 3px;
}

/* --- "<- Directory . Logout" shortcut strip (dirlink.js) ----------------- */
/* The first line of every page. Deliberately quiet -- small and grey, so it
   reads as chrome and never competes with the page's own <h1>. */
#dirlink {
    font-size: 0.85rem;
    line-height: 1.2;
    margin: -1rem 0 0.6rem;
    /* Keep clear of the fixed "Hide numbers" pill in the top-right corner. */
    padding-right: 10rem;
}

#dirlink .dirlink-sep {
    color: #999;
    margin: 0 0.4rem;
}

/* --- Suggestion Box tab strip (suggestion.js) ---------------------------- */
/* Injected at the top of every page's <body>: the page's own tab plus the
   Suggestion Box tab. Same visual language as the Part 5 tab strip, scaled up
   since this one sits at page level. */
#suggest-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid #c7ccd1;
    /* No negative top margin: #dirlink now occupies that space above us. */
    margin: 0 0 1.25rem;
    /* Keep clear of the fixed "Hide numbers" pill in the top-right corner. */
    padding-right: 10rem;
}

#suggest-tabs .suggest-tab {
    background: #eef1f4;
    border: 1px solid #c7ccd1;
    border-bottom: none;
    color: #1f2328;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.35rem 0.9rem;
    border-radius: 0.35rem 0.35rem 0 0;
    cursor: pointer;
    margin-bottom: -1px;                 /* active tab merges into the strip */
}

#suggest-tabs .suggest-tab:hover { background: #e2e6ea; }

#suggest-tabs .suggest-tab.active {
    background: #fff;
    border-bottom: 1px solid #fff;
    font-weight: 700;
}

/* The page's own content while the Suggestion tab is up. !important because
   the pages set display on plenty of their own top-level sections. */
.suggest-away { display: none !important; }

#suggest-panel { max-width: 46rem; }

#suggest-panel textarea {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: vertical;
}

.suggest-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

#suggest-submit {
    font: inherit;
    font-weight: 600;
    padding: 0.45rem 1.2rem;
    cursor: pointer;
}

#suggest-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.suggest-ok { color: #127a2e; }
.suggest-err { color: #b00020; }

/* ---------------------------------------------------------------------------
   Month in review — variance vs. the moving averages (bookkeeping Part 6)
   --------------------------------------------------------------------------- */
/* The primary action matches Part 5's blue, so "the button that does the thing"
   looks the same in both sections. Part 7 (fixed assets) shares it. */
#qbo-variance .big-action, #qbo-fa .big-action {
    font-size: 1.15rem; font-weight: 700; padding: 0.7rem 1.5rem;
    background: #0b66c3; border: 1px solid #0b66c3; color: #fff;
    border-radius: 0.5rem; cursor: pointer;
    box-shadow: 0 2px 5px rgba(11, 102, 195, 0.32);
}
#qbo-variance .big-action:hover:not(:disabled), #qbo-fa .big-action:hover:not(:disabled) { background: #0a58a8; }
#qbo-variance .big-action:disabled, #qbo-fa .big-action:disabled { opacity: 0.55; cursor: not-allowed; }

/* Filter bar above the tables: sticky inside the results box so the materiality
   floor and the row filters stay reachable while scrolling a long account list. */
.qbo-var-filters {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
    padding: 0.5rem 0.6rem; margin: 0.75rem 0 0;
    background: #f1f5f9; border: 1px solid #c7ccd1; border-radius: 0.35rem;
    font-size: 0.9rem;
}
.qbo-var-filters label { white-space: nowrap; }
.qbo-var-filters input[type=number] { width: 6rem; }
.qbo-var-filters input[type=search] { width: 12rem; }

.qbo-var-scroll { overflow-x: auto; max-width: 100%; }
.qbo-var-table {
    min-width: 0; margin: 0.5rem 0 0.25rem; font-size: 0.85em;
    border-collapse: collapse;
}
.qbo-var-table th, .qbo-var-table td {
    padding: 0.15rem 0.5rem; border: 1px solid #e0e4e8;
}
/* Deliberately NOT sticky: the header is two rows deep and half its cells span
   both of them, and a rowspan cell cannot stick to a row it only half occupies —
   it detaches from its neighbours the moment the table scrolls. */
.qbo-var-table thead th {
    background: #eef1f4; white-space: nowrap; font-size: 0.95em;
}
/* Group header (row 1) sits above the sortable sub-headers (row 2). */
.qbo-var-table thead tr.qbo-var-grouphead th {
    text-align: center; border-bottom: 1px solid #c7ccd1;
    background: #e4e9ee; font-weight: 700;
}
.qbo-var-table thead tr.qbo-var-subhead th { font-weight: 600; }
.qbo-var-table td.num { white-space: nowrap; }
.qbo-var-table tbody tr:hover td { background: #f3f7fb; }
/* Subtotal / section rows read as the skeleton of the report, like the preview. */
.qbo-var-table tr.qbo-var-total td { font-weight: 700; background: #f8fafc; }
.qbo-var-table tr.qbo-var-total:hover td { background: #eef4fb; }
.qbo-var-acct { white-space: pre; }     /* preserve the account-tree indentation */
/* A column this run has no history for: shown, but visibly unavailable rather
   than silently blank. */
.qbo-var-table th.qbo-var-nodata, .qbo-var-table td.qbo-var-nodata {
    color: #b0b6bc; background: #fbfbfc;
}
/* Good/bad for the line it sits on, not up/down: revenue rising is green and an
   expense rising is red (bookkeeping.js, varMoveClass). The same two verdicts
   the exported sheets shade their Δ columns with, so the page cannot disagree
   with the file it produces. A row the report takes no side on gets no class at
   all and stays in body ink; qbo-var-nil is for a cell with no VALUE. */
.qbo-var-good { color: #1a7f37; }
.qbo-var-bad  { color: #b3261e; }
.qbo-var-nil  { color: #9aa0a6; }

/* Flag chips. Each marks a failure mode a percentage alone can't express. */
.qbo-var-flag {
    display: inline-block; margin: 0 0.15rem 0 0; padding: 0 0.35rem;
    border-radius: 0.6rem; font-size: 0.8em; font-weight: 600;
    white-space: nowrap; cursor: help;
}
.qbo-var-flag-new       { background: #e8f0fe; color: #1247a5; }
.qbo-var-flag-stopped   { background: #fce8e6; color: #b00020; }
.qbo-var-flag-sign_flip { background: #fef7e0; color: #a56300; }
.qbo-var-flag-outlier   { background: #f3e8fd; color: #6b2fb5; }
/* The two trajectory flags. Both are given a solid rather than a tinted chip
   because neither is visible in any other column on the row: a creep is
   invisible to every average beside it, and a peer divergence is invisible in
   a single company's tab at all. */
.qbo-var-flag-creep     { background: #a56300; color: #fff; }
.qbo-var-flag-peer_odd  { background: #0b66c3; color: #fff; }

/* Which tab a pooled briefing row came from. Narrow and quiet — it is a
   breadcrumb back to the per-company tab, not a figure to read. */
.qbo-var-where {
    display: inline-block; max-width: 16rem; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
    font-size: 0.85em; color: #555;
}

/* Sparkline: 12ish months of shape in one cell. The dashed rule is the row's
   own 12-month average, so "above/below normal" is legible without reading a
   single number. */
.qbo-var-spark { display: block; }
.qbo-var-spark .qbo-var-spark-line { fill: none; stroke: #5f6368; stroke-width: 1; }
.qbo-var-spark .qbo-var-spark-avg {
    stroke: #b0b6bc; stroke-width: 1; stroke-dasharray: 2 2;
}
.qbo-var-spark .qbo-var-spark-dot { fill: #0b66c3; }

.qbo-var-summary { margin: 0.4rem 0 0; font-size: 0.9rem; color: #444; }
.qbo-var-empty { margin: 0.75rem 0; color: #666; font-style: italic; }

/* Payee-evidence filter above the proposed tables. The chip in the Review cell
   shows what one match rests on; this scopes the whole review to a kind of
   evidence — "no payee word" in one click. It hides rows only: the selection is
   global, so the readout says when a hidden row is still selected. */
.payee-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    margin: 0.6rem 0 0.9rem;
    padding: 0.5rem 0.7rem;
    background: rgba(127, 127, 127, 0.08);
    border-radius: 4px;
    font-size: 0.9rem;
}
.payee-filter-legend {
    font-weight: 600;
    margin-right: 0.2rem;
}
.payee-filter label {
    margin-right: 0.7rem;
    cursor: pointer;
}
.payee-filter input[type="radio"] {
    margin-right: 0.25rem;
    cursor: pointer;
}
.payee-filter-count {
    margin-left: auto;
    color: #888;
    font-variant-numeric: tabular-nums;
}
.payee-filter-count.warn {
    color: #8a6212;
    font-weight: 600;
}
.proposed-table tbody tr.payee-hidden {
    display: none;
}
