/* ═══════════════════════════════════════════════════════
   Finance Explorer — "Ledger Noir" Design System
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --bg-base: #0c0c10;
    --bg-surface: #131318;
    --bg-elevated: #1b1b22;
    --bg-hover: #22222c;
    --bg-active: #2a2a36;
    --bg-input: #0e0e14;
    --bg-row-alt: #10101a;

    --border: #232336;
    --border-subtle: #1a1a2a;
    --border-strong: #34344a;

    --text: #e4e2dc;
    --text-secondary: #908e88;
    --text-muted: #585654;

    --accent: #c8a868;
    --accent-dim: #957d4c;
    --accent-bright: #dcc088;
    --accent-glow: rgba(200, 168, 104, 0.12);

    --positive: #6ab878;
    --positive-bg: rgba(106, 184, 120, 0.06);
    --negative: #c86a6a;
    --negative-bg: rgba(200, 106, 106, 0.06);

    --match-high: #6ab878;
    --match-med: #c8a868;
    --match-low: #c86a6a;

    --radius-sm: 3px;
    --radius: 6px;
    --radius-lg: 8px;

    --shadow-sm: 0 2px 6px rgba(0,0,0,0.4);
    --shadow: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 24px 80px rgba(0,0,0,0.5);

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 180ms;
    --duration-slow: 350ms;

    --font-display: 'DM Serif Text', Georgia, 'Times New Roman', serif;
    --font-body: 'Karla', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ── Selection ── */
::selection { background: rgba(200, 168, 104, 0.3); color: var(--text); }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
html { font-size: 22px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text);
    line-height: 1.45;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Noise Texture Overlay ── */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
    opacity: 0.018;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 40px;
    background: var(--bg-surface);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid transparent;
    transition: box-shadow var(--duration-slow) var(--ease), border-color var(--duration-slow) var(--ease);
}

.header.scrolled {
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.4);
    border-bottom-color: var(--border);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 20px;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text);
    letter-spacing: -0.01em;
}

.logo span {
    color: var(--accent);
}

.tagline {
    font-size: 0.55rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 500;
}

.header-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
}

.kpi {
    padding: 0 24px;
    border-right: 1px solid var(--border);
    text-align: right;
}

.kpi:last-child { border-right: none; }

.kpi-label {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* ── Gold Rule ── */
.gold-rule {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--accent-dim) 15%, var(--accent) 50%, var(--accent-dim) 85%, transparent 100%);
    opacity: 0.35;
    transition: opacity 0.5s var(--ease);
}


/* ── Filter Toggle ── */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 40px;
    background: var(--bg-surface);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.filter-toggle:hover {
    color: var(--accent);
    background: var(--bg-elevated);
}

.filter-toggle-icon {
    font-size: 0.55rem;
    transition: transform var(--duration-slow) var(--ease);
}

.filter-toggle-count {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 2px 12px;
    border-radius: 200px;
    border: 1px solid rgba(200, 168, 104, 0.2);
}

/* ── Filter Bar ── */
.filters {
    padding: 12px clamp(20px, 2vw, 40px);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    max-height: none;
    overflow: visible;
    transition: max-height var(--duration-slow) var(--ease), padding var(--duration-slow) var(--ease), opacity var(--duration-slow) var(--ease);
}

.filters-collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
    opacity: 0;
    overflow: hidden;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filters-row + .filters-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

/* Row 1: Search stretches, dates and amounts stay compact */
.filters-row-scope .search-field { flex: 1; min-width: 200px; }
.filters-row-scope .search-field input[type="text"] { width: 100%; }

.filter-actions-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-left: auto;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.filter-field label {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}

.filter-field input[type="date"],
.filter-field input[type="text"],
.filter-field input[type="number"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    outline: none;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
    min-width: 0;
}

.filter-field input:focus {
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.filter-field input[type="date"] { width: 270px; max-width: 100%; font-family: var(--font-mono); font-size: 0.8rem; }
.filter-field input[type="number"] { width: 180px; max-width: 100%; font-family: var(--font-mono); font-size: 0.8rem; -moz-appearance: textfield; padding-right: 44px; }
.filter-field input[type="number"]::-webkit-outer-spin-button,
.filter-field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Custom spinner wrapper */
.spin-wrap { position: relative; display: inline-block; }
.spin-wrap input { width: 180px; }
.spin-wrap-date input { width: 270px; padding-right: 44px; }

.spin-buttons {
    position: absolute;
    right: 2px;
    top: 2px;
    bottom: 2px;
    width: 36px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
}

.spin-btn {
    flex: 1;
    background: var(--bg-elevated);
    border: none;
    cursor: pointer;
    position: relative;
    transition: background var(--duration) var(--ease);
    border-radius: 0;
}

.spin-btn:first-child { border-radius: 0 var(--radius) 0 0; }
.spin-btn:last-child { border-radius: 0 0 var(--radius) 0; border-top: 1px solid var(--border); }
.spin-btn:hover { background: var(--bg-hover); }
.spin-btn:active { background: var(--bg-active); }

/* CSS triangles for up/down */
.spin-btn::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.spin-up::after {
    border-bottom: 8px solid var(--text-muted);
    transform: translate(-50%, -50%);
}

.spin-down::after {
    border-top: 8px solid var(--text-muted);
    transform: translate(-50%, -50%);
}

.spin-btn:hover::after { border-bottom-color: var(--accent); border-top-color: var(--accent); }
.filter-field input[type="text"] { width: 400px; max-width: 100%; }

/* Multi-select */
.multi-select { position: relative; min-width: 120px; }

.multi-select-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 44px 10px 14px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.multi-select-btn::after {
    content: '';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid var(--text-muted);
}

.multi-select-btn:hover,
.multi-select-btn:focus {
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 4px var(--accent-glow);
    outline: none;
}

.multi-select-dropdown {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 100%;
    max-width: 220px;
    max-height: 560px;
    overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
}

.multi-select-dropdown.open { display: flex; }

.multi-select-dropdown label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text);
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    transition: background var(--duration) var(--ease);
}

.multi-select-dropdown label:hover { background: var(--bg-hover); }
.multi-select-dropdown input[type="checkbox"] { accent-color: var(--accent); }

/* Multi-select toolbar buttons — hover colors handled inline per button */

/* Row hide button hover */
.row-hide-btn:hover { opacity: 1 !important; color: var(--negative) !important; }

