/* ==========================================================================
   Reusable UI components. Anything a non-shell page should be able to drop
   in: section blocks, charts, tables, buttons, badges, KPI strip, etc.
   Use the corresponding macros in `templates/_macros.html` where they exist.
   ========================================================================== */

/* ==========================================================================
   SECTION BLOCK — every page section sits in one of these
   ========================================================================== */
.block {
    padding: 2rem 0 2.25rem;
    border-top: 1px solid var(--rule);
    position: relative;
}

.block:first-of-type {
    border-top: none;
    padding-top: 0.5rem;
}

.block::before {
    /* margin numeral — "01", "02", … fund-report flourish */
    content: attr(data-folio);
    position: absolute;
    top: 2.15rem;
    left: -3rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0.85;
}

.block-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1.25rem;
}

.block-title {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
    line-height: 1.2;
}

.block-sub {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-quiet);
    margin-top: 0.35rem;
    font-weight: 500;
}

/* ==========================================================================
   PILL-BUTTON GROUP (.time-range) — used for time ranges, mode toggles,
   filters. Buttons inside use .time-btn. Active state is one button.
   ========================================================================== */
.time-range {
    display: inline-flex;
    background: var(--paper-tint);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 2px;
    gap: 1px;
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--ink-quiet);
    padding: 0.32rem 0.7rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 4px;
    transition: color 0.18s var(--ease-snap), background 0.18s var(--ease-snap);
}

.time-btn:hover { color: var(--ink); }

.time-btn.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 0 0 1px var(--rule);
}

/* ==========================================================================
   CHART CONTAINER
   ========================================================================== */
.chart-wrap {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 0.75rem;
    position: relative;
}

.chart        { width: 100%; height: 360px; }
.chart-mid    { height: 320px; }
.chart-small  { height: 280px; }

/* ==========================================================================
   TABLES — financial register
   ========================================================================== */
table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-sans);
}

thead tr { border-bottom: 1px solid var(--rule); }

th {
    text-align: left;
    padding: 0.55rem 0.6rem;
    color: var(--ink-quiet);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

td {
    padding: 0.85rem 0.6rem;
    border-bottom: 1px solid var(--rule-soft);
    font-size: 0.88rem;
    color: var(--ink);
    vertical-align: middle;
}

tbody tr { transition: background 0.18s var(--ease-snap); }
tbody tr:hover { background: var(--accent-faint); }
tbody tr:last-child td { border-bottom: none; }

/* Boxed table card (used when the table sits on its own card) */
.data-table {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 0.4rem 1rem;
}

.data-table th { padding: 0.7rem 0.6rem; }

/* Backwards-compat alias — older markup uses .holdings-table */
.holdings-table {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 0.4rem 1rem;
}
.holdings-table th { padding: 0.7rem 0.6rem; }

/* ==========================================================================
   ASSET CELL + ICON BADGE
   Use the `asset_icon(asset, size)` macro to render the icon. JS in
   index.html sets `background` and inner glyph from ASSET_COLORS / ASSET_GLYPHS.
   ========================================================================== */
.asset-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
}

.asset-name {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.005em;
}

.asset-name small {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--ink-faint);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 1px;
}

.asset-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ink-faint);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 2px #fff;
}

.asset-icon.asset-icon-sm {
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
}

/* ==========================================================================
   ASSET PICKER — minimal styled <select>
   ========================================================================== */
.asset-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.asset-select {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper-tint);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 0.32rem 1.5rem 0.32rem 0.7rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    letter-spacing: -0.005em;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1l4 4 4-4' stroke='%23d97706' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    transition: border-color 0.18s var(--ease-snap);
}

.asset-select:hover { border-color: var(--rule-strong); }

.asset-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.asset-select option {
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    padding: 0.5rem;
}

.asset-suffix {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    text-transform: uppercase;
    font-weight: 500;
}

/* ==========================================================================
   VERDICT BADGE — small label for actions, transaction types, statuses
   Variants: .verdict-buy (gain), .verdict-sell (loss), .verdict-hold (neutral)
   ========================================================================== */
.verdict {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    border-radius: 3px;
    line-height: 1;
}

