/* ==========================================================================
   Page-specific skins: Reports, Import/Export, Help,
   Categories.  Loaded via {% block head_extra %} AFTER styles(.mobile).css
   and components.css, so equal-specificity rules here win by source order.
   tour.css loads after this file — .tour-launch-card overrides are therefore
   scoped (.page-help .tour-launch-card) for higher specificity.

   Every rule is scoped under a page wrapper class:
       .page-reports  .page-ie  .page-help  .page-categories
   All colors come from tokens.css custom properties — no hardcoded colors —
   so dark mode works automatically.
   ========================================================================== */

/* ==========================================================================
   1. REPORTS  (.page-reports)
   ========================================================================== */

.page-reports {
    padding: 22px 18px;
}

.page-reports > * {
    max-width: 1240px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Header row: title + range inputs + month chips + actions --- */
.page-reports .reports-header {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 14px 18px;
    margin-bottom: 16px;
}

.page-reports .reports-header h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 12px;
}

.page-reports .reports-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

/* Month quick-nav as chips */
.page-reports .month-quick-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.page-reports .month-quick-nav .btn,
.page-reports .month-quick-nav .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px !important;
    font-size: 12.5px !important;
    font-weight: 600;
    line-height: 1.6;
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--ink-secondary);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s ease, color .12s ease;
}

.page-reports .month-quick-nav .btn:hover,
.page-reports .month-quick-nav .btn-secondary:active {
    background: var(--bg-hover);
    color: var(--ink);
}

.page-reports .report-month-label {
    font-weight: 600;
    font-size: 13.5px;
    min-width: 120px;
    text-align: center;
    color: var(--ink);
}

/* Date range */
.page-reports .date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-reports .date-range-picker label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
}

.page-reports .date-range-picker input[type="date"] {
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
    background: var(--bg-surface);
    color: var(--ink);
}

.page-reports .date-range-picker input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Action buttons */
.page-reports .reports-controls .btn-primary,
.page-reports .reports-controls .btn-secondary:not(.btn-sm),
.page-reports .reports-controls .btn-excel {
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-btn);
    line-height: 1.5;
    cursor: pointer;
}

.page-reports .reports-controls #applyFilters {
    background: var(--accent);
    color: var(--ink-on-accent);
    border: none;
    box-shadow: 0 2px 6px -1px oklch(0.52 0.14 256 / 0.4);
}

.page-reports .reports-controls #applyFilters:hover {
    background: var(--accent-hover);
}

.page-reports .reports-controls #exportPdf {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
}

.page-reports .reports-controls #exportPdf:hover,
.page-reports .reports-controls #exportPdf:active {
    background: var(--bg-hover);
}

/* Export XLSX: positive outline (!important beats styles_mobile's !important) */
.page-reports .btn-excel {
    background: transparent !important;
    color: var(--positive) !important;
    border: 1px solid var(--positive) !important;
    border-radius: var(--radius-btn);
    font-weight: 600;
}

.page-reports .btn-excel:hover,
.page-reports .btn-excel:active {
    background: var(--positive-bg) !important;
    color: var(--positive) !important;
}

/* Mobile button group (template uses .button-group on mobile) */
.page-reports .button-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.page-reports .button-group button {
    flex: 1;
    border-radius: var(--radius-btn);
    font-weight: 600;
}

.page-reports .button-group #exportPdf {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
}

/* --- Balance summary: grid of stat tiles --- */
.page-reports .report-balance-summary {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    min-height: auto !important;
}

.page-reports .report-balance-summary > h2 {
    margin: 4px 2px 10px;
}

.page-reports .balance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
    padding: 0;
}

.page-reports .balance-stat-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 13px 15px;
}

.page-reports .balance-stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
}

.page-reports .balance-stat-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 19px;
    color: var(--ink);
    line-height: 1.2;
}