/* Active filter chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.filter-chips:not(:has(.chip)) .btn-reset-chip { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--accent-glow);
    border: 1px solid rgba(200, 168, 104, 0.18);
    border-radius: 200px;
    font-size: 0.68rem;
    color: var(--accent-bright);
    font-weight: 500;
    cursor: default;
    animation: chipIn 0.2s var(--ease) both;
}

/* CSS-drawn X icon — replaces Unicode × everywhere */
.icon-x {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
    vertical-align: middle;
}
.icon-x::before, .icon-x::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 3px;
    background: currentColor;
    border-radius: 2px;
}
.icon-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.icon-x::after { transform: translate(-50%, -50%) rotate(-45deg); }

.chip-remove {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.6;
    transition: opacity var(--duration) var(--ease);
}

.chip-remove:hover { opacity: 1; }

.btn-reset-filters {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    padding: 10px 18px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    align-self: flex-end;
    white-space: nowrap;
}

.btn-reset-filters:hover {
    border-color: var(--negative);
    color: var(--negative);
    background: var(--negative-bg);
}

.btn-reset-chip {
    padding: 3px 12px;
    border-radius: 200px;
    font-size: 0.68rem;
    font-weight: 500;
    order: -1;
}

.btn-export-chip {
    padding: 3px 12px;
    border-radius: 200px;
    font-size: 0.68rem;
    font-weight: 500;
    margin-left: auto;
    order: 999;
}

/* ── Tab Navigation ── */
.tabs {
    position: relative;
    display: flex;
    padding: 0 40px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    padding: 10px 24px;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--duration) var(--ease);
    white-space: nowrap;
    position: relative;
}

.tab:hover { color: var(--text-secondary); }
.tab:active { transform: translateY(2px); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-count {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 12px;
    opacity: 0.7;
}

.tab-count-alert {
    color: var(--negative);
    opacity: 1;
    font-weight: 700;
}

/* ── Main Content ── */
.main { padding: 20px clamp(20px, 2vw, 40px) 120px; }

.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.25s var(--ease) both; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.panel-info strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ── Transaction Table ── */
.table-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 340px);
}

table {
    width: 100%;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
}

thead th {
    background: var(--bg-elevated);
    padding: 8px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
    transition: color var(--duration) var(--ease);
}

thead th:hover { color: var(--accent); }

thead th .sort-icon {
    display: inline-block;
    margin-left: 1px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 7px solid currentColor;
    opacity: 0.7;
    vertical-align: middle;
    transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
    font-size: 0;
}

thead th .sort-icon.sort-asc {
    transform: rotate(180deg);
}

thead th.sorted {
    color: var(--accent);
}

thead th.sorted .sort-icon {
    opacity: 1;
    color: var(--accent);
}

thead th.col-right { text-align: right; }

tbody tr {
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

tbody tr:nth-child(even) { background: var(--bg-row-alt); }
tbody tr:hover { background: var(--bg-hover); }

.row-focused {
    outline: 1px solid var(--accent-dim);
    outline-offset: -2px;
    background: var(--bg-hover) !important;
}

/* Staggered row entrance */
tbody tr.row-enter {
    animation: rowFadeIn 0.25s var(--ease) both;
}

tbody td {
    padding: 6px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border-subtle);
}

/* Amount ledger indicator — left border on checkbox cell */
tbody tr.row-negative td:first-child {
    box-shadow: inset 4px 0 0 var(--negative);
}

tbody tr.row-positive td:first-child {
    box-shadow: inset 4px 0 0 var(--positive);
}

th[data-sort="amount"] {
    width: 1%;
    text-align: right;
    padding-right: 12px;
    white-space: nowrap;
}
td.col-amount {
    width: 1%;
    font-family: var(--font-mono);
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
    padding-right: 12px;
    white-space: nowrap;
}

td.col-amount.positive { color: var(--positive); }
td.col-amount.negative { color: var(--negative); }

th[data-sort="description"] {
    width: 100%;
}
td.col-desc {
    width: 100%;
    max-width: 0;
    font-size: 0.75rem;
}
.desc-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* desc-tags removed — tags shown in detail panel only */

th.col-action, td.col-action {
    width: 1%;
    padding: 0 4px !important;
    text-align: center;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}
th.col-action { cursor: default; }
td.col-action .row-hide-btn {
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
    color: var(--text-muted);
    font-size: 0.7rem;
}
td.col-action .row-unhide-btn {
    opacity: 0.6;
    color: var(--positive);
}
tbody tr:hover .row-hide-btn { opacity: 0.6; }
td.col-action .row-hide-btn:hover { opacity: 1; color: var(--negative); }
td.col-action .row-unhide-btn:hover { color: var(--positive); }

th[data-sort="date"],
th[data-sort="category"],
th[data-sort="account"],
th[data-sort="institution"] {
    width: 1%;
    white-space: nowrap;
}
td.col-date {
    width: 1%;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

td.col-category {
    width: 1%;
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

td.col-account {
    width: 1%;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding-left: 8px;
    padding-right: 8px;
    white-space: nowrap;
}

td.col-institution {
    width: 1%;
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Flow type badge */
.flow-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 10px;
    border: 1px solid currentColor;
    border-radius: var(--radius-sm);
    margin-left: 16px;
    vertical-align: middle;
    letter-spacing: 0.03em;
    opacity: 0.7;
    text-transform: uppercase;
}


/* ── Row Detail ── */
.row-detail { background: transparent !important; }
.row-detail:hover { background: transparent !important; }
.row-detail td { padding: 0 !important; }

.detail-card {
    margin: 2px 12px 10px;
    padding: 14px 24px;
    background: var(--bg-elevated);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    animation: slideDown 0.15s var(--ease) both;
}

.detail-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-desc {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.4;
    word-break: break-word;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    max-width: 50%;
}

.detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--bg-active);
    padding: 3px 10px;
    border-radius: 999px;
}

.detail-chip-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-muted);
}

.detail-flow-chip {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg-active);
}

/* ── Edit form layout ── */
.detail-grid-edit {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-top: 10px;
}
.edit-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.edit-row label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}
.edit-row input,
.edit-row select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 7px 12px;
    font-size: 0.8rem;
    font-family: var(--font-body);
    width: 100%;
    outline: none;
}
.edit-row input:focus,
.edit-row select:focus {
    border-color: var(--accent-dim);
}
.edit-row select { cursor: pointer; }