.verdict-buy  { color: var(--gain); background: var(--gain-soft); }
.verdict-sell { color: var(--loss); background: var(--loss-soft); }
.verdict-hold {
    color: var(--ink-mute);
    background: var(--paper-tint);
    border: 1px solid var(--rule);
}

/* ==========================================================================
   PROGRESS — track + fill, used for budget bars and similar
   ========================================================================== */
.progress-track {
    position: relative;
    height: 6px;
    background: var(--rule-soft);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.6s var(--ease-out);
}

.progress-legend {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-quiet);
    font-weight: 500;
}

/* ==========================================================================
   BUDGET BLOCK — feature panel built from progress + line items
   ========================================================================== */
.budget-block {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.budget-hero-num {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 2.5rem;
    color: var(--ink);
    line-height: 1;
    letter-spacing: -0.025em;
    font-feature-settings: "tnum", "zero";
}

.budget-hero-num .currency {
    color: var(--ink-faint);
    font-weight: 500;
    font-size: 0.55em;
    margin-right: 0.15em;
}

.budget-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--rule-soft);
    font-size: 0.85rem;
}

.budget-line:last-of-type { border-bottom: none; }

.budget-line .label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-quiet);
    font-weight: 500;
}

/* ==========================================================================
   PRIMARY BUTTON
   ========================================================================== */
.btn-ink {
    background: var(--ink);
    border: 1px solid var(--ink);
    color: var(--paper);
    padding: 0.42rem 0.85rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.18s var(--ease-snap), border-color 0.18s var(--ease-snap), opacity 0.18s var(--ease-snap);
}

.btn-ink:hover { background: var(--accent); border-color: var(--accent); }

.btn-ink:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ink .dot {
    width: 6px;
    height: 6px;
    background: var(--accent-mute);
    border-radius: 50%;
}

.btn-ink:hover .dot { background: var(--paper); }

.btn-icon {
    width: 13px;
    height: 13px;
    color: var(--accent-mute);
}

.btn-ink:hover .btn-icon { color: var(--paper); }

/* ==========================================================================
   HTMX INDICATORS
   ========================================================================== */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.18s var(--ease-snap);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--accent);
    font-weight: 500;
}
.htmx-request .htmx-indicator,
.htmx-indicator.htmx-request { opacity: 1; }

/* ==========================================================================
   KPI STRIP — single bordered row of summary tiles.
   Reused on dashboard (4 tiles) and bank page (totals strip).
   `data-accent` on each tile selects amber/teal/plum/ink chrome.
   ========================================================================== */
.kpi-strip {
    display: grid;
    grid-template-columns: 1.6fr 1fr 1fr 1fr;
    border: 1px solid var(--rule);
    border-radius: 10px;
    background: var(--surface);
    overflow: hidden;
}

.kpi-tile {
    padding: 1.1rem 1.25rem 1.2rem;
    border-right: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    position: relative;
}
.kpi-tile:last-child { border-right: none; }

.kpi-tile::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--ink-faint);
    opacity: 0.5;
}
.kpi-tile[data-accent="amber"]::before { background: var(--accent);   opacity: 1; }
.kpi-tile[data-accent="teal"]::before  { background: var(--accent-2); opacity: 1; }
.kpi-tile[data-accent="plum"]::before  { background: var(--accent-3); opacity: 1; }
.kpi-tile[data-accent="ink"]::before   { background: var(--ink);      opacity: 0.4; }

.kpi-tile-hero {
    background: linear-gradient(180deg, var(--accent-faint), transparent 65%);
}

.kpi-tile[data-accent="teal"] .kpi-num.kpi-num-quiet { color: var(--accent-2); opacity: 0.5; }
.kpi-tile[data-accent="plum"] .kpi-progress-fill     { background: var(--accent-3); }
.kpi-tile[data-accent="plum"] .kpi-num .currency     { color: var(--accent-3); opacity: 0.7; }

.kpi-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-quiet);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.kpi-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: var(--ink-faint);
}
.kpi-tile[data-accent="amber"] .kpi-icon { color: var(--accent); }
.kpi-tile[data-accent="teal"]  .kpi-icon { color: var(--accent-2); }
.kpi-tile[data-accent="plum"]  .kpi-icon { color: var(--accent-3); }
.kpi-tile[data-accent="ink"]   .kpi-icon { color: var(--ink); opacity: 0.65; }