.page-reports .balance-stat-value.stat-success { color: var(--positive); }
.page-reports .balance-stat-value.stat-danger  { color: var(--negative); }
.page-reports .balance-stat-value.negative     { color: var(--negative); }

/* --- Chart cards --- */
.page-reports .reports-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr));
    margin: 16px auto 16px;
}

.page-reports .report-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
}

.page-reports .report-card h2,
.page-reports .table-section h2 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    margin: 0 0 12px;
    border: none;
    padding: 0;
}

/* Balance-summary tile grid keeps its own transparent card, so re-assert */
.page-reports .report-balance-summary h2 {
    margin-bottom: 10px;
}

/* --- Tables --- */
.page-reports .reports-tables {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.page-reports .table-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
    overflow-x: auto;
}

.page-reports .transaction-summary,
.page-reports .recurring-summary {
    overflow-x: auto;
}

.page-reports .transaction-table,
.page-reports .recurring-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 0;
}

.page-reports .transaction-table th,
.page-reports .recurring-table th {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    background: var(--bg-band);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.page-reports .transaction-table td,
.page-reports .recurring-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--ink);
}

/* Kill legacy zebra striping; keep a clean hover */
.page-reports .transaction-table tr:nth-child(even),
.page-reports .recurring-table tr:nth-child(even) {
    background: transparent;
}

.page-reports .transaction-table tbody tr:hover,
.page-reports .recurring-table tbody tr:hover {
    background: var(--bg-hover);
    opacity: 1;
}

/* Right-aligned mono amounts */
.page-reports .transaction-table th:nth-child(5),
.page-reports .transaction-table th:nth-child(6),
.page-reports .transaction-table td:nth-child(5),
.page-reports .transaction-table td:nth-child(6),
.page-reports .recurring-table th:nth-child(2),
.page-reports .recurring-table th:last-child,
.page-reports .recurring-table td:nth-child(2),
.page-reports .recurring-table td:last-child {
    text-align: right;
}

.page-reports .transaction-table td:nth-child(5),
.page-reports .transaction-table td:nth-child(6),
.page-reports .recurring-table td:nth-child(2),
.page-reports .recurring-table td:last-child {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.page-reports .transaction-table .negative,
.page-reports .recurring-table .negative {
    color: var(--negative);
}

.page-reports .transaction-table .balance-row td {
    color: var(--ink-tertiary);
    font-style: italic;
}

/* Empty states — shown when JS leaves the tbody with no rows */
.page-reports .reports-empty {
    display: none;
}

.page-reports .transaction-summary:has(tbody:empty) table,
.page-reports .recurring-summary:has(tbody:empty) table {
    display: none;
}

.page-reports .transaction-summary:has(tbody:empty) .reports-empty,
.page-reports .recurring-summary:has(tbody:empty) .reports-empty {
    display: block;
}

@media (max-width: 640px) {
    .page-reports {
        padding: 14px 12px;
    }

    .page-reports .reports-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .page-reports .month-quick-nav {
        justify-content: center;
    }

    .page-reports .balance-summary-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .page-reports .balance-stat-item {
        padding: 10px 12px;
    }

    .page-reports .balance-stat-value {
        font-size: 16px;
    }

    .page-reports .report-card {
        min-height: auto;
    }
}

/* ==========================================================================
   1b. SEARCH  (.page-search)
   Filter bar + a single results table — deliberately reuses the visual
   language of .page-reports (same card/header/table shapes) rather than
   inventing a new one.
   ========================================================================== */

.page-search {
    padding: 22px 18px;
}

.page-search > * {
    max-width: 1240px;
    margin-left: auto;
    margin-right: auto;
}

.page-search .search-header {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 14px 18px;
    margin-bottom: 16px;
}

.page-search .search-header h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 12px;
}

.page-search .search-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px 14px;
}

.page-search .search-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.page-search .search-field-query { flex: 1 1 220px; min-width: 180px; }
.page-search .search-field-amount { flex: 0 0 auto; }

.page-search .search-field label,
.page-search .date-range-picker label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
}