@media (max-width: 600px) {
    .detail-grid-edit { grid-template-columns: 1fr; }
}

.detail-grid:empty { display: none; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 6px 24px;
    font-size: 0.8rem;
    margin-top: 10px;
}

.detail-grid dt {
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.detail-grid dd {
    color: var(--text);
    margin-bottom: 2px;
    word-break: break-word;
}

.detail-links { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-links-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}

.detail-link-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
    font-size: 0.78rem;
}

.detail-link-row .link-date {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.73rem;
}

.detail-link-row .link-amount {
    font-family: var(--font-mono);
    font-weight: 600;
}

.detail-link-row .link-desc {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-link-row .link-meta {
    color: var(--text-muted);
    font-size: 0.7rem;
    white-space: nowrap;
}

.detail-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.detail-actions .btn-primary {
    background: var(--accent);
    color: var(--bg-base);
}
.detail-actions .btn-primary:hover { background: var(--accent-bright); color: var(--bg-base); }

.detail-actions .btn-subtle {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.detail-actions .btn-subtle:hover { background: var(--bg-active); color: var(--text); }

.btn {
    background: var(--accent-dim);
    color: var(--text);
    border: none;
    border-radius: var(--radius);
    padding: 8px 20px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.btn:hover { background: var(--accent); color: var(--bg-base); }
.btn:active { transform: translateY(2px); }

.btn:disabled,
.btn:disabled:hover {
    cursor: not-allowed;
    opacity: 0.48;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-active);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ── Table Footer ── */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
}

.running-total {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.running-total strong {
    color: var(--text);
    font-weight: 600;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pagination button {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    padding: 6px 18px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.pagination button:hover:not(:disabled) {
    border-color: var(--accent-dim);
    color: var(--accent);
}

.pagination button:disabled { opacity: 0.25; cursor: default; }
.pagination button:active:not(:disabled) { transform: translateY(2px); }

.page-label {
    font-family: var(--font-mono);
    font-size: 0.77rem;
    color: var(--text-muted);
    min-width: 160px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.page-size-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 0.73rem;
    cursor: pointer;
    transition: border-color var(--duration) var(--ease);
}

.page-size-select:hover {
    border-color: var(--accent-dim);
    color: var(--text);
}

.page-size-select:focus {
    outline: none;
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ── Summary Tab ── */
.summary-overall {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 28px;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.kpi-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.kpi-card-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 8px;
}

.kpi-card-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.kpi-card-value.negative { color: var(--negative); }
.kpi-card-value.positive { color: var(--positive); }
.kpi-card-value.net { color: var(--accent); }

/* Utility color classes */
.positive { color: var(--positive); }
.negative { color: var(--negative); }

.kpi-card-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

.summary-section {
    margin-bottom: 40px;
}

.summary-section h3 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

/* Horizontal bar chart */
.hbar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hbar-row {
    display: grid;
    grid-template-columns: 260px 1fr auto;
    align-items: center;
    gap: 28px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--duration) var(--ease);
}

.hbar-row:hover {
    background: var(--bg-hover);
}

.hbar-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.hbar-count {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 8px;
    font-weight: 400;
}

.hbar-track {
    height: 32px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.hbar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.5s var(--ease);
    min-width: 4px;
}

.hbar-fill.out { background: var(--negative); opacity: 0.65; }
.hbar-fill.in { background: var(--positive); opacity: 0.65; }

.hbar-track-stacked {
    display: flex;
    height: 100%;
}

.hbar-value {
    font-family: var(--font-mono);
    font-size: 0.77rem;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hbar-value.negative { color: var(--negative); }
.hbar-value.positive { color: var(--positive); }

/* ── Reconciliation ── */
.recon-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.recon-col {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.recon-col h4 {
    background: var(--bg-elevated);
    padding: 12px 20px;
    font-size: 0.77rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

.recon-list {
    max-height: 1080px;
    overflow-y: auto;
    flex: 1;
}

.recon-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
    font-size: 0.85rem;
}

.recon-item:hover {
    background: var(--bg-hover);
    border-left: 6px solid var(--border-strong);
    padding-left: 14px;
}

.recon-item.selected {
    background: var(--bg-active);
    border-left: 6px solid var(--accent);
    padding-left: 14px;
}

.recon-item .ri-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.recon-item .ri-date {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.recon-item .ri-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.recon-item .ri-desc {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.recon-item .ri-meta {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.match-score {
    display: inline-block;
    padding: 4px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 16px;
    letter-spacing: 0.03em;
}

.match-score.high { background: rgba(106,184,120,0.12); color: var(--match-high); }
.match-score.medium { background: rgba(200,168,104,0.12); color: var(--match-med); }
.match-score.low { background: rgba(200,106,106,0.12); color: var(--match-low); }

.match-days {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 12px;
}


/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s var(--ease) both;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 1400px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.2s var(--ease) both;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text);
    font-weight: 400;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 8px 16px;
    transition: color var(--duration) var(--ease);
}

.modal-close:hover { color: var(--negative); }

.modal-body { padding: 24px 32px; }



/* ── Loading & Skeleton ── */
.loading-text {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.loading-text::before {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 16px;
    vertical-align: middle;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
    height: 28px;
}

.skeleton-row td { padding: 6px 12px !important; }

/* ── Empty State ── */
.empty-state {
    padding: 60px 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.empty-state-icon {
    font-size: 2.4rem;
    margin-bottom: 24px;
    opacity: 0.2;
    filter: grayscale(1);
}

.dataset-empty {
    max-width: 760px;
    margin: 22px auto 42px;
    padding: 34px 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.dataset-empty-kicker {
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.dataset-empty h2 {
    margin: 0 0 14px;
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
}

.dataset-empty p {
    max-width: 560px;
    margin: 0 auto;
    color: var(--text-muted);
    line-height: 1.65;
    font-size: 0.92rem;
}

.dataset-empty-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.dataset-empty-actions .btn {
    min-width: 132px;
}

/* ── Toast Notifications ── */
.toasts {
    position: fixed;
    bottom: 40px;
    right: 40px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.toast {
    padding: 14px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.78rem;
    box-shadow: var(--shadow);
    transform: translateX(120%);
    opacity: 0;
    transition: all var(--duration-slow) var(--ease);
    display: flex;
    align-items: center;
    gap: 16px;
}

.toast-action {
    background: none;
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.73rem;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 16px;
    white-space: nowrap;
    transition: all var(--duration) var(--ease);
}

.toast-action:hover {
    background: var(--accent-glow);
    color: var(--accent-bright);
}

.toast-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    margin-left: auto;
    opacity: 0.5;
    transition: opacity var(--duration) var(--ease);
    flex-shrink: 0;
}

.toast-dismiss:hover { opacity: 1; }

.toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.toast-success { border-left: 6px solid var(--positive); }
.toast-error { border-left: 6px solid var(--negative); }
.toast-info { border-left: 6px solid var(--accent); }

/* ── Back to Top ── */
.btn-back-to-top {
    position: fixed;
    bottom: 32px;
    left: 32px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 200;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: all var(--duration-slow) var(--ease);
    box-shadow: var(--shadow-sm);
}

.btn-back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.btn-back-to-top:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
    box-shadow: var(--shadow);
}

/* ── Keyboard Shortcut Hints ── */
.shortcuts-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.73rem;
    color: var(--text-muted);
    opacity: 0.4;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity var(--duration) var(--ease);
}

.shortcuts-hint kbd {
    display: inline-block;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 10px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    margin: 0 2px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Keyframes ── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes rowFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes chipIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.94) translateY(24px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Segments Row ── */
.segments-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    padding: 6px 0 0;
    border-top: 1px solid var(--border);
}

.segments-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    flex-shrink: 0;
    user-select: none;
}

.segments-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.segment-pill {
    --seg-hue: 38;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid hsl(var(--seg-hue) 30% 40% / 0.35);
    border-radius: 200px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-family: var(--font-body);
    color: hsl(var(--seg-hue) 40% 72%);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
    white-space: nowrap;
}

.segment-pill:nth-child(8n+1) { --seg-hue: 38; }   /* gold */
.segment-pill:nth-child(8n+2) { --seg-hue: 200; }  /* blue */
.segment-pill:nth-child(8n+3) { --seg-hue: 150; }  /* teal */
.segment-pill:nth-child(8n+4) { --seg-hue: 280; }  /* purple */
.segment-pill:nth-child(8n+5) { --seg-hue: 350; }  /* rose */
.segment-pill:nth-child(8n+6) { --seg-hue: 90; }   /* lime */
.segment-pill:nth-child(8n+7) { --seg-hue: 25; }   /* orange */
.segment-pill:nth-child(8n+8) { --seg-hue: 170; }  /* cyan */

.segment-pill:hover {
    border-color: hsl(var(--seg-hue) 50% 55%);
    background: hsl(var(--seg-hue) 30% 20% / 0.2);
}

.segment-active {
    border-color: hsl(var(--seg-hue) 55% 60%);
    background: hsl(var(--seg-hue) 40% 25% / 0.2);
    color: hsl(var(--seg-hue) 55% 78%);
    font-weight: 600;
}

.segment-delete {
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--duration) var(--ease), color var(--duration) var(--ease);
    cursor: pointer;
    padding: 0 2px;
}

.segment-pill:hover .segment-delete { opacity: 1; }
.segment-delete:hover { color: var(--negative); }

.segment-save-btn {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 200px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-family: var(--font-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
    white-space: nowrap;
}

.segment-save-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}

/* Date inputs showing data range as context (not active filters) */
input.date-default { color: var(--text-muted); opacity: 0.55; }
input.date-default:focus { color: var(--text); opacity: 1; }

/* ── Date Navigator ── */
.date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.date-nav-arrow {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration) var(--ease);
    flex-shrink: 0;
}

.date-nav-arrow:hover:not(:disabled) {
    border-color: var(--accent-dim);
    color: var(--accent);
    background: var(--bg-hover);
}

.date-nav-arrow:disabled {
    opacity: 0.2;
    pointer-events: none;
}

.date-nav-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.date-nav-years {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ynav {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    padding: 3px 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.ynav:hover { border-color: var(--accent-dim); color: var(--accent); }
.ynav.active {
    background: var(--accent-glow);
    border-color: var(--accent-dim);
    color: var(--accent-bright);
}

.date-nav-months {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    align-items: center;
}

.date-nav-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 6px;
    flex-shrink: 0;
}

.mnav, .qnav, .preset-sm {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 200px;
    color: var(--text-muted);
    padding: 3px 8px;
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}

.mnav:hover, .qnav:hover, .preset-sm:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}

.mnav:active, .qnav:active, .preset-sm:active { transform: scale(0.95); }

.mnav.active {
    background: var(--accent-glow);
    border-color: var(--accent-dim);
    color: var(--accent-bright);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.mnav.in-range {
    background: rgba(200, 168, 104, 0.06);
    border-color: rgba(200, 168, 104, 0.2);
    color: var(--accent-dim);
}

.qnav.active, .preset-sm.active {
    background: var(--accent-glow);
    border-color: var(--accent-dim);
    color: var(--accent-bright);
}

.mnav.nav-disabled, .qnav.nav-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ── Export Button ── */
.btn-export {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    padding: 8px 18px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}

.btn-export:hover {
    border-color: var(--positive);
    color: var(--positive);
}

/* ── Insights Tab ── */
.insights-loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.insights-loading::before {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 16px;
    vertical-align: middle;
}

.insights-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 32px;
}


.insights-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.insight-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow: hidden;
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.insight-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.insight-card h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.insight-card-wide {
    grid-column: 1 / -1;
}

.insight-card-empty {
    opacity: 0.4;
    transform: none !important;
    box-shadow: none !important;
}

.insight-card-empty:hover {
    transform: none !important;
    border-color: var(--border) !important;
}

.insight-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.insight-sub {
    font-family: var(--font-body);
    font-size: 0.73rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 16px;
}

.chart-container {
    position: relative;
    height: 440px;
}

.chart-container-square {
    height: 540px;
}

.chart-container-tall {
    height: 640px;
}

/* ── Insight Lists ── */
.ins-list {
    max-height: 720px;
    overflow-y: auto;
}

.ins-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.82rem;
    gap: 24px;
}

.ins-row:last-child { border-bottom: none; }

.ins-row-clickable {
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.ins-row-clickable:hover {
    background: var(--bg-hover);
}

.ins-row-clickable:active {
    background: var(--bg-active);
}

.ins-row-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.ins-row-meta {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.ins-row-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ins-badge {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 200px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ins-badge-freq {
    background: var(--accent-glow);
    color: var(--accent-bright);
    border: 1px solid rgba(200, 168, 104, 0.18);
}

.ins-badge-anomaly {
    background: rgba(200, 106, 106, 0.12);
    color: var(--negative);
}

.ins-badge-anomaly-high {
    background: rgba(200, 106, 106, 0.2);
    color: #e87070;
}

.ins-transfer-arrow {
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0 16px;
}

/* ── Filter Notice ── */
.filter-notice {
    padding: 12px 24px;
    background: var(--accent-glow);
    border: 1px solid rgba(200, 168, 104, 0.15);
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 0.77rem;
    color: var(--accent-bright);
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-notice::before {
    content: '\26A0';
    font-size: 1rem;
    opacity: 0.6;
}

/* ── Insight Tables ── */
.ins-table {
    border-collapse: collapse;
    font-size: 0.82rem;
}

.ins-table thead th {
    background: var(--bg-elevated);
    padding: 12px 20px;
    text-align: left;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    position: static;
    cursor: default;
    white-space: nowrap;
}

.ins-table thead th:hover { color: var(--text-muted); }

.ins-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    cursor: default;
}

.ins-table tbody tr:hover {
    background: var(--bg-hover);
}

.ins-table tbody td {
    padding: 12px 20px;
    font-size: 0.82rem;
    white-space: nowrap;
}

.ins-table tbody td:first-child {
    white-space: normal;
    max-width: 480px;
}

/* ── Responsive ── */
@media (max-width: 2000px) {
    .hbar-row { grid-template-columns: 200px 1fr 160px; gap: 20px; }
    .hbar-label { font-size: 0.77rem; }
}

@media (max-width: 1800px) {
    .header { padding: 10px 28px; }
    .header-left { gap: 16px; }
    .tagline { display: none; }
    .header-stats { gap: 0; }
    .kpi { padding: 0 18px; }
    .filter-toggle { padding: 8px 28px; }
    .filters { padding: 12px 28px; }
    .tabs { padding: 0 28px; }
    .recon-panel { grid-template-columns: 1fr; }
    .summary-overall { grid-template-columns: 1fr; }
    .hbar-row { grid-template-columns: 180px 1fr 160px; }
    .filter-field input[type="text"] { width: 260px; }
    .insights-kpis { grid-template-columns: repeat(3, 1fr); }
    .insights-grid { grid-template-columns: 1fr; }
    .insight-card-wide { grid-column: 1; }
}

@media (max-width: 1280px) {
    .tab { padding: 16px 28px; font-size: 0.8rem; }
    .shortcuts-hint { display: none; }
    .hbar-row { grid-template-columns: 160px 1fr; }
    .hbar-value { display: none; }
    .insights-kpis { grid-template-columns: repeat(2, 1fr); }
    .filter-field input[type="date"] { width: 200px; }
    .spin-wrap-date input { width: 200px; }
    .filter-field input[type="number"] { width: 140px; }
    .spin-wrap input { width: 140px; }
    .multi-select { min-width: 180px; }

}

@media (max-width: 960px) {
    html { font-size: 17px; }
    .header { padding: 16px 20px; }
    .filter-toggle { padding: 10px 20px; }
    .filters { padding: 16px 20px; }
    .tabs {
        padding: 0 20px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab { padding: 14px 20px; font-size: 0.77rem; flex-shrink: 0; }
    .filters-row { gap: 12px; }
    .filter-field input[type="date"] { width: 170px; font-size: 0.73rem; }
    .spin-wrap-date input { width: 170px; }
    .filter-field input[type="text"] { width: 200px; }
    .filter-field input[type="number"] { width: 120px; }
    .spin-wrap input { width: 120px; }
    .multi-select { min-width: 160px; }
    .summary-overall { gap: 16px; }
    .kpi-card { padding: 24px 28px; }
    .detail-grid { grid-template-columns: 1fr; }
    .chart-container { height: 400px; }
    .chart-container-square { height: 480px; }
    .chart-container-tall { height: 560px; }
    .modal { width: 96%; max-width: none; }
    .modal-body { padding: 24px; }
    .modal-header { padding: 20px 24px; }
    .toasts { bottom: 20px; right: 20px; left: 20px; }
    .toast { font-size: 0.77rem; }
    .btn-back-to-top { bottom: 20px; left: 20px; width: 44px; height: 44px; font-size: 1rem; }
    .recon-panel { gap: 20px; }
    .ins-table tbody td { padding: 10px 14px; font-size: 0.77rem; }
    .ins-table thead th { padding: 10px 14px; font-size: 0.6rem; }
}

/* ── Phone ── */
@media (max-width: 600px) {
    html { font-size: 15px; overflow-x: clip; }

    /* Header: stack logo above KPIs */
    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 14px;
        gap: 6px;
    }
    .header-stats {
        width: 100%;
        justify-content: space-between;
    }
    .kpi { padding: 0 10px; }
    .kpi-value { font-size: 0.85rem; }
    .kpi-label { font-size: 0.5rem; }

    /* Filters: full-width inputs */
    .filter-toggle { padding: 8px 14px; }
    .filters { padding: 10px 14px; }
    .filters-row { gap: 8px; }
    .filters-row + .filters-row { margin-top: 8px; padding-top: 8px; }
    .filters-row-scope .search-field { min-width: 0; }
    .filters-row-actions { flex-wrap: wrap; }
    .filter-field input[type="text"],
    .filter-field input[type="date"],
    .filter-field input[type="number"] { width: 100%; }
    .spin-wrap input,
    .spin-wrap-date input { width: 100%; }
    .filter-field { flex: 1 1 100%; min-width: 0; }
    .multi-select { min-width: 0; width: 100%; }

    /* Tabs: tighter for phones */
    .tabs { padding: 0 14px; }
    .tab { padding: 12px 14px; font-size: 0.75rem; }

    /* Main content */
    .main { padding: 14px 14px 50px; }

    /* Table: allow horizontal scroll */
    .table-container {
        overflow-x: auto;
        max-height: calc(100vh - 260px);
    }

    /* Hbar charts: stack label above bar */
    .hbar-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 8px 4px;
    }
    .hbar-label {
        text-align: left;
        font-size: 0.73rem;
    }
    .hbar-value { display: block; font-size: 0.7rem; }

    /* Charts: shorter on phones */
    .chart-container { height: 280px; }
    .chart-container-square { height: 320px; }
    .chart-container-tall { height: 380px; }

    /* Summary KPIs: single column */
    .summary-overall { grid-template-columns: 1fr; gap: 10px; }
    .kpi-card { padding: 16px; }
    .insights-kpis { grid-template-columns: 1fr; }

    /* Modal */
    .modal { width: 100%; border-radius: 0; }
    .modal-body { padding: 16px; }
    .modal-header { padding: 14px 16px; }

    /* Toasts & back-to-top */
    .btn-back-to-top { bottom: 14px; left: 14px; width: 40px; height: 40px; font-size: 0.85rem; }
    .toasts { bottom: 14px; right: 14px; left: 14px; }

    /* Toolbar dropdowns: fixed bottom sheet on mobile */
    .sel-cat-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        border-radius: var(--radius) var(--radius) 0 0;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.6);
        z-index: 300;
    }
    .sel-cat-list { max-height: 40vh; }

    .recon-panel { gap: 14px; }

}

/* ═══════════════════════════════════════════════════════
   Enhanced Filter Controls
   ═══════════════════════════════════════════════════════ */

/* Dropdown toolbar (Select All / None / Invert + search) */
.ms-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    flex-wrap: wrap;
    align-items: center;
}

.ms-toolbar-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: var(--font-body);
    font-weight: 600;
    padding: 4px 14px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all var(--duration) var(--ease);
}

.ms-toolbar-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}

.ms-search {
    flex: 1;
    min-width: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.75rem;
    font-family: var(--font-body);
    padding: 4px 14px;
    outline: none;
}

.ms-search:focus {
    border-color: var(--accent-dim);
}

.ms-search::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Include/Exclude mode toggle */
.ms-mode-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 4px 12px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all var(--duration) var(--ease);
    margin-left: auto;
}

.ms-mode-toggle:hover {
    border-color: var(--accent-dim);
}

.ms-mode-toggle.exclude {
    background: var(--negative-bg);
    border-color: var(--negative);
    color: var(--negative);
}

/* Multi-select button text for exclude mode */
.multi-select-btn.exclude-mode {
    border-color: rgba(200, 106, 106, 0.3);
    color: var(--negative);
}

/* Hide button on transaction rows */
.row-hide-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--duration) var(--ease), color var(--duration) var(--ease);
    line-height: 1;
}