.kpi-num {
    font-family: var(--font-sans);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.022em;
    color: var(--ink);
    line-height: 1;
    font-feature-settings: "tnum", "zero";
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-num-hero {
    font-size: 2.4rem;
    letter-spacing: -0.03em;
}

.kpi-num .currency {
    color: var(--ink-faint);
    font-weight: 500;
    margin-right: 0.05em;
}
.kpi-num-hero .currency { font-size: 0.6em; }

.kpi-num-frac {
    color: var(--ink-faint);
    font-size: 0.62em;
    font-weight: 500;
    margin-left: 0.1em;
}

.kpi-num-quiet { color: var(--ink-faint); }

.kpi-num-verdict {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.kpi-asset {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
    letter-spacing: 0.01em;
}

.kpi-delta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    font-feature-settings: "tnum", "zero";
    letter-spacing: -0.005em;
}
.kpi-delta-pct   { color: inherit; opacity: 0.75; }
.kpi-delta-quiet { color: var(--ink-faint); font-weight: 500; }

.kpi-progress {
    height: 4px;
    background: var(--rule-soft);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.kpi-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.6s var(--ease-out);
}

/* ==========================================================================
   SPARKLINE — inline mini-chart, populated by JS
   ========================================================================== */
.spark {
    width: 100%;
    max-width: 100px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
}

/* ==========================================================================
   NO DATA placeholder
   ========================================================================== */
.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--ink-faint);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    border: 1px dashed var(--rule);
    border-radius: 8px;
}

/* ==========================================================================
   COMPONENT RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
    .block::before { display: none; }
    .kpi-strip { grid-template-columns: 1fr 1fr; }
    .kpi-tile { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
    .kpi-tile:nth-child(2n) { border-right: none; }
    .kpi-tile:nth-last-child(-n+2) { border-bottom: none; }
    .kpi-tile-hero { grid-column: span 2; }
}

@media (max-width: 600px) {
    .kpi-strip { grid-template-columns: 1fr; }
    .kpi-tile { border-right: none; border-bottom: 1px solid var(--rule); }
    .kpi-tile:last-child { border-bottom: none; }
    .kpi-tile-hero { grid-column: span 1; }
    .kpi-num-hero { font-size: 2rem; }
}


/* ============================================================================
   Bank module — status pill, tab nav, modal.
   ============================================================================ */

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.status-pill-ok       { color: var(--ink-quiet); background: var(--rule-soft); }
.status-pill-broken   { color: var(--loss); background: var(--loss-soft); }
.status-pill-disabled { color: var(--ink-faint); background: var(--rule-soft); }

.status-detail-row td {
    border-top: none !important;
    padding-top: 0 !important;
    font-size: 0.85rem;
}

.tab-nav {
    display: inline-flex;
    gap: 0.25rem;
}
.tab {
    color: var(--ink-quiet);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    text-decoration: none;
    transition: color 0.15s var(--ease-out);
}
.tab:hover { color: var(--ink); }
.tab-active {
    color: var(--ink);
    border-bottom: 2px solid var(--accent);
    border-radius: 0;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 22, 17, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal-form {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    min-width: 420px;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.modal-form h3 { font-family: var(--font-serif); font-style: italic; margin-bottom: 0.5rem; }
.modal-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--ink-quiet);
}
.modal-form input[type="text"], .modal-form input[type="file"], .modal-form select {
    border: 1px solid var(--rule);
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}
.pager a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.pager a:hover { color: var(--accent); }


/* ============================================================================
   BANK MODULE — Almanac dashboard
   The bank page is a sibling to the crypto page: same Plex+cream foundation,
   warmer chroma, more illustrative widgets. All styles below are scoped to
   classes that only appear on /bank.
   ============================================================================ */

/* ---------- 01 · Hero ---------------------------------------------------- */

.bank-hero { padding-top: 0; }

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: 2.25rem;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.hero-grid::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(60% 80% at 0% 0%, rgba(217, 119, 6, 0.10), transparent 60%),
        radial-gradient(50% 70% at 100% 100%, rgba(13, 148, 136, 0.08), transparent 60%);
    pointer-events: none;
}