.page-search .search-field input[type="text"],
.page-search .search-field input[type="number"],
.page-search .search-field select,
.page-search .search-field input[type="date"],
.page-search .date-range-picker input[type="date"] {
    padding: 6px 10px;
    font-size: 12.5px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
    background: var(--bg-surface);
    color: var(--ink);
    font-family: var(--font-ui);
}

.page-search .search-field input[type="number"] {
    font-family: var(--font-mono);
    width: 90px;
}

.page-search .date-range-picker input[type="date"] {
    font-family: var(--font-mono);
}

.page-search .search-field input:focus,
.page-search .search-field select:focus,
.page-search .date-range-picker input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.page-search .date-range-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-search .search-amount-range {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-tertiary);
}

.page-search .search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.page-search .search-actions .btn-primary,
.page-search .search-actions .btn-secondary {
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-btn);
    line-height: 1.5;
    cursor: pointer;
}

.page-search .search-actions .btn-primary {
    background: var(--accent);
    color: var(--ink-on-accent);
    border: none;
    box-shadow: 0 2px 6px -1px oklch(0.52 0.14 256 / 0.4);
}

.page-search .search-actions .btn-primary:hover { background: var(--accent-hover); }

.page-search .search-actions .btn-secondary {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
}

.page-search .search-actions .btn-secondary:hover { background: var(--bg-hover); }

.page-search .table-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
    overflow-x: auto;
}

.page-search .search-load-more {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 9px 15px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-btn);
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    cursor: pointer;
}

.page-search .search-load-more:hover { background: var(--bg-hover); }

.page-search .search-results-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.page-search .search-results-head h2 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    margin: 0;
}

.page-search .search-results-count {
    font-size: 12px;
    color: var(--ink-tertiary);
}

.page-search .transaction-summary { overflow-x: auto; }

.page-search .transaction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.page-search .transaction-table th {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    background: var(--bg-band);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.page-search .transaction-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.page-search .transaction-table th.sortable:hover {
    color: var(--ink);
}

.page-search .transaction-table th.sort-active {
    color: var(--accent-text);
}

.page-search .transaction-table th .sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 9px;
}

.page-search .transaction-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--ink);
}

.page-search .transaction-table tbody tr {
    cursor: pointer;
}

.page-search .transaction-table tbody tr:hover {
    background: var(--bg-hover);
}

.page-search .transaction-table th:nth-child(5),
.page-search .transaction-table td:nth-child(5) {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.page-search .transaction-table .negative { color: var(--negative); }

.page-search .transaction-table td:nth-child(6) .bc-tag { margin-left: 0; margin-right: 6px; }
.page-search .transaction-table td:nth-child(6) .bc-tag:last-child { margin-right: 0; }

.page-search .reports-empty { display: none; }

.page-search .transaction-summary:has(tbody:empty) table { display: none; }
.page-search .transaction-summary:has(tbody:empty) .reports-empty { display: block; }

@media (max-width: 900px) {
    .page-search .search-controls { align-items: stretch; }
    .page-search .search-actions { margin-left: 0; width: 100%; }
    .page-search .search-actions .btn-primary,
    .page-search .search-actions .btn-secondary { flex: 1; }
}

@media (max-width: 640px) {
    .page-search {
        padding: 14px 12px;
    }

    .page-search .search-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .page-search .search-field input,
    .page-search .search-field select {
        width: 100%;
    }
}

/* --- Mobile-only pieces (search_mobile.html doesn't render the header
       card / table — just these) --- */
.page-search .search-mobile-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.page-search .search-mobile-top h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}

.page-search .search-mobile-top input[type="text"] {
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
    background: var(--bg-surface);
    color: var(--ink);
    font-family: var(--font-ui);
}

.page-search .search-mobile-top input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.page-search .search-filters-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
    overflow: hidden;
}

.page-search .search-filters-toggle summary {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
}