tbody tr:hover .row-hide-btn { opacity: 0.5; }
.row-hide-btn:hover { opacity: 1 !important; color: var(--negative); }

tbody tr { position: relative; }

/* Hidden row indicator */
tbody tr.row-hidden {
    opacity: 0.35;
}

tbody tr.row-hidden td:first-child {
    box-shadow: inset 6px 0 0 var(--text-muted) !important;
}

/* Show Hidden toggle */
.btn-show-hidden.active,
#btn-only-hidden.active {
    border-color: var(--accent-dim);
    color: var(--accent);
    background: var(--accent-glow);
}

/* Amount presets */
.amount-presets {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.amount-presets:empty { display: none; }


/* ═══════════════════════════════════════════════════════
   Print Stylesheet
   ═══════════════════════════════════════════════════════ */
@media print {
    * { color-adjust: exact; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    body {
        background: #fff;
        color: #1a1a1a;
        font-size: 10pt;
    }

    body::after { display: none; } /* Remove noise texture */

    .header {
        position: static;
        background: #fff;
        border-bottom: 2px solid #c8a868;
        padding: 12px 24px;
    }

    .gold-rule,
    .filter-toggle,
    .filters,
    .tabs,
    .shortcuts-hint,
    .btn-back-to-top,
    .toasts,
    .btn-export,
    .btn-reset-filters,
    .pagination button,
    .page-size-select,
    .detail-actions,
    .row-hide-btn,
    .modal-overlay { display: none !important; }

    .main { padding: 12px 0; }
    .panel { display: block !important; }
    .panel:not(.active) { display: none !important; }

    .table-container {
        max-height: none;
        overflow: visible;
        border: 1px solid #ccc;
    }

    table { font-size: 8pt; }

    thead th {
        background: #f5f5f0;
        color: #333;
        position: static;
        border-bottom: 2px solid #999;
    }

    tbody tr { border-bottom: 1px solid #ddd; }
    tbody tr:nth-child(even) { background: #fafaf8; }
    tbody tr:hover { background: none; }
    tbody tr.row-enter { animation: none; }

    td.col-amount.positive { color: #2a7a3a; }
    td.col-amount.negative { color: #a03030; }

    .kpi-card, .insight-card, .summary-section {
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .kpi-card { background: #fafaf8; }
    .kpi-card-value.negative { color: #a03030; }
    .kpi-card-value.positive { color: #2a7a3a; }

    .insight-card {
        background: #fff;
        box-shadow: none;
        transform: none;
        page-break-inside: avoid;
    }

    .insights-grid { gap: 16px; }
    .chart-container { height: 300px; }
    .chart-container-square { height: 300px; }
    .chart-container-tall { height: 400px; }

    .logo span { color: #8a7440; }
    .header-stats { display: flex; }
    .kpi-value { color: #333; }
    .kpi-label { color: #666; }

    a { color: #333; text-decoration: none; }
}

/* ── Admin Tab ── */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 20px 40px;
}

.admin-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.admin-card h3 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--accent);
    margin: 0 0 8px;
}

.admin-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

.admin-btn {
    width: 100%;
    padding: 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.admin-btn-danger {
    border-color: rgba(200, 106, 106, 0.3);
    color: var(--negative);
}
.admin-btn-danger:hover {
    background: rgba(200, 106, 106, 0.1);
    border-color: var(--negative);
}

.admin-result {
    margin-top: 12px;
    font-size: 0.78rem;
    font-family: var(--font-mono);
    min-height: 1.2em;
}

.admin-result-ok { color: var(--positive); }
.admin-result-err { color: var(--negative); }

/* ── Category Manager ── */
.admin-card-wide {
    grid-column: 1 / -1;
}

.import-card {
    display: grid;
    gap: 12px;
}

.import-status {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid rgba(200, 168, 104, 0.28);
    border-radius: var(--radius-sm);
    color: var(--accent);
    background: rgba(200, 168, 104, 0.06);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.import-dropzone {
    position: relative;
    display: grid;
    grid-template-columns: 1fr minmax(180px, 240px);
    gap: 14px;
    align-items: stretch;
}

.import-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.import-dropzone-body {
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 22px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.015);
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.import-dropzone.is-dragging .import-dropzone-body,
.import-dropzone:hover .import-dropzone-body {
    border-color: var(--accent);
    background: rgba(200, 168, 104, 0.05);
}

.import-dropzone-title {
    color: var(--text);
    font-size: 1rem;
    font-weight: 700;
}

.import-dropzone-meta {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.import-dropzone .admin-btn {
    align-self: stretch;
    position: relative;
    z-index: 1;
}

.import-file-list {
    display: grid;
    gap: 8px;
}

.import-file-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    font-size: 0.78rem;
}

.import-file-name {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-file-meta,
.import-file-kind {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.import-history {
    display: grid;
    gap: 8px;
    margin-top: 4px;
}

.import-history-title {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.import-history-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.74rem;
}

.import-history-row strong {
    color: var(--text);
    font-weight: 600;
}

@media (max-width: 760px) {
    .import-dropzone {
        grid-template-columns: 1fr;
    }

    .import-file-row,
    .import-history-row {
        grid-template-columns: 1fr;
    }
}
.cat-mgr-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.cat-mgr-search {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 6px 12px;
    font-size: 0.75rem;
    font-family: var(--font-body);
    outline: none;
}
.cat-mgr-search:focus {
    border-color: var(--accent-dim);
}
.cat-mgr-search::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}
.cat-mgr-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.cat-mgr-merge-btn {
    font-size: 0.7rem;
    padding: 4px 12px;
    white-space: nowrap;
}
.cat-mgr-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.cat-mgr-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--duration) var(--ease);
}
.cat-mgr-row:last-child { border-bottom: none; }
.cat-mgr-row:hover { background: var(--bg-hover); }
.cat-mgr-row.cat-mgr-selected {
    background: var(--accent-glow);
    border-left: 2px solid var(--accent);
}
.cat-mgr-name {
    flex: 1;
    font-size: 0.78rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cat-mgr-count-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    min-width: 36px;
    text-align: right;
}
.cat-mgr-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}
.cat-mgr-row:hover .cat-mgr-actions,
.cat-mgr-row.cat-mgr-selected .cat-mgr-actions {
    opacity: 1;
}
.cat-mgr-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.62rem;
    font-family: var(--font-body);
    padding: 2px 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: all var(--duration) var(--ease);
}
.cat-mgr-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}
.cat-mgr-btn-danger:hover {
    border-color: var(--negative);
    color: var(--negative);
}

/* ── Selection & Slices ────────────────────────────────────────────────── */

/* Checkbox column */
th.col-sel, td.col-sel {
    width: 1%;
    padding: 0 0 0 10px !important;
    text-align: center;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}
th.col-sel { cursor: pointer; }

td.col-sel input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
td.col-sel input[type="checkbox"]:hover {
    border-color: var(--accent-dim);
}
td.col-sel input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}
td.col-sel input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px; top: 0;
    width: 5px; height: 9px;
    border: solid var(--bg-base); border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

th.col-sel input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}
th.col-sel input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}
th.col-sel input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px; top: 0;
    width: 4px; height: 8px;
    border: solid var(--bg-base); border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
th.col-sel input[type="checkbox"].cb-partial {
    border-color: var(--accent-dim);
    background: var(--accent-dim);
}
th.col-sel input[type="checkbox"].cb-partial::after {
    content: '';
    position: absolute;
    left: 2px; top: 4px;
    width: 7px; height: 2px;
    background: var(--bg-base);
    border: none;
    transform: none;
}

/* Selected row highlight */
tbody tr.row-selected {
    background: hsl(38 40% 18% / 0.22) !important;
}
tbody tr.row-selected td:first-child {
    box-shadow: inset 6px 0 0 var(--accent) !important;
}

/* ── Selection Toolbar ── */
.selection-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--accent-dim);
    padding: 6px 16px;
    font-size: 0.78rem;
    z-index: 20;
    position: relative;
    animation: toolbarFadeIn 0.15s var(--ease) both;
}
@keyframes toolbarFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.selection-toolbar .sel-count {
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    min-width: 40px;
}
.selection-toolbar .sel-total {
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    margin-right: auto;
}
.selection-toolbar .sel-total .positive { color: var(--positive); }
.selection-toolbar .sel-total .negative { color: var(--negative); }

.sel-btn {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 4px 12px;
    font-size: 0.72rem;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease),
                background var(--duration) var(--ease);
}
.sel-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
    background: var(--bg-hover);
}
.sel-btn-primary {
    border-color: var(--accent-dim);
    color: var(--accent);
}
.sel-btn-primary:hover {
    background: var(--accent-glow);
}
.sel-btn-clear {
    border: none;
    color: var(--text-muted);
    padding: 4px 8px;
    font-size: 0.68rem;
}
.sel-btn-clear:hover {
    color: var(--negative);
    background: none;
}

/* Add-to-slice dropdown */
.sel-dropdown {
    position: relative;
    display: inline-block;
}
.sel-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    min-width: 180px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 30;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.5);
}
.sel-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background var(--duration) var(--ease);
}
.sel-dropdown-item:hover {
    background: var(--bg-hover);
}
.sel-dropdown-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Category picker (selection toolbar) ── */
/* ── Toolbar dropdown panels (Category, Tag) ── */
.sel-cat-panel {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    width: 260px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(200,168,104,0.08);
    z-index: 200;
    flex-direction: column;
}
.sel-cat-panel.open { display: flex; }
.sel-cat-input {
    display: block;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 8px 12px;
    margin: 8px;
    width: calc(100% - 16px);
    font-size: 0.75rem;
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--duration) var(--ease);
}
.sel-cat-input:focus { border-color: var(--accent-dim); }
.sel-cat-input::placeholder { color: var(--text-muted); opacity: 0.5; }
.sel-cat-list {
    max-height: 240px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    padding: 4px 0;
}
.sel-cat-item {
    padding: 6px 14px;
    font-size: 0.73rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sel-cat-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.sel-cat-clear {
    color: var(--text-muted);
    font-style: italic;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 8px;
}

/* ── Slices & Combos Panel ── */
.slices-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 0 0;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.slices-panel:empty { display: none; padding: 0; border: none; margin: 0; }

.slices-panel-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    flex-shrink: 0;
    user-select: none;
}