.hero-cash, .hero-month {
    position: relative;
    padding: 1.6rem 1.75rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.hero-cash {
    border-right: 1px solid var(--rule);
}

.hero-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-quiet);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}
.hero-eyebrow em {
    font-family: var(--font-serif);
    font-style: italic;
    text-transform: none;
    color: var(--ink-mute);
    letter-spacing: -0.005em;
}
.hero-eyebrow-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.hero-amount {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: clamp(2.6rem, 5.5vw, 4.25rem);
    line-height: 0.95;
    letter-spacing: -0.035em;
    color: var(--ink);
    font-feature-settings: "tnum", "zero";
    margin-top: 0.2rem;
}
.hero-amount .hero-cur {
    color: var(--accent);
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 500;
    font-size: 0.55em;
    margin-right: 0.18em;
    vertical-align: 0.15em;
}
.hero-amount .hero-frac {
    color: var(--ink-faint);
    font-weight: 500;
    font-size: 0.4em;
    margin-left: 0.08em;
    letter-spacing: -0.02em;
    vertical-align: 0.4em;
}

.hero-delta-row {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-top: 0.1rem;
}
.hero-delta {
    font-weight: 600;
    font-feature-settings: "tnum";
    letter-spacing: -0.005em;
}
.hero-delta.positive { color: var(--gain); }
.hero-delta.negative { color: var(--loss); }
.hero-delta-pct { color: var(--ink-mute); font-weight: 500; }
.hero-delta-meta {
    margin-left: auto;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-quiet);
    font-weight: 500;
}

.hero-spark {
    margin-top: 0.6rem;
    height: 64px;
    overflow: hidden;
    border-radius: 6px;
}
.hero-spark .bank-sparkline {
    width: 100%;
    height: 100%;
    display: block;
}
.hero-spark-axis {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    margin-top: 0.35rem;
}

/* Right column — month strip */
.hero-month {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.0));
}
.month-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-quiet);
    font-weight: 500;
}
.month-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.month-stat {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 9px;
    padding: 0.7rem 0.8rem 0.75rem;
    position: relative;
    overflow: hidden;
}
.month-stat::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px;
}
.month-stat[data-tone="in"]::before   { background: var(--gain); }
.month-stat[data-tone="out"]::before  { background: var(--loss); }
.month-stat[data-tone="net"]::before  { background: var(--accent); }
.month-stat[data-tone="rate"]::before { background: var(--accent-3); }

.ms-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-quiet);
    font-weight: 500;
}
.ms-num {
    font-family: var(--font-sans);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-top: 0.2rem;
    font-feature-settings: "tnum", "zero";
}
.ms-num.positive { color: var(--gain); }
.ms-num.negative { color: var(--loss); }
.ms-cur {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    margin-top: 0.1rem;
}
.ms-pct { font-size: 0.6em; color: var(--ink-faint); margin-left: 0.1em; }
.ms-bar {
    margin-top: 0.4rem;
    height: 4px;
    background: var(--rule-soft);
    border-radius: 999px;
    overflow: hidden;
}
.ms-bar > span {
    display: block;
    height: 100%;
    background: var(--accent-3);
    border-radius: 999px;
    transition: width 0.6s var(--ease-out);
}

.month-meta {
    margin-top: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--ink-quiet);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

@media (max-width: 1100px) {
    /* Stacked: the column gap would open a void between the two halves. */
    .hero-grid { grid-template-columns: 1fr; gap: 0; }
    .hero-cash { border-right: none; border-bottom: 1px solid var(--rule); }
}

/* ---------- 02 · Cash flow ---------------------------------------------- */

.cashflow-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.25rem 1.4rem 1rem;
}

.cashflow-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    align-items: end;
    height: 220px;
}

.cf-col {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
    gap: 0.55rem;
}

.cf-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    height: 100%;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1px;
}