.page-search .search-filters-toggle summary::-webkit-details-marker { display: none; }

.page-search .search-filters-toggle summary::after {
    content: '▾';
    float: right;
    color: var(--ink-tertiary);
}

.page-search .search-filters-toggle[open] summary::after { content: '▴'; }

.page-search .search-filters-toggle .search-controls {
    flex-direction: column;
    align-items: stretch;
    padding: 0 16px 14px;
}

.page-search .search-filters-toggle .search-field input,
.page-search .search-filters-toggle .search-field select {
    width: 100%;
}

/* short fields two to a line, so some results show under the open filters */
.page-search .search-filters-toggle .search-field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.page-search .search-filters-toggle .search-field-pair .search-field { min-width: 0; }
.page-search .search-filters-toggle .search-field-pair input,
.page-search .search-filters-toggle .search-field-pair select { min-width: 0; }

.page-search .search-filters-toggle .search-actions {
    margin-left: 0;
    margin-top: 4px;
}

.page-search .search-filters-toggle .search-actions .btn-primary,
.page-search .search-filters-toggle .search-actions .btn-secondary {
    flex: 1;
}

.page-search .search-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 2px 8px;
}

.page-search .search-results-bar .search-results-count { margin: 0; }

.page-search .search-sort-select {
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
    background: var(--bg-surface);
    color: var(--ink-secondary);
    font-family: var(--font-ui);
}

.page-search .search-results-count {
    font-size: 12px;
    color: var(--ink-tertiary);
    margin: 0 2px 8px;
}

.page-search .search-results-wrap { position: relative; }

.page-search .search-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.page-search .search-result-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 12px 14px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: var(--font-ui);
}

.page-search .search-result-card:active { background: var(--bg-hover); }

.page-search .search-result-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page-search .search-result-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.page-search .search-result-desc {
    min-width: 0;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-search .search-result-amt {
    flex: none;
    font-family: var(--font-mono);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-secondary);
}

.page-search .search-result-amt.positive { color: var(--positive); }

.page-search .search-result-bottom {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-top: 1px;
}

.page-search .search-result-sub {
    flex: 1;
    min-width: 0;
    font-size: 11.5px;
    color: var(--ink-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-search .search-result-tags { flex: none; }

.page-search .search-results-wrap .reports-empty { display: none; }
.page-search .search-results-wrap:has(.search-results-list:empty) .reports-empty { display: block; }
.page-search .search-results-wrap:has(.search-results-list:empty) .search-results-list { display: none; }

/* ==========================================================================
   3. IMPORT / EXPORT  (.page-ie)
   ========================================================================== */

/* Desktop <main> is overflow:hidden — make the page itself the scroller */
.page-ie {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 22px 18px;
    box-sizing: border-box;
}

.page-ie .ie-shell {
    max-width: 1100px;
    margin: 0 auto;
}

/* The page head: the way back to Account Settings, then the title */
.page-ie .ie-page-head {
    margin-bottom: 18px;
}

.page-ie .ie-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-secondary);
    text-decoration: none;
}

.page-ie .ie-back:hover {
    color: var(--ink);
}

.page-ie .ie-back i {
    font-size: 11px;
}

.page-ie .ie-page-head h1 {
    margin: 6px 0 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
}

.mobile-main .page-ie .ie-page-head {
    margin-bottom: 14px;
}

.mobile-main .page-ie .ie-page-head h1 {
    font-size: 19px;
}

/* Cards */
.page-ie .ie-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 20px;
}

.page-ie .ie-card h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 6px;
}

.page-ie .ie-card > p {
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-secondary);
}

/* Drop zone */
.page-ie .ie-drop-zone {
    border: 2px dashed var(--border-strong);
    border-radius: 16px;
    background: var(--bg-page);
    padding: 44px 16px;
    transition: border-color .15s ease, background-color .15s ease;
}

.page-ie .ie-drop-zone.ie-drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.page-ie .ie-upload-icon {
    color: var(--ink-tertiary);
    font-size: 2.3rem;
}