.slice-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 200px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
    white-space: nowrap;
    user-select: none;
}
.slice-pill:hover {
    border-color: var(--border-strong);
    background: var(--bg-hover);
}
.slice-pill-active {
    font-weight: 600;
}
.slice-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.slice-count {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-left: 2px;
}
.slice-total {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    margin-left: 2px;
}
.slice-delete {
    font-size: 0.9rem;
    line-height: 1;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--duration) var(--ease), color var(--duration) var(--ease);
    cursor: pointer;
    padding: 0 2px;
}
.slice-pill:hover .slice-delete { opacity: 1; }
.slice-delete:hover { color: var(--negative); }

.slice-pill .sel-cb {
    appearance: none;
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    margin-right: 2px;
}
.slice-pill .sel-cb:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.slice-pill .sel-cb:checked::after {
    content: '';
    position: absolute;
    left: 2px; top: 0;
    width: 4px; height: 7px;
    border: solid var(--bg-base); border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.combo-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    border: 1px dashed var(--border-strong);
    border-radius: 200px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
    white-space: nowrap;
}
.combo-pill:hover {
    border-color: var(--accent-dim);
    background: var(--bg-hover);
}
.combo-pill-active {
    border-style: solid;
    border-color: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}
.combo-dots {
    display: inline-flex;
    gap: 2px;
    margin-right: 2px;
}
.combo-delete {
    font-size: 0.9rem;
    line-height: 1;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--duration) var(--ease), color var(--duration) var(--ease);
    cursor: pointer;
    padding: 0 2px;
}
.combo-pill:hover .combo-delete { opacity: 1; }
.combo-delete:hover { color: var(--negative); }