.cf-bar {
    width: 22px;
    border-radius: 4px 4px 0 0;
    transition: transform 0.2s var(--ease-snap);
    position: relative;
    min-height: 2px;
}
.cf-bar:hover { transform: translateY(-2px); }
.cf-bar-in {
    background: linear-gradient(180deg, var(--gain), #166534);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}
.cf-bar-out {
    background: linear-gradient(180deg, #f87171, var(--loss));
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.cf-axis {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.cf-net {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    font-feature-settings: "tnum";
    letter-spacing: -0.005em;
}
.cf-net.positive { color: var(--gain); }
.cf-net.negative { color: var(--loss); }
.cf-month {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--ink-quiet);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

.cashflow-legend {
    margin-top: 0.9rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.cfl { display: inline-flex; align-items: center; gap: 0.4rem; }
.cfl-swatch { width: 10px; height: 10px; border-radius: 2px; }
.cfl-swatch-in  { background: var(--gain); }
.cfl-swatch-out { background: var(--loss); }

/* ---------- 03 · Categories + merchants --------------------------------- */

.cat-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.5rem 1.5rem 1.4rem;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
    align-items: center;
}

.cat-donut-wrap {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}
.cat-donut-wrap svg.bank-donut {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.04));
}
.cat-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}
.cdc-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-quiet);
    font-weight: 500;
}
.cdc-amount {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1.45rem;
    letter-spacing: -0.025em;
    color: var(--ink);
    font-feature-settings: "tnum";
    margin-top: 0.2rem;
}
.cdc-meta {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.2rem;
    font-weight: 500;
}

.cat-legend {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem 1.2rem;
}
.cat-legend li {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    gap: 0.6rem;
    align-items: baseline;
    padding: 0.32rem 0;
    border-bottom: 1px dashed var(--rule-soft);
    font-size: 0.86rem;
}
.cat-legend li:last-child { border-bottom: none; }
.cat-swatch {
    width: 10px; height: 10px;
    border-radius: 2px;
    background: var(--cat-color);
    transform: translateY(-2px);
}
.cat-name {
    color: var(--ink);
    font-weight: 500;
}
.cat-amount { color: var(--ink); font-weight: 600; font-size: 0.85rem; }
.cat-pct { font-size: 0.78rem; min-width: 2.6em; text-align: right; }

@media (max-width: 800px) {
    .cat-card { grid-template-columns: 1fr; }
    .cat-legend { grid-template-columns: 1fr; }
}

.merchant-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.2rem 1.4rem 1.1rem;
}
.merchant-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.merchant-row {
    display: grid;
    grid-template-columns: 30px 26px 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 0.7rem;
    row-gap: 0.3rem;
    align-items: center;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--rule-soft);
}
.merchant-row:last-child { border-bottom: none; }
.merchant-rank {
    grid-row: 1 / 3;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.04em;
}
.merchant-row .cat-dot {
    grid-row: 1 / 3;
}
.merchant-meta { min-width: 0; }
.merchant-name {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink);
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.merchant-sub {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.merchant-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--ink);
    text-align: right;
    font-feature-settings: "tnum";
}
.merchant-amount .cur { color: var(--ink-faint); font-weight: 500; font-size: 0.85em; }
.merchant-bar {
    grid-column: 2 / 5;
    height: 4px;
    background: var(--rule-soft);
    border-radius: 999px;
    overflow: hidden;
}
.merchant-bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.6s var(--ease-out);
}

/* ---------- 04 · Recurring + heatmap ------------------------------------ */

.recurring-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.3rem 1.4rem 1.1rem;
}
.recurring-hero {
    border-bottom: 1px solid var(--rule-soft);
    padding-bottom: 1rem;
    margin-bottom: 0.8rem;
}
.rh-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-quiet);
    font-weight: 500;
}
.rh-amount {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: -0.025em;
    color: var(--accent-3);
    font-feature-settings: "tnum";
    line-height: 1;
    margin-top: 0.3rem;
}
.rh-amount .rh-meta {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.45em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.rh-sub {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--ink-quiet);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.4rem;
    font-weight: 500;
}
.recurring-list {
    list-style: none;
    display: flex;
    flex-direction: column;
}
.recurring-list li {
    display: grid;
    grid-template-columns: 16px 1fr auto auto;
    gap: 0.7rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--rule-soft);
    font-size: 0.86rem;
}
.recurring-list li:last-child { border-bottom: none; }
.rec-name {
    color: var(--ink);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rec-cadence {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.rec-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--ink);
    font-feature-settings: "tnum";
}