.page-ie .ie-drop-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

.page-ie .ie-drop-sub {
    color: var(--ink-tertiary);
    font-size: 12.5px;
}

.page-ie .ie-supported {
    color: var(--ink-tertiary);
    font-size: 12px;
}

.page-ie .ie-upload-spinner {
    color: var(--ink-secondary);
}

/* Stats bar + filter badges (re-tokened) */
.page-ie .ie-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    border: none;
}

.page-ie .ie-badge.ie-badge-active {
    outline: 2px solid currentColor;
    outline-offset: 1px;
    filter: none;
    font-weight: 700;
}

.page-ie .ie-badge[data-filter]:hover {
    filter: none;
    transform: none;
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.page-ie .ie-badge-new       { background: var(--positive-bg); color: var(--positive); }
.page-ie .ie-badge-dup       { background: var(--negative-bg); color: var(--negative); }
.page-ie .ie-badge-possible  { background: var(--warning-bg);  color: var(--warning); }
.page-ie .ie-badge-recurring { background: var(--accent-soft); color: var(--accent-text); }

.page-ie .ie-filter-status {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
}

.page-ie .ie-filter-label {
    color: var(--accent-text);
    font-size: 12px;
}

.page-ie .ie-show-all-btn {
    border: 1px solid var(--accent);
    color: var(--accent-text);
    font-size: 11.5px;
    background: var(--bg-surface);
}

.page-ie .ie-show-all-btn:hover {
    background: var(--accent);
    color: var(--ink-on-accent);
}

/* Preview table */
.page-ie .ie-table-wrapper {
    border: 1px solid var(--border);
    border-radius: 10px;
}

.page-ie .ie-table {
    font-size: 13px;
}

.page-ie .ie-table th {
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
}

.page-ie .ie-table td {
    padding: 7px 12px;
}

.page-ie .ie-disp-amount,
.page-ie .ie-amount-pos,
.page-ie .ie-amount-neg {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    white-space: nowrap;
}

.page-ie .ie-amount-pos { color: var(--positive); }
.page-ie .ie-amount-neg { color: var(--negative); }

.page-ie .ie-disp-date {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: var(--ink-secondary);
}

/* Row status tints (tokens instead of hardcoded rgba) */
.page-ie .ie-status-duplicate td          { background: var(--negative-bg); }
.page-ie .ie-status-possible_duplicate td { background: var(--warning-bg); }
.page-ie .ie-recurring-member td          { border-left: 3px solid var(--accent); }

.page-ie .ie-group-banner td {
    background: var(--accent-soft);
    border-bottom: 1px solid var(--border);
}

.page-ie .ie-group-banner:not(tr) {
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.page-ie .ie-group-banner-content i { color: var(--accent-text); }
.page-ie .ie-toggle-label           { color: var(--accent-text); }
.page-ie .ie-recur-hint             { color: var(--accent-text); }

.page-ie .ie-select {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--ink);
    padding: 4px 6px;
}

/* Edit button + edit panel (styled like a modal card) */
.page-ie .ie-edit-btn {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--ink-secondary);
    padding: 4px 7px;
}

.page-ie .ie-edit-btn:hover,
.page-ie .ie-edit-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink-on-accent);
}

.page-ie .ie-edit-row > td {
    background: var(--bg-band);
    padding: 10px !important;
}

.page-ie .ie-edit-panel {
    background: var(--bg-raised);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-popover);
    padding: 16px 18px;
}

.page-ie .ie-ep-field label,
.page-ie .ie-ep-field--wide > label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-secondary);
}