/* Slice dot indicator on transaction rows */
.slice-indicator {
    display: inline-flex;
    gap: 2px;
    margin-left: 4px;
    vertical-align: middle;
}
.slice-indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* Combo save button in slices panel */
.combo-save-btn {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 200px;
    padding: 3px 10px;
    font-size: 0.68rem;
    font-family: var(--font-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
    white-space: nowrap;
}
.combo-save-btn:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}

/* Separator between slices and combos */
.slices-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
    flex-shrink: 0;
}


.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
    align-items: center;
}

.detail-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 10px;
    border: 1px solid;
    border-radius: 12px;
    letter-spacing: 0.02em;
}

.detail-tag-remove {
    cursor: pointer;
    opacity: 0.5;
    font-size: 0.8rem;
    line-height: 1;
    transition: opacity var(--duration) var(--ease);
}

.detail-tag-remove:hover {
    opacity: 1;
}

.detail-tag-add {
    display: inline-block;
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 8px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    transition: all var(--duration) var(--ease);
}

.detail-tag-add:hover {
    border-color: var(--accent-dim);
    color: var(--accent);
}

/* ── Tag filter (floating panel) ── */
.tag-filter-field {
    position: relative;
    border-left: 1px solid var(--border);
    padding-left: 12px !important;
}
.tag-and-hint {
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.6;
    padding: 8px 10px 4px;
}
.tag-expand-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 280px;
    max-width: 320px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
    z-index: 200;
    display: flex;
    flex-direction: column;
}
.tag-panel-toolbar {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.tag-selected-area {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 0 10px;
    min-height: 0;
}
.tag-selected-area:not(:empty) {
    padding-top: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.tag-dd-search-wrap {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}
.tag-dd-search {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 5px 10px;
    font-size: 0.72rem;
    font-family: var(--font-body);
    outline: none;
}
.tag-dd-search::placeholder { color: var(--text-muted); opacity: 0.5; }
.tag-dd-list {
    max-height: 200px;
    overflow-y: auto;
}
.tag-dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    font-size: 0.72rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}
.tag-dd-item:hover { background: var(--bg-hover); }
.tag-dd-item.in-selection { opacity: 0.3; pointer-events: none; }
.tag-mode-btns {
    display: flex;
    gap: 3px;
}
.tag-mode-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 10px;
    font-size: 0.62rem;
    font-weight: 700;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.tag-mode-btn.active[data-tag-mode="include"] {
    background: var(--bg-active);
    color: var(--positive);
    border-color: var(--positive);
}
.tag-mode-btn.active[data-tag-mode="exclude"] {
    background: var(--bg-active);
    color: var(--negative);
    border-color: var(--negative);
}
.tag-mode-btn.active[data-tag-mode="and"] {
    background: var(--bg-active);
    color: var(--accent);
    border-color: var(--accent);
}
/* tag mode button hover handled inline via JS to match other filter buttons */
.tag-and-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 10px;
    font-size: 0.62rem;
    font-weight: 700;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    margin-left: auto;
}
.tag-and-toggle.active {
    background: var(--bg-active);
    color: var(--accent);
    border-color: var(--accent);
}
/* hover handled inline via JS to match other filter buttons */
.tag-mode-hint {
    font-size: 0.62rem;
    color: var(--text-muted);
    opacity: 0.7;
    flex-shrink: 0;
}
.tag-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
    min-width: 0;
}
.tag-fpill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-family: var(--font-body);
    cursor: pointer;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    transition: all var(--duration) var(--ease);
    user-select: none;
}
.tag-fpill .tag-fdot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tag-fpill.selected {
    background: var(--bg-active);
    color: var(--text);
    border-color: var(--accent-dim);
}
.tag-fpill.selected-exclude {
    background: rgba(200,106,106,0.08);
    color: var(--negative);
    border-color: rgba(200,106,106,0.3);
}
.tag-fpill.selected-and {
    background: rgba(200,168,104,0.1);
    color: var(--accent);
    border-color: var(--accent-dim);
}
.tag-fpill:hover {
    border-color: var(--text-muted);
}

.tag-picker {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    min-width: 220px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 300;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.tag-picker-input {
    width: 100%;
    background: var(--bg-input);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    font-size: 0.75rem;
    font-family: var(--font-body);
    outline: none;
}

.tag-picker-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.tag-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}

.tag-picker-item:hover {
    background: var(--bg-hover);
}

.tag-picker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