.heatmap-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 1.3rem 1.4rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.heatmap-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}
.hm-title {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.hm-sub {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.2rem;
    font-weight: 500;
}
.hm-legend {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--ink-quiet);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.hm-leg-cell {
    width: 12px; height: 12px;
    background: var(--accent);
    border-radius: 3px;
}
.hm-leg-label { padding: 0 0.2rem; }

.heatmap-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 1fr);
    gap: 4px;
    aspect-ratio: 13 / 7;
    width: 100%;
}
.hm-cell {
    background: var(--accent);
    /* Floor at 0.06 so cells with no spend are visible as a faint cream square. */
    opacity: calc(0.06 + var(--hm-i, 0) * 0.94);
    border-radius: 3px;
    transition: transform 0.15s var(--ease-snap);
    cursor: default;
}
.hm-cell:hover {
    transform: scale(1.18);
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}
.heatmap-axis {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.hm-col-label {
    text-align: left;
    height: 1em;
    line-height: 1;
    overflow: hidden;
}

/* ---------- 05 · Accounts strip ----------------------------------------- */

.account-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.85rem;
}
.account-tile {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 11px;
    padding: 1rem 1.1rem 1rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.18s var(--ease-snap), border-color 0.18s var(--ease-snap);
    display: block;
    color: inherit;
    text-decoration: none;
}
.account-tile::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--tile-color, var(--accent));
}
.account-tile:hover {
    transform: translateY(-2px);
    border-color: var(--rule-strong);
}
.account-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.account-tile-tag {
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 0.18rem 0.45rem;
    border-radius: 999px;
}
.account-tile-cur {
    font-size: 0.62rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
}
.account-tile-name {
    margin-top: 0.6rem;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink);
    letter-spacing: -0.005em;
}
.account-tile-balance {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1.55rem;
    color: var(--ink);
    letter-spacing: -0.025em;
    line-height: 1;
    margin-top: 0.4rem;
    font-feature-settings: "tnum", "zero";
}
.account-tile-cents {
    color: var(--ink-faint);
    font-weight: 500;
    font-size: 0.5em;
    margin-left: 0.05em;
}
.account-tile-foot {
    margin-top: 0.55rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- 06 · Connections grid --------------------------------------- */

.connections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.85rem;
}
.conn-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 0.95rem 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    border-left: 3px solid var(--rule-strong);
}
.conn-status-ok       { border-left-color: var(--gain); }
.conn-status-broken   { border-left-color: var(--loss); }
.conn-status-disabled { border-left-color: var(--ink-faint); }
.conn-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
}
.conn-name {
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--ink);
    font-size: 0.95rem;
    letter-spacing: -0.005em;
}
.conn-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 0.8rem;
    font-size: 0.78rem;
}
.conn-meta div { display: flex; flex-direction: column; gap: 0.1rem; }
.conn-meta dt {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    font-weight: 500;
}
.conn-meta dd { font-size: 0.78rem; color: var(--ink); }
.conn-broken {
    margin-top: 0.3rem;
    padding: 0.55rem 0.7rem;
    background: var(--loss-soft);
    border-radius: 6px;
    color: var(--loss);
    font-size: 0.78rem;
    font-family: var(--font-sans);
}
.conn-broken code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
}

/* ---------- 07 · Transaction list (recent + full ledger) ---------------- */