.page-ie .ie-ep-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.page-ie .ie-ep-recur-opts {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.page-ie .ie-icon-grid {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.page-ie .ie-icon-opt:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.page-ie .ie-icon-opt.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.page-ie .ie-ep-actions {
    border-top: 1px solid var(--border);
}

/* Mobile edit panel divider */
.page-ie .ie-mobile-ep {
    border-top: 2px solid var(--accent);
}

/* Sticky confirm band */
.page-ie #preview-section .ie-card {
    overflow: visible;
}

.page-ie .ie-confirm-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 16px -20px -20px;
    padding: 12px 20px;
    background: var(--bg-band);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.page-ie .ie-selected-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-secondary);
    font-variant-numeric: tabular-nums;
}

/* Result screen: green check circle */
.page-ie .ie-result-card {
    text-align: center;
    padding: 44px 24px;
}

.page-ie .ie-result-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--positive-bg);
    color: var(--positive);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

.page-ie .ie-result-card h2 {
    margin-bottom: 4px;
}

.page-ie #importResultText {
    color: var(--ink-secondary);
    font-size: 14px;
}

/* Export panel */
.page-ie .ie-export-note {
    background: var(--accent-soft);
    color: var(--ink-secondary);
    border-radius: 10px;
    font-size: 13px;
}

.page-ie .ie-export-note i {
    color: var(--accent-text);
}

.page-ie .ie-export-form label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-secondary);
}

.page-ie .ie-export-form input[type="date"] {
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 7px 10px;
}

/* Mobile preview cards */
.page-ie .ie-mobile-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
}

.page-ie .ie-mobile-card.ie-status-duplicate          { border-left: 4px solid var(--negative); }
.page-ie .ie-mobile-card.ie-status-possible_duplicate { border-left: 4px solid var(--warning); }
.page-ie .ie-mobile-card.ie-recurring-member          { border-left: 4px solid var(--accent); }

.page-ie .ie-card-header {
    background: var(--bg-band);
    border-bottom: 1px solid var(--border);
}

.page-ie .ie-card-date {
    color: var(--ink-secondary);
}

@media (max-width: 640px) {
    .page-ie {
        padding: 14px 12px;
    }

    .page-ie .ie-card {
        padding: 16px;
    }

    .page-ie .ie-confirm-bar {
        margin: 14px -16px -16px;
        padding: 11px 16px;
    }
}

/* ==========================================================================
   4. HELP  (.page-help)
   ========================================================================== */

.page-help {
    padding: 26px 18px;
}

.page-help > * {
    max-width: 780px;
    margin-left: auto;
    margin-right: auto;
}

.page-help h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 16px;
}

/* Tour launcher card (overrides tour.css, which loads after this file) */
.page-help .tour-launch-card {
    background: var(--accent-soft);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius-card-lg);
    box-shadow: var(--shadow-card);
    padding: 20px 22px;
    margin-bottom: 16px;
}

.page-help .tour-launch-card .tour-launch-icon {
    font-size: 2rem;
}

.page-help .tour-launch-card .tour-launch-body h3 {
    color: var(--ink);
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.page-help .tour-launch-card .tour-launch-body p {
    color: var(--ink-secondary);
    opacity: 1;
    font-size: 13.5px;
    line-height: 1.5;
}

.page-help .tour-launch-card button {
    background: var(--accent);
    color: var(--ink-on-accent);
    border: none;
    border-radius: var(--radius-btn);
    padding: 10px 20px;
    font-weight: 600;
    font-size: 13.5px;
    box-shadow: 0 2px 6px -1px oklch(0.52 0.14 256 / 0.4);
    transition: background-color .12s ease;
}

.page-help .tour-launch-card button:hover {
    background: var(--accent-hover);
    transform: none;
    box-shadow: 0 2px 6px -1px oklch(0.52 0.14 256 / 0.4);
}

/* Help sections as cards (components.css supplies the card surface) */
.page-help .help-section {
    padding: 18px 22px;
    margin-bottom: 14px;
}

.page-help .help-section h2 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    border-bottom: none;
    padding-bottom: 0;
    margin: 0 0 10px;
}

.page-help .help-section p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    margin: 0 0 8px;
}

