  :root {
    --bg: #0f1117;
    --card: #1a1b23;
    --card-border: #2a2b35;
    --text: #e4e4e7;
    --text-muted: #71717a;
    --green: #22c55e;
    --green-dim: #16a34a;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --blue: #3b82f6;
    --purple: #a855f7;
    --cyan: #06b6d4;
    --teal: #14b8a6;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh;
  }
  .container { max-width: 1400px; margin: 0 auto; padding: 24px; }

  /* Header */
  .header { margin-bottom: 28px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .header-left {}
  .header h1 {
    font-size: 28px; font-weight: 700;
    background: linear-gradient(135deg, #3b82f6, #a855f7);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  }
  .header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
  .header-link {
    font-size: 13px; color: var(--green); text-decoration: none; font-weight: 600;
    padding: 8px 16px; border: 1px solid rgba(34,197,94,0.3); border-radius: 8px;
    background: rgba(34,197,94,0.08); transition: all 0.2s; white-space: nowrap;
  }
  .header-link:hover { background: rgba(34,197,94,0.15); transform: translateY(-1px); }

  /* Tabs */
  .tabs {
    display: flex; gap: 4px; margin-bottom: 24px;
    background: var(--card); border-radius: 10px; padding: 4px;
    border: 1px solid var(--card-border); width: fit-content;
  }
  .tab {
    padding: 8px 20px; border-radius: 8px; border: none;
    cursor: pointer; font-size: 13px; font-weight: 500;
    background: transparent; color: var(--text-muted);
    font-family: inherit; transition: all 0.2s;
  }
  .tab:hover { color: var(--text); background: rgba(255,255,255,0.04); }
  .tab.active {
    background: rgba(59,130,246,0.15); color: var(--blue);
    box-shadow: 0 0 12px rgba(59,130,246,0.1);
  }

  /* KPI Cards */
  .kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 24px;
  }
  .kpi-card {
    background: var(--card); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 18px 20px;
    cursor: pointer; transition: all 0.2s; position: relative;
  }
  .kpi-card:hover {
    border-color: rgba(59,130,246,0.4); background: rgba(255,255,255,0.04);
    transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }
  .kpi-card:active { transform: translateY(0); }
  .kpi-card::after {
    content: "\2192"; position: absolute; top: 14px; right: 14px;
    font-size: 14px; color: var(--text-muted); opacity: 0; transition: opacity 0.2s;
  }
  .kpi-card:hover::after { opacity: 1; }
  .kpi-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1.2px; color: var(--text-muted); margin-bottom: 6px;
  }
  .kpi-value { font-size: 26px; font-weight: 700; }
  .kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

  /* Cards */
  .card {
    background: var(--card); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 20px 24px; margin-bottom: 20px;
  }
  .card-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--blue); margin-bottom: 16px;
  }

  /* Grids */
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

  /* Charts */
  .chart-wrap { position: relative; height: 300px; }
  .chart-wrap-sm { position: relative; height: 260px; }
  .chart-wrap-tall { position: relative; height: 400px; }

  /* Tables */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  thead th {
    text-align: left; padding: 10px 14px; font-size: 11px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    color: var(--blue); border-bottom: 1px solid var(--card-border);
    cursor: pointer; user-select: none;
  }
  thead th:hover { color: var(--cyan); }
  tbody td { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.03); }
  tbody tr:hover { background: rgba(255,255,255,0.02); }
  .mono { font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: 12px; }
  .text-right { text-align: right; }
  .text-center { text-align: center; }
  .bold { font-weight: 700; }
  .amt { color: var(--amber); font-weight: 700; }
  .tag {
    display: inline-block; font-size: 10px; font-weight: 600;
    padding: 2px 8px; border-radius: 4px;
  }

  /* Filter bar */
  .filter-bar {
    display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center;
  }
  .filter-bar select, .filter-bar input {
    background: rgba(255,255,255,0.04); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 8px 14px; color: var(--text);
    font-size: 13px; font-family: inherit; outline: none; transition: border-color 0.2s;
  }
  .filter-bar select:focus, .filter-bar input:focus { border-color: var(--blue); }
  .filter-bar select option { background: var(--card); }
  .btn-clear {
    background: rgba(244,63,94,0.12); border: 1px solid rgba(244,63,94,0.25);
    color: var(--rose); border-radius: 8px; padding: 8px 14px;
    font-size: 13px; cursor: pointer; font-family: inherit;
  }

  /* Legend */
  .legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
  .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
  .legend-dot { width: 10px; height: 10px; border-radius: 50%; }

  /* Insight cards */
  .insight {
    background: rgba(59,130,246,0.06); border: 1px solid rgba(59,130,246,0.15);
    border-radius: 10px; padding: 16px 20px; margin-bottom: 12px;
    transition: all 0.2s; cursor: pointer;
  }
  .insight:hover {
    border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.1);
    transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  }
  .insight-title { font-size: 13px; font-weight: 700; color: var(--blue); margin-bottom: 4px; }
  .insight-text { font-size: 13px; color: var(--text-muted); }
  .insight-val { color: var(--amber); font-weight: 700; }

  /* Category cards */
  .cat-card {
    background: var(--card); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 18px 20px; cursor: pointer; transition: all 0.2s;
  }
  .cat-card:hover {
    border-color: rgba(59,130,246,0.4); background: rgba(255,255,255,0.04);
    transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }
  .cat-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
  .cat-card-amount { font-size: 22px; font-weight: 700; color: var(--amber); }
  .cat-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
  .cat-card-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.05); margin-top: 10px; overflow: hidden; }
  .cat-card-fill { height: 100%; border-radius: 3px; }

  /* Month navigation */
  .month-nav {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
  }
  .month-nav select {
    background: rgba(255,255,255,0.04); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 8px 14px; color: var(--text);
    font-size: 14px; font-weight: 600; font-family: inherit; outline: none;
  }
  .month-nav select option { background: var(--card); }
  .month-nav-btn {
    border-radius: 8px; padding: 8px 16px; font-size: 13px;
    font-weight: 600; cursor: pointer; font-family: inherit; border: none; transition: all 0.2s;
  }
  .month-nav-btn:hover { transform: translateY(-1px); }

  /* Modal */
  .modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); z-index: 1000;
    justify-content: center; align-items: flex-start; padding: 20px;
    overflow-y: auto;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--card); border: 1px solid var(--card-border);
    border-radius: 16px; padding: 28px; max-width: 480px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    max-height: calc(100vh - 40px); display: flex; flex-direction: column;
    margin: auto;
  }
  @media (max-width: 600px) {
    .modal-overlay { padding: 10px; }
    .modal { padding: 18px 14px; border-radius: 12px; max-width: 100%; max-height: none; }
    .modal[style*="max-width:740px"] { max-width: 100% !important; }
  }
  .modal-wide { max-width: 640px; }
  /* Upload steps scroll content, keep buttons visible */
  .upload-step { min-height: 0; overflow: hidden; }
  .upload-step .drop-zone { flex-shrink: 0; }
  #upload-file-list { flex: 1; min-height: 0; overflow-y: auto; }
  #upload-preview { overflow-y: auto; min-height: 0; flex: 1; padding-bottom: 4px; }
  .upload-step .modal-actions { flex-shrink: 0; padding-top: 4px; }
  .upload-step .upload-actions { flex-shrink: 0; }
  .upload-step .processing-section { overflow-y: auto; min-height: 0; flex: 1; }
  .modal-title { font-size: 16px; font-weight: 700; color: var(--blue); margin-bottom: 20px; flex-shrink: 0; }
  .modal-field { margin-bottom: 16px; }
  .modal-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-muted); margin-bottom: 6px; display: block;
  }
  .modal-input, .modal-select {
    width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 10px 14px; color: var(--text);
    font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.2s;
  }
  .modal-input:focus, .modal-select:focus { border-color: var(--blue); }
  .modal-select option { background: var(--card); }
  .modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
  .modal-btn {
    padding: 10px 20px; border-radius: 8px; border: none;
    font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all 0.2s;
  }
  .modal-btn-cancel {
    background: rgba(255,255,255,0.06); color: var(--text-muted);
    border: 1px solid var(--card-border);
  }
  .modal-btn-cancel:hover { background: rgba(255,255,255,0.1); }
  .modal-btn-save {
    background: rgba(59,130,246,0.2); color: var(--blue);
    border: 1px solid rgba(59,130,246,0.3);
  }
  .modal-btn-save:hover { background: rgba(59,130,246,0.3); }
  .modal-btn-reset {
    background: rgba(244,63,94,0.12); color: var(--rose);
    border: 1px solid rgba(244,63,94,0.25); margin-right: auto;
  }
  .modal-btn-reset:hover { background: rgba(244,63,94,0.2); }
  .modal-original { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
  .modal-checkbox {
    display: flex; align-items: center; gap: 8px; margin-top: 12px;
    font-size: 13px; color: var(--text-muted); cursor: pointer;
  }
  .modal-checkbox input { accent-color: var(--blue); }

  /* Upload modal */
  .drop-zone {
    border: 2px dashed var(--card-border); border-radius: 12px;
    padding: 40px 20px; text-align: center; cursor: pointer; transition: all 0.2s;
  }
  .drop-zone.drag-over { border-color: var(--blue); background: rgba(59,130,246,0.06); }
  .drop-zone-icon { font-size: 32px; margin-bottom: 8px; }
  .drop-zone-text { font-size: 14px; font-weight: 600; color: var(--text); }
  .drop-zone-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

  /* Upload format cards */
  .format-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
  .format-card {
    background: rgba(255,255,255,0.03); border: 2px solid var(--card-border);
    border-radius: 12px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s;
  }
  .format-card:hover { border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.06); }
  .format-card.selected { border-color: var(--blue); background: rgba(59,130,246,0.1); }
  .format-icon { font-size: 28px; margin-bottom: 8px; }
  .format-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
  .format-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

  /* Upload steps */
  .upload-step { display: none; }
  .upload-step.active { display: flex; flex-direction: column; }
  .upload-steps-indicator { display: flex; gap: 8px; margin-bottom: 20px; flex-shrink: 0; }
  .step-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--card-border); transition: all 0.2s;
  }
  .step-dot.active { background: var(--blue); width: 24px; border-radius: 4px; }
  .step-dot.done { background: var(--green); }

  /* Preview table */
  .preview-table { max-height: 200px; overflow-y: auto; margin: 12px 0; border-radius: 8px; border: 1px solid var(--card-border); }
  .preview-stat { display: inline-block; padding: 6px 14px; border-radius: 8px; background: rgba(255,255,255,0.04); font-size: 13px; margin: 4px; }
  .preview-stat strong { color: var(--blue); }

  /* Upload file list */
  .upload-file-grid {
    display: flex; flex-direction: column; gap: 8px; margin-top: 16px;
  }
  .upload-file-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border); border-radius: 10px; transition: all 0.15s;
  }
  .upload-file-item:hover { background: rgba(255,255,255,0.06); }
  .upload-file-icon { font-size: 22px; flex-shrink: 0; }
  .upload-file-info { flex: 1; min-width: 0; }
  .upload-file-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .upload-file-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
  .upload-file-remove {
    background: rgba(244,63,94,0.1); border: 1px solid rgba(244,63,94,0.2);
    color: var(--rose); border-radius: 50%; width: 26px; height: 26px;
    cursor: pointer; font-size: 14px; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; transition: all 0.15s;
    font-family: inherit;
  }
  .upload-file-remove:hover { background: rgba(244,63,94,0.2); }
  .upload-actions {
    margin-top: 16px; display: flex; gap: 12px; align-items: center;
  }
  .upload-file-count { font-size: 13px; color: var(--text-muted); font-weight: 600; }

  /* Processing section */
  .processing-section {
    background: rgba(255,255,255,0.02); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 24px;
  }
  .progress-overall { margin-bottom: 16px; }
  .processing-section .progress-label {
    font-size: 13px; color: var(--text-muted); margin-bottom: 6px;
    display: flex; justify-content: space-between;
  }
  .processing-section .progress-bar {
    height: 8px; background: rgba(255,255,255,0.05);
    border-radius: 4px; overflow: hidden;
  }
  .processing-section .progress-fill {
    height: 100%; background: var(--blue); border-radius: 4px;
    transition: width 0.3s; width: 0%;
  }
  .process-log {
    background: rgba(0,0,0,0.2); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 12px; max-height: 200px;
    overflow-y: auto; margin-top: 16px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 12px; line-height: 1.8;
  }
  .process-log-line { color: var(--text-muted); }
  .process-log-line.info { color: var(--blue); }
  .process-log-line.success { color: var(--green); }
  .process-log-line.error { color: var(--rose); }

  /* Month bucket cards */
  .month-bucket-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px; margin-top: 12px;
  }
  .month-bucket-card {
    background: rgba(255,255,255,0.03); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 16px 18px;
  }
  .month-bucket-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
  }
  .month-bucket-name { font-size: 15px; font-weight: 700; color: var(--text); }
  .month-bucket-count { font-size: 12px; color: var(--text-muted); }
  .month-bucket-total { font-size: 20px; font-weight: 700; color: var(--amber); margin-bottom: 4px; }
  .month-bucket-dates { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
  .month-bucket-conflict {
    margin-top: 10px; padding: 10px 12px; border-radius: 8px;
    background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25);
  }
  .month-bucket-conflict-label {
    font-size: 12px; color: var(--amber); font-weight: 600; margin-bottom: 6px;
  }
  .month-bucket-radio {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-muted); cursor: pointer; margin-top: 4px;
  }
  .month-bucket-radio input { accent-color: var(--blue); }
  .month-bucket-select {
    display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; min-width: 0;
  }
  .month-bucket-select input { accent-color: var(--blue); flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
  .month-bucket-card.month-bucket-deselected {
    opacity: 0.35; border-style: dashed;
  }

  /* Source type input in upload review */
  .source-type-group { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
  .source-type-input { flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--card-border); background: var(--card-bg, var(--card)); color: var(--text); font-size: 14px; }
  .source-type-input:focus { outline: none; border-color: var(--blue); }
  .source-info-icon { cursor: help; color: var(--text-muted); font-size: 18px; position: relative; flex-shrink: 0; }
  .source-info-icon:hover .source-info-tip { display: block; }
  .source-info-tip { display: none; position: absolute; bottom: calc(100% + 8px); right: 0; width: 280px; padding: 10px 12px; background: var(--card-bg, var(--card)); border: 1px solid var(--card-border); border-radius: 8px; font-size: 12px; color: var(--text-muted); box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 10; line-height: 1.4; }

  /* Light theme adjustments */
  body.light .upload-file-item { background: rgba(0,0,0,0.02); }
  body.light .upload-file-item:hover { background: rgba(0,0,0,0.04); }
  body.light .processing-section { background: rgba(0,0,0,0.02); }
  body.light .process-log { background: rgba(0,0,0,0.03); }
  body.light .month-bucket-card { background: rgba(0,0,0,0.02); }

  /* Edit & delete indicators */
  .edit-icon, .delete-icon {
    display: inline-block; margin-left: 4px; font-size: 12px; color: var(--text-muted);
    opacity: 0; transition: opacity 0.2s; cursor: pointer; vertical-align: middle;
  }
  .delete-icon:hover { color: #ef4444; }
  .edit-icon:hover { color: var(--blue); }
  tbody tr:hover .edit-icon, tbody tr:hover .delete-icon { opacity: 1; }
  .edit-dot {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--cyan); margin-left: 6px; vertical-align: middle;
  }

  /* Add expense button */
  .btn-add-expense {
    background: var(--blue); color: #fff; border: none; border-radius: 8px;
    padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: background 0.2s; white-space: nowrap;
  }
  .btn-add-expense:hover { background: #2563eb; }

  /* Help modal styles */
  .help-section { margin-bottom: 20px; }
  .help-section-title { font-size: 13px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 1px; padding-bottom: 6px; border-bottom: 1px solid var(--card-border); margin-bottom: 10px; }
  .help-text { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
  .help-step { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
  .help-step-num { width: 28px; height: 28px; border-radius: 50%; background: rgba(59,130,246,0.15); color: var(--blue); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .help-step-text { font-size: 13px; color: var(--text-muted); line-height: 1.6; padding-top: 3px; }

  /* Compare delta cards */
  .delta-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px; margin-bottom: 24px;
  }
  .delta-card {
    background: var(--card); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 18px 20px;
  }
  .delta-value { font-size: 22px; font-weight: 700; }
  .delta-change { font-size: 13px; font-weight: 600; margin-top: 4px; }
  .delta-up { color: var(--rose); }
  .delta-down { color: var(--green); }

  /* Empty state */
  .empty-state {
    text-align: center; padding: 60px 20px;
  }
  .empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
  .empty-state-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
  .empty-state-text { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; max-width: 500px; margin-left: auto; margin-right: auto; }
  .empty-state-btn {
    background: rgba(59,130,246,0.2); color: var(--blue); border: 1px solid rgba(59,130,246,0.3);
    border-radius: 10px; padding: 12px 28px; font-size: 15px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all 0.2s;
  }
  .empty-state-btn:hover { background: rgba(59,130,246,0.3); transform: translateY(-2px); }

  /* Merchant rows */
  .merchant-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; margin: 0 -12px; border-bottom: 1px solid rgba(255,255,255,0.03);
    border-radius: 8px; transition: all 0.2s; cursor: pointer;
  }
  .merchant-row:hover { background: rgba(255,255,255,0.03); }

  /* Heatmap */
  .heatmap-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .heatmap-cell {
    aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center;
    justify-content: center; font-size: 12px; font-weight: 600;
  }
  .heatmap-label { font-size: 11px; color: var(--text-muted); text-align: center; padding: 4px; }

  .view { display: none; }
  .view.active { display: block; }

  /* Sortable th */
  th.sorted-asc::after { content: " \u25B2"; font-size: 9px; }
  th.sorted-desc::after { content: " \u25BC"; font-size: 9px; }

  /* Global search */
  #global-search:focus { border-color: var(--blue); }
  .search-result {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 16px; cursor: pointer; transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
  }
  .search-result:last-child { border-bottom: none; }
  .search-result:hover { background: rgba(255,255,255,0.04); }
  .search-result-name { font-size: 13px; font-weight: 600; }
  .search-result-name mark { background: rgba(59,130,246,0.3); color: var(--text); border-radius: 2px; padding: 0 2px; }
  .search-result-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
  .search-result-amount { font-size: 13px; font-weight: 700; color: var(--amber); white-space: nowrap; }
  .search-group-header {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--blue); padding: 10px 16px 4px; background: rgba(255,255,255,0.02);
  }

  /* Light theme */
  body.light {
    --bg: #f5f5f7; --card: #ffffff; --card-border: #e0e0e5;
    --text: #1a1a2e; --text-muted: #6b6b80;
  }
  body.light .modal { box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
  body.light .modal-select option, body.light .filter-bar select option,
  body.light .month-nav select option { background: #fff; }
  body.light .search-result-name mark { background: rgba(59,130,246,0.25); color: #1a1a2e; }

  /* Theme toggle */
  .theme-toggle {
    background: rgba(255,255,255,0.06); border: 1px solid var(--card-border);
    border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 16px;
    line-height: 1; transition: all 0.2s; color: var(--text);
  }
  .theme-toggle:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }

  /* Responsive */
  @media (max-width: 900px) {
    .container { padding: 14px; }
    .header h1 { font-size: 20px; }
    .header p { font-size: 12px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi-value { font-size: 20px; }
    .kpi-card { padding: 14px 16px; }
    .tabs {
      width: 100%; display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 4px;
    }
    .tab { padding: 8px 6px; font-size: 11px; white-space: nowrap; text-align: center; }
    .card { padding: 16px; margin-bottom: 14px; }
    .card-title { font-size: 11px; margin-bottom: 12px; }
    .chart-wrap { height: 260px; }
    .chart-wrap-sm { height: 220px; }
    .chart-wrap-tall { height: 320px; }
    table { font-size: 12px; }
    thead th { padding: 8px 10px; font-size: 10px; }
    tbody td { padding: 8px 10px; font-size: 12px; }
    .filter-bar select, .filter-bar input { font-size: 12px; padding: 7px 10px; width: 100%; }
    .filter-bar { gap: 8px; }
    .format-grid { grid-template-columns: 1fr; }
    .month-bucket-grid { grid-template-columns: 1fr; }
    .upload-file-grid { }
    .process-log { max-height: 150px; font-size: 11px; }
    .processing-section { padding: 16px; }
    .insight { padding: 12px 14px; }
    .insight-title { font-size: 12px; }
    .insight-text { font-size: 12px; }
    .cat-card { padding: 14px 16px; }
    .cat-card-amount { font-size: 18px; }
  }
  @media (max-width: 480px) {
    .container { padding: 10px; }
    .header h1 { font-size: 17px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-value { font-size: 18px; }
    .kpi-card { padding: 12px 14px; }
    .kpi-label { font-size: 9px; letter-spacing: 1px; }
    .kpi-sub { font-size: 11px; }
    .tabs { grid-template-columns: repeat(3, 1fr); gap: 3px; }
    .tab { padding: 7px 4px; font-size: 10px; }
    .chart-wrap { height: 220px; }
    .chart-wrap-sm { height: 200px; }
    .chart-wrap-tall { height: 280px; }
    .tag { font-size: 8px; padding: 1px 5px; }
  }

  /* ── Pagination ── */
  .pagination-bar {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    margin-top: 12px; padding: 10px 0; font-size: 13px; color: var(--text-muted);
  }
  .pagination-bar .page-size-wrap { display: flex; align-items: center; gap: 6px; }
  .pagination-bar .page-size-wrap label { font-size: 12px; color: var(--text-muted); }
  .pagination-bar select.page-size-select {
    background: var(--card-bg, var(--card)); border: 1px solid var(--card-border); border-radius: 6px;
    padding: 4px 8px; color: var(--text); font-size: 12px; font-family: inherit; cursor: pointer;
  }
  .pagination-bar .page-btns { display: flex; align-items: center; gap: 4px; }
  .pagination-bar .page-btn {
    background: var(--card-bg, var(--card)); border: 1px solid var(--card-border); border-radius: 6px;
    padding: 4px 10px; color: var(--text); font-size: 12px; cursor: pointer; font-family: inherit;
    transition: all 0.15s;
  }
  .pagination-bar .page-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
  .pagination-bar .page-btn:disabled { opacity: 0.35; cursor: default; }
  .pagination-bar .page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
  .pagination-bar .page-info { font-size: 12px; }
  @media (max-width: 480px) {
    .pagination-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .pagination-bar .page-size-wrap { justify-content: center; }
    .pagination-bar .page-btns { justify-content: center; flex-wrap: wrap; }
    .pagination-bar .page-btn { padding: 6px 12px; min-height: 34px; }
    .pagination-bar .page-info { text-align: center; }
  }