.tx-day {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 0 0.5rem;
}
.tx-day:first-child { padding-top: 0.6rem; }
.tx-day-label {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--accent);
    letter-spacing: -0.005em;
    text-transform: none;
}
.tx-day-rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--rule), transparent 80%);
}
.tx-row {
    border-bottom: 1px solid var(--rule-soft);
}
.tx-line {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 8.5rem 8rem 7rem;
    gap: 0.75rem;
    align-items: center;
    min-height: 40px;
    padding: 0 0.5rem;
    cursor: pointer;
    list-style: none;
    transition: background 0.12s var(--ease-snap);
}
.tx-line::-webkit-details-marker { display: none; }
.tx-line:hover,
.tx-row[open] > .tx-line { background: var(--paper-tint); }
.tx-name {
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--ink);
    font-size: 0.9rem;
    letter-spacing: -0.005em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-motif {
    font-weight: 400;
    color: var(--ink-quiet);
}
.tx-cat,
.tx-acct {
    font-size: 0.75rem;
    color: var(--ink-quiet);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-cat-other { color: var(--ink-faint); font-style: italic; }
.tx-acct { font-family: var(--font-mono); font-size: 0.7rem; }
.tx-amount {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.9rem;
    font-feature-settings: "tnum";
    text-align: right;
    color: var(--ink);
}
.tx-amount.positive { color: var(--gain); }
.tx-amount.negative { color: var(--ink); }
.tx-amount .cur {
    color: var(--ink-faint);
    font-size: 0.78em;
}
.tx-detail {
    padding: 0.6rem 0.5rem 0.9rem calc(18px + 1.25rem);
    background: var(--paper-tint);
    border-top: 1px dashed var(--rule);
}
.tx-detail-loading { color: var(--ink-faint); font-size: 0.8rem; }
.tx-facts {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 0.25rem 0.75rem;
    margin: 0 0 0.7rem;
    font-size: 0.8rem;
}
.tx-facts dt { color: var(--ink-quiet); }
.tx-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.tx-day-net {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-feature-settings: "tnum";
}
.tx-day-net.positive { color: var(--gain); }
.tx-day-net.negative { color: var(--loss); }

.see-all {
    margin-top: 0.85rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.see-all a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1px;
}
.see-all a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Category dot (used everywhere) ------------------------------ */

.cat-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--cat-color, var(--ink-faint));
    color: #fff;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: -0.02em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10), 0 0 0 2px var(--surface);
    line-height: 1;
}
.cat-dot-sm {
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10), 0 0 0 1.5px var(--surface);
}

/* ---------- Header pulse text ------------------------------------------ */

#sync-indicator { margin-left: 0.5rem; }

/* On the bank page, the header_info slot carries a friendly pulse line —
   give it a touch more presence than the default mono slug. */
.header-meta > span:not(.dot-sep):not(.tab-nav) {
    font-family: var(--font-mono);
    text-transform: none;
    letter-spacing: 0.02em;
    color: var(--ink-mute);
}

/* ---------- Responsive -------------------------------------------------- */

@media (max-width: 900px) {
    .cashflow-grid { gap: 0.5rem; height: 180px; }
    .cf-bar { width: 14px; }
    .cat-card { padding: 1.25rem; }
    .heatmap-grid { aspect-ratio: 11 / 7; }
}
@media (max-width: 600px) {
    .month-stats { grid-template-columns: repeat(2, 1fr); }
    .hero-cash, .hero-month { padding: 1.1rem 1.1rem 1rem; }
    .cashflow-grid { grid-template-columns: repeat(6, 1fr); }
    .cf-bar { width: 10px; }
    .cat-card { padding: 1rem; }
    .cat-donut-wrap { width: 160px; height: 160px; }
}

/* ----- Bank ledger: lazy month sections + date scrubber ----- */
.tx-scroll {
    display: flex;
    flex-direction: column;
    /* Right gutter so the fixed scrubber never overlaps row content. */
    padding-right: 56px;
}
.tx-month {
    display: flex;
    flex-direction: column;
}
.tx-month-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    padding: 1.2rem 0 0.3rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 0.2rem;
}
.tx-month-n {
    color: var(--ink-faint);
    font-weight: 500;
}
.tx-month-net {
    font-feature-settings: "tnum";
    letter-spacing: 0;
}
.tx-month-net.positive { color: var(--gain); }
.tx-month-net.negative { color: var(--loss); }
@media (max-width: 700px) {
    .tx-line { grid-template-columns: 18px minmax(0, 1fr) auto; gap: 0.6rem; }
    .tx-cat, .tx-acct { display: none; }
    .tx-month-body { padding: 0; }
    .tx-detail { padding-left: 0.5rem; }
    .tx-facts { grid-template-columns: 5.5rem minmax(0, 1fr); }
}
.tx-month-body {
    display: flex;
    flex-direction: column;
    padding: 0 1.2rem;
}
.tx-month-placeholder {
    background:
        repeating-linear-gradient(
            transparent 0 52px,
            var(--rule-soft) 52px 53px
        );
    opacity: 0.4;
}

/* On the ledger page the scrubber replaces the native scrollbar — hide
   it so the right edge shows a single scroll affordance. */