.page-help .help-section p:last-child {
    margin-bottom: 0;
}

.page-help .help-section ul,
.page-help .help-section ol {
    margin: 0 0 0 20px;
    padding: 0;
}

.page-help .help-section ul ul,
.page-help .help-section ul ol {
    margin-top: 6px;
}

.page-help .help-section li {
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    margin-bottom: 7px;
}

.page-help .help-section li:last-child {
    margin-bottom: 0;
}

.page-help .help-section a {
    color: var(--accent-text);
    font-weight: 500;
}

/* "Add to home screen" callout (mobile) — was hardcoded pink */
.page-help #addToHomeScreen {
    background: var(--bg-surface);
    border-left: 3px solid var(--warning);
}

@media (max-width: 640px) {
    .page-help {
        padding: 14px 12px;
    }

    .page-help .help-section {
        padding: 16px;
    }
}

/* ==========================================================================
   5. CATEGORIES  (.page-categories)
   ========================================================================== */

/* Desktop <main> is overflow:hidden — make the page the scroller */
.page-categories {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    padding: 24px 18px;
    box-sizing: border-box;
}

.page-categories .categories-header,
.page-categories .categories-grid {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

.page-categories .categories-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-categories .categories-header h1 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0;
}

.page-categories .categories-header .btn-primary {
    padding: 8px 16px;
    font-size: 13px;
    border: none;
}

.page-categories .categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 16px;
    align-items: start;
}

.page-categories .categories-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
}

.page-categories .categories-section h2 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    margin: 0 0 8px;
}

.page-categories .category-list {
    display: flex;
    flex-direction: column;
}

.page-categories .category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    margin: 0 -10px;
    border-bottom: 1px solid var(--border);
    border-radius: 8px;
    transition: background-color .12s ease;
}

.page-categories .category-item:last-child {
    border-bottom: none;
}

.page-categories .category-item:hover {
    background: var(--bg-hover);
}

.page-categories .category-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    margin: 0;
}

.page-categories .category-type {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    background: var(--bg-inset);
    border-radius: 999px;
    padding: 3px 9px;
}

.page-categories .category-actions {
    display: flex;
    gap: 6px;
    margin: 0;
}

.page-categories .btn-edit {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: background-color .12s ease;
}

.page-categories .btn-edit:hover {
    background: var(--bg-hover);
}

.page-categories .category-list .empty-state {
    padding: 26px 12px;
}

/* Add/Edit modal sizing (modal markup lives inside the page wrapper) */
.page-categories .modal-content {
    max-width: 420px;
    width: calc(100% - 32px);
    padding: 20px 22px;
}

.page-categories .modal-header {
    margin-bottom: 12px;
}

.page-categories .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.page-categories .form-actions button {
    padding: 8px 16px;
    font-size: 13px;
}

@media (max-width: 640px) {
    .page-categories {
        padding: 14px 12px;
    }
}

/* ==========================================================================
   4b. HELP — in-depth documentation additions  (.page-help)
   All colors via tokens.css custom properties.
   ========================================================================== */

.page-help {
    scroll-behavior: smooth;
}

/* Anchor targets clear the sticky-ish top edge of the scroll container */
.page-help .help-section[id] {
    scroll-margin-top: 16px;
}

/* --- Table of contents card (desktop) --- */
.page-help .help-toc {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 16px 22px 18px;
    margin-bottom: 14px;
}

.page-help .help-toc h2 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    margin: 0 0 10px;
}

.page-help .help-toc ol {
    columns: 2;
    column-gap: 28px;
    margin: 0;
    padding: 0 0 0 20px;
    counter-reset: none;
}

.page-help .help-toc li {
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 5px;
    break-inside: avoid;
    color: var(--ink-tertiary);
}

.page-help .help-toc a {
    color: var(--accent-text);
    font-weight: 500;
    text-decoration: none;
}

.page-help .help-toc a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .page-help .help-toc ol {
        columns: 1;
    }
}