html.tx-scrub-page {
    scrollbar-width: none;
}
html.tx-scrub-page::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* The scrubber is a wide transparent strip down the right side: hovering
   anywhere in it shows the ns-resize (vertical-arrow) cursor and a
   click/drag scrubs. The track/thumb/bubble stay pinned to the right. */
.tx-scrubber {
    position: fixed;
    top: 120px;
    bottom: 24px;
    right: 0;
    /* Only the track itself: the rows to its left are clickable. Matches
       the `.tx-scroll` right gutter. */
    width: 56px;
    z-index: 40;
    cursor: ns-resize;
}
.tx-scrubber-track {
    position: absolute;
    inset: 0 0 0 auto;
    width: 50px;
    border-left: 1px solid var(--rule);
    background: linear-gradient(90deg, transparent, var(--surface) 60%);
}
.tx-scrubber-tick {
    position: absolute;
    right: 8px;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--ink-faint);
    letter-spacing: 0.04em;
}
.tx-scrubber-thumb {
    position: absolute;
    right: 4px;
    width: 6px;
    height: 34px;
    border-radius: 4px;
    background: var(--accent);
}
/* Persistent month label riding alongside the thumb. Always visible so
   the user can tell where they are; `.active` bumps emphasis while
   scrolling or scrubbing. */
.tx-scrubber-bubble {
    position: absolute;
    right: 58px;
    transform: translateY(-25%);
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--rule);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: background 0.12s var(--ease-snap),
        color 0.12s var(--ease-snap);
    pointer-events: none;
}
.tx-scrubber-bubble.active {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}
@media (max-width: 700px) {
    .tx-scroll { padding-right: 36px; }
    .tx-scrubber { width: 36px; }
    .tx-scrubber-track { width: 36px; }
    .tx-scrubber-tick { right: 4px; font-size: 0.5rem; }
    .tx-scrubber-bubble { right: 40px; font-size: 0.65rem; }
}

.acct-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.4rem;
}
.acct-pill {
    font-size: 0.78rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    color: var(--ink-mute);
    text-decoration: none;
    background: var(--surface);
}
.acct-pill:hover { border-color: var(--accent); color: var(--ink); }
.acct-pill-active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--surface);
}

.stale-banner {
    margin-bottom: 1.2rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--ink);
    font-size: 0.85rem;
}

/* Ledger filter bar. While results are shown, the month-by-month ledger
   and its scrubber step aside. */
.tx-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.4rem 56px 0.6rem 0;
}
.tx-filters input,
.tx-filters select {
    font: inherit;
    font-size: 0.82rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--rule);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
}
.tx-filters input[type="search"] { flex: 1 1 16rem; }
.tx-more-filters { align-self: center; }
.tx-more-filters[open] { flex-basis: 100%; }
.tx-more-filters > summary {
    font-size: 0.78rem;
    color: var(--ink-quiet);
    cursor: pointer;
}
.tx-more-filters[open] > summary { color: var(--ink); margin-bottom: 0.4rem; }
.tx-range-fields { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; }
.tx-filter-range {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--ink-quiet);
}
.tx-filter-range input[type="number"] { width: 5.5rem; }
#tx-search-results:empty { display: none; }
.block:has(#tx-search-results:not(:empty)) #tx-scroll { display: none; }
/* visibility, not display: tx-scrubber.js sets an inline display. */
body:has(#tx-search-results:not(:empty)) #tx-scrubber { visibility: hidden; }
.tx-search-summary {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--ink-quiet);
    padding: 0.4rem 1.2rem;
    border-bottom: 1px solid var(--rule);
}
.tx-search-summary .positive { color: var(--gain); margin-right: 0.6rem; }
.tx-search-summary .negative { color: var(--ink); }
@media (max-width: 700px) {
    .tx-filters { margin-right: 36px; }
    .tx-filters select { flex: 1 1 8rem; }
}

/* Category correction form, inside the ledger row's detail panel */
.tx-cat-form {
    display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
    font-size: 0.78rem;
}
.tx-cat-form select { font: inherit; padding: 0.15rem 0.3rem; }
.tx-cat-form label { display: inline-flex; gap: 0.2rem; align-items: center; }