/* --- Sub-headings inside a section --- */
.page-help .help-section h3 {
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--ink);
    margin: 14px 0 6px;
}

.page-help .help-section h3:first-of-type {
    margin-top: 12px;
}

/* --- Keyboard shortcut chips --- */
.page-help kbd {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1;
    color: var(--ink);
    background: var(--bg-inset);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 4px 7px;
    vertical-align: baseline;
    white-space: nowrap;
}

/* --- Monetary / mono examples --- */
.page-help .help-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    background: var(--bg-inset);
    border-radius: 6px;
    padding: 1px 6px;
    white-space: nowrap;
}

.page-help .help-amount.is-negative {
    color: var(--negative);
}

.page-help .help-amount.is-warning {
    color: var(--warning);
}

.page-help .help-amount.is-positive {
    color: var(--positive);
}

/* --- Small clarifying tables --- */
.page-help .help-table-wrap {
    overflow-x: auto;
    margin: 10px 0 4px;
}

.page-help .help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.45;
}

.page-help .help-table th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    text-align: left;
    padding: 6px 12px 6px 0;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

.page-help .help-table td {
    padding: 8px 12px 8px 0;
    border-bottom: 1px solid var(--border);
    color: var(--ink);
    vertical-align: top;
}

.page-help .help-table tr:last-child td {
    border-bottom: none;
}

.page-help .help-table td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

/* --- Tip / note callout --- */
.page-help .help-callout {
    display: block;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0 4px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink);
}

.page-help .help-callout .help-callout-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-text);
    margin-right: 6px;
}

/* --- Inline category-dot swatch --- */
.page-help .help-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    vertical-align: baseline;
    margin: 0 1px;
}

/* --- UI-label styling ("what it's called on screen") --- */
.page-help .help-ui {
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}

/* --- Collapsible sections (mobile help) --- */
.page-help details.help-section {
    padding: 0;
    overflow: hidden;
}

.page-help details.help-section > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    padding: 14px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
    -webkit-tap-highlight-color: transparent;
}

.page-help details.help-section > summary::-webkit-details-marker {
    display: none;
}

.page-help details.help-section > summary::after {
    content: "";
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--ink-tertiary);
    border-bottom: 1.5px solid var(--ink-tertiary);
    transform: rotate(45deg);
    transition: transform var(--dur-pop) var(--ease-pop);
    margin-right: 2px;
}

.page-help details.help-section[open] > summary::after {
    transform: rotate(225deg);
    margin-top: 4px;
}

.page-help details.help-section > .help-details-body {
    padding: 0 16px 16px;
}

.page-help details.help-section > .help-details-body > :first-child {
    margin-top: 0;
}

/* ==========================================================================
   LEGAL  (.page-legal): /terms and /privacy, rendered from app/legal/*.md
   ========================================================================== */

.page-legal {
    /* main is a fixed-height flex column with overflow hidden (styles.css): the page scrolls itself */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    width: 100%;
    padding: 26px 18px 48px;
}

.page-legal > * {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

.page-legal .legal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.page-legal .legal-tabs a {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--ink-secondary);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
}

.page-legal .legal-tabs a.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink-on-accent);
}

.page-legal .legal-doc {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 28px 32px;
    color: var(--ink);
    line-height: 1.6;
}

.page-legal .legal-doc h1 {
    font-size: 26px;
    margin: 0 0 12px;
}

.page-legal .legal-doc h2 {
    font-size: 18px;
    margin: 28px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    scroll-margin-top: 80px;
}

.page-legal .legal-doc p,
.page-legal .legal-doc ul {
    margin: 0 0 12px;
}

.page-legal .legal-doc li {
    margin-bottom: 6px;
}

.page-legal .legal-doc a {
    color: var(--accent);
}

@media (max-width: 640px) {
    .page-legal {
        padding: 14px 12px 32px;
    }

    .page-legal .legal-doc {
        padding: 18px 16px;
    }
}
