/* ============================================================
   Ledger Chat — Warm Ledger Redesign
   ============================================================ */

:root {
  /* Warm paper backgrounds */
  --bg-app: #F5F3EF;
  --bg-primary: #FAF9F6;
  --bg-secondary: #F0EDE8;
  --bg-tertiary: #E8E5E0;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #FAFAF8;

  /* Text — warm charcoal, not pure black */
  --text-primary: #2D3034;
  --text-secondary: #6B7280;
  --text-muted: #A3A8B0;

  /* Borders — warm with opacity */
  --border: rgba(0, 0, 0, 0.08);
  --border-light: rgba(0, 0, 0, 0.05);
  --border-strong: rgba(0, 0, 0, 0.12);

  /* Brand green — sage/forest */
  --green: #2D8B55;
  --green-hover: #257A49;
  --green-light: #E8F5EE;
  --green-soft: rgba(45, 139, 85, 0.08);

  /* Warm blue */
  --blue: #4F7DF3;
  --blue-light: #EBF0FE;
  --blue-soft: rgba(79, 125, 243, 0.08);

  /* Amber */
  --amber: #D4940A;
  --amber-light: #FFF8E7;

  /* Red */
  --red: #C53030;
  --red-light: #FFF0F0;
  --red-soft: rgba(197, 48, 48, 0.06);

  /* Semantic aliases */
  --positive: var(--green);
  --positive-bg: var(--green-light);
  --positive-soft: var(--green-soft);
  --negative: var(--red);
  --negative-bg: var(--red-light);
  --negative-soft: var(--red-soft);
  --interactive: var(--blue);
  --interactive-hover: #3D6AE0;
  --interactive-soft: var(--blue-soft);
  --warning: var(--amber);
  --highlight: var(--amber-light);
  --focus-ring: rgba(79, 125, 243, 0.25);

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Radius — warm, approachable */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Sizing */
  --sidebar-width: 220px;
  --sidebar-collapsed: 56px;
  --chat-width: 420px;
  --input-height: 40px;
  --row-height-compact: 40px;
  --row-height-standard: 52px;
  --max-app-width: 1600px;

  /* Shadows — very subtle, warm */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

  /* Category colors */
  --cat-groceries: #2D8B55;
  --cat-dining: #D4940A;
  --cat-housing: #4F7DF3;
  --cat-transport: #6B7280;
  --cat-entertainment: #8B5CF6;
  --cat-health: #C53030;
  --cat-shopping: #0891B2;
  --cat-services: #6366F1;
  --cat-other: #9CA3AF;
}

/* ============================================================
   Reset
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
}

/* ============================================================
   Upload Screen
   ============================================================ */

.upload-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-app);
}

.upload-screen-inner {
  text-align: center;
  max-width: 480px;
  width: 100%;
  padding: var(--space-2xl);
}

.upload-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-3xl);
}

.brand-mark {
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-3xl) var(--space-xl);
  cursor: pointer;
  transition: background-color 200ms, border-color 200ms;
}

.upload-zone:hover {
  background: var(--bg-surface);
  border-color: var(--green);
}

.upload-zone.dragover {
  background: var(--green-soft);
  border-color: var(--green);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.upload-icon svg {
  width: 40px;
  height: 40px;
  stroke-width: 1.5;
}

.upload-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--text-primary);
}

.upload-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.upload-formats {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.upload-browse-btn {
  margin-top: var(--space-sm);
  border-radius: var(--radius-md);
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-md);
  line-height: 1.5;
}

.upload-hint code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Upload Setup (API key onboarding) */
.upload-setup {
  text-align: left;
  margin-bottom: var(--space-xl);
}

.upload-setup-title {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.upload-setup-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.upload-key-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.provider-toggle-sm {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.provider-sm {
  padding: 6px var(--space-md);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: none;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}

.provider-sm.active {
  background: var(--text-primary);
  color: #FFFFFF;
}

.upload-key-input {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-surface);
}

.upload-key-input:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.btn-sm {
  height: 36px;
  padding: 0 var(--space-lg);
  font-size: 13px;
  font-weight: 500;
  color: #FFFFFF;
  background: var(--green);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 150ms;
  flex-shrink: 0;
}

.btn-sm:hover {
  background: var(--interactive-hover);
}

.upload-setup-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.upload-setup-help a {
  color: var(--interactive);
  text-decoration: none;
}

.upload-setup-help a:hover {
  text-decoration: underline;
}

.upload-key-status {
  font-size: 13px;
  margin-top: var(--space-sm);
}

.upload-security {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-xl);
}

.bundle-hint {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--amber-light);
  border: 1px solid var(--amber);
  border-radius: var(--radius-lg);
  max-width: 400px;
  text-align: left;
  animation: fadeIn 200ms ease;
}

.bundle-hint-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.bundle-hint-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.bundle-hint-body p {
  margin-top: var(--space-sm);
  color: var(--text-secondary);
}

.bundle-hint-body code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

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

.upload-progress {
  margin-top: var(--space-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.upload-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.upload-status {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.upload-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
  max-width: 260px;
}

.upload-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  opacity: 0.4;
  transition: opacity 200ms;
}

.upload-step.active {
  opacity: 1;
  color: var(--text-secondary);
}

.upload-step.done {
  opacity: 1;
  color: var(--positive);
}

.upload-step-icon {
  width: 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
}

.upload-step.active .upload-step-icon::after {
  content: '...';
  animation: pulse-dots 1s infinite;
}

.upload-step.done .upload-step-icon::after {
  content: '\2713';
}

.upload-step:not(.active):not(.done) .upload-step-icon::after {
  content: '\25CB';
}

@keyframes pulse-dots {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.upload-done {
  font-size: 14px;
  font-weight: 500;
  color: var(--positive);
  animation: fade-in 300ms ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   App Layout
   ============================================================ */

.app-layout {
  display: flex;
  height: 100vh;
  max-width: var(--max-app-width);
  margin: 0 auto;
  background: var(--bg-app);
  position: relative;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-xl);
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-md);
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: var(--space-lg) var(--space-sm) var(--space-sm);
}

.nav-section-label:first-child {
  padding-top: var(--space-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color 150ms, color 150ms;
  margin-bottom: 2px;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--green-soft);
  color: var(--green);
}

.nav-item.active svg {
  color: var(--green);
}

.nav-item:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: 13px;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color 150ms, color 150ms;
}

.sidebar-footer-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

.sidebar-footer-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-secondary);
}

.sidebar-footer-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* ============================================================
   Main Content
   ============================================================ */

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-app);
}

/* Top Bar */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  gap: var(--space-lg);
  background: var(--bg-app);
}

.topbar-left {
  min-width: 0;
}

.view-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

/* Period Selector */
.period-selector {
  display: flex;
  gap: var(--space-xs);
}

.period-pill {
  padding: 6px var(--space-md);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color 150ms, color 150ms, border-color 150ms;
}

.period-pill:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.period-pill.active {
  background: var(--text-primary);
  color: #FFFFFF;
  border-color: var(--text-primary);
}

.period-pill:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* Icon Button */
.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-icon:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* Chat Toggle Button */
.btn-chat-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px var(--space-lg);
  font-size: 13px;
  font-weight: 500;
  color: #FFFFFF;
  background: var(--green);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 150ms;
}

.btn-chat-toggle svg {
  width: 16px;
  height: 16px;
}

.btn-chat-toggle:hover {
  background: var(--green-hover);
}

.btn-chat-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* View Content */
.view-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--space-xl) var(--space-xl);
}

/* View Toolbar (search, filters, etc. inside view content) */
.view-toolbar {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  background: var(--bg-app);
  position: sticky;
  top: 0;
  z-index: 10;
}

.view-toolbar input[type="text"],
.view-toolbar select,
.view-toolbar .filter-pill {
  height: 36px;
  line-height: 36px;
  box-sizing: border-box;
}

.view-toolbar input[type="text"],
.view-toolbar select {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-surface);
}

.view-toolbar input[type="text"]:focus-visible,
.view-toolbar select:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.filter-pill {
  padding: 6px var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background-color 150ms, color 150ms;
}

.filter-pill:hover {
  background: var(--bg-secondary);
}

.filter-pill.active {
  background: var(--text-primary);
  color: #FFFFFF;
  border-color: var(--text-primary);
}

.filter-pill:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.filter-pills {
  display: flex;
  gap: var(--space-xs);
}

/* Spending grid zero cells */
.zero-cell {
  color: var(--border-strong);
  font-weight: 400;
}

/* Year/Year year toggles */
.yoy-year-toggles {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

/* Toolbar search inputs */
.view-toolbar .search-input {
  width: 200px;
}

.view-toolbar .search-input-sm {
  width: 180px;
}

/* Copy as CSV button + Explain pill — right-aligned in toolbar */
.copy-csv-btn {
  margin-left: auto;
  padding: 0 var(--space-md);
  height: 36px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
  white-space: nowrap;
}

.copy-csv-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.copy-csv-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* Toolbar checkbox labels (e.g. "Exclude transfers") */
.toolbar-label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* Total rows in data tables */
.data-table .total-row {
  font-weight: 600;
}

.data-table .total-row td {
  border-top: 2px solid var(--border-strong);
}

/* Payee cell weight */
.data-table .payee-cell {
  font-weight: 500;
}

/* Row with negative net (expenses > income) */
.data-table tr.row-negative {
  background: var(--negative-soft);
}

/* ============================================================
   Chat Slide-Over Panel
   ============================================================ */

.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 50;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 300ms;
}

.chat-overlay[style*="block"] {
  opacity: 1;
}

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--chat-width);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-panel.open {
  transform: translateX(0);
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 56px;
}

.chat-panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-panel-title svg {
  width: 18px;
  height: 18px;
  color: var(--green);
}

.chat-panel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms;
}

.btn-icon-sm svg {
  width: 14px;
  height: 14px;
}

.btn-icon-sm:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-icon-sm:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.chat-model-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px var(--space-sm);
  font-family: inherit;
  font-size: 11px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  height: 32px;
  cursor: pointer;
}

.chat-model-select:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all 100ms;
}

.thinking-toggle:has(input:checked) {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}

.thinking-toggle input {
  display: none;
}

.thinking-label::before {
  content: '\25CB';
  margin-right: 2px;
  font-size: 10px;
}

.thinking-toggle:has(input:checked) .thinking-label::before {
  content: '\25CF';
}

/* Chat Sessions Drawer */
.chat-sessions-drawer {
  border-bottom: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-primary);
}

.chat-session-list {
  display: flex;
  flex-direction: column;
}

.chat-session-item {
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background-color 150ms;
}

.chat-session-item:hover {
  background: var(--bg-secondary);
}

.chat-session-item.active {
  background: var(--green-soft);
  color: var(--text-primary);
}

.chat-session-title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-session-date {
  font-size: 10px;
  color: var(--text-muted);
}

.chat-session-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  margin-left: auto;
  opacity: 0;
  transition: opacity 150ms;
}

.chat-session-item:hover .chat-session-delete {
  opacity: 1;
}

.chat-session-delete:hover {
  color: var(--negative);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: var(--space-lg);
  gap: var(--space-md);
}

.chat-empty-icon {
  color: var(--text-muted);
  opacity: 0.4;
}

.chat-empty-icon svg {
  width: 32px;
  height: 32px;
}

.chat-api-notice {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
}

.chat-api-notice strong {
  color: var(--text-primary);
}

.chat-message {
  margin-bottom: var(--space-lg);
  max-width: 100%;
}

/* User messages — right-aligned, dark bubble */
.chat-message.user {
  display: flex;
  justify-content: flex-end;
}

.chat-message.user .message-content {
  background: var(--text-primary);
  color: #FFFFFF;
  padding: var(--space-sm) var(--space-lg);
  max-width: 85%;
  font-size: 13px;
  line-height: 1.5;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

/* AI messages — left-aligned, light bubble */
.chat-message.assistant {
  display: flex;
  justify-content: flex-start;
}

.chat-message.assistant .message-content {
  background: var(--bg-primary);
  padding: var(--space-md) var(--space-lg);
  max-width: 90%;
  font-size: 13px;
  line-height: 1.5;
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
  border: 1px solid var(--border);
}

/* Tables inside AI messages */
.chat-message.assistant .message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-sm) 0;
  font-size: 12px;
}

.chat-message.assistant .message-content table th {
  background: var(--bg-secondary);
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  border-bottom: 1px solid var(--border-strong);
}

.chat-message.assistant .message-content table td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.chat-message.assistant .message-content table .num {
  text-align: right;
  font-family: var(--font-mono);
}

.chat-message.assistant .message-content table tbody tr:nth-child(even) {
  background: var(--bg-surface);
}

.chat-message.assistant .message-content table tbody tr:hover {
  background: var(--bg-secondary);
}

.chat-message.assistant .message-content .negative {
  color: var(--negative);
}

.chat-message.assistant .message-content .positive {
  color: var(--positive);
}

/* Chat context note */
.chat-context-note {
  border-left: 3px solid var(--interactive);
  background: var(--interactive-soft);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Tool execution indicators */
.tool-indicator {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: var(--space-xs) 0;
}

.tool-indicator.complete {
  color: var(--positive);
}

.tool-indicator.in-progress {
  color: var(--text-secondary);
}

.tool-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

/* Chat Suggestions */
.chat-suggestions {
  padding: 0 var(--space-lg) var(--space-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.suggestion-chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: border-color 150ms, color 150ms, background-color 150ms;
}

.suggestion-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.suggestion-chip:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  align-items: flex-end;
}

.chat-input-bar textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-lg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  min-height: var(--input-height);
  max-height: 120px;
  overflow-y: auto;
  background: var(--bg-primary);
  transition: border-color 150ms;
}

.chat-input-bar textarea:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  background: var(--green);
  color: #FFFFFF;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms, transform 100ms;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

.chat-send-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--green-hover);
  transform: scale(1.05);
}

.chat-send-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.chat-cost-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 0 var(--space-sm);
}

/* ============================================================
   Tables — Primary Data Display
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border-radius: var(--radius-lg);
}

/* Table container with rounded corners */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.data-table th {
  background: var(--bg-secondary);
  padding: 0 var(--space-md);
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  height: var(--row-height-compact);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable-th:hover {
  color: var(--text-primary);
}

.data-table th.sort-asc::after {
  content: ' \25B2';
  font-size: 9px;
}

.data-table th.sort-desc::after {
  content: ' \25BC';
  font-size: 9px;
}

.trend-summary {
  margin-bottom: var(--space-sm);
}

.trend-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  transition: all 100ms;
}

.trend-pill:hover {
  background: var(--bg-secondary);
}

.trend-pill-name {
  font-weight: 500;
}

.trend-pill-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.trend-pill.rising {
  border-color: var(--negative-bg);
}

.trend-pill.rising .trend-pill-pct {
  color: var(--negative);
}

.trend-pill.falling {
  border-color: var(--positive-bg);
}

.trend-pill.falling .trend-pill-pct {
  color: var(--positive);
}

.trend-col, .trend-col-header {
  width: 70px;
  min-width: 70px;
  text-align: center;
}

.trend-micro {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  white-space: nowrap;
}

.trend-micro.rising {
  color: var(--negative);
  background: var(--negative-bg);
}

.trend-micro.falling {
  color: var(--positive);
  background: var(--positive-bg);
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
}

.data-table td {
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--border);
  height: var(--row-height-standard);
  vertical-align: middle;
}

.data-table.compact td {
  height: var(--row-height-compact);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(245, 243, 239, 0.5);
}

.data-table tbody tr:hover {
  background: var(--blue-soft);
}

/* Selected/expanded row */
.data-table tbody tr.selected,
.data-table tbody tr.expanded {
  background: var(--blue-soft);
  border-left: 3px solid var(--blue);
}

.data-table .negative,
.data-table .amount-negative {
  color: var(--negative);
}

.data-table .positive,
.data-table .amount-positive {
  color: var(--positive);
}

.data-table .payee {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.data-table .date-col {
  font-family: var(--font-mono);
  white-space: nowrap;
  font-size: 12px;
}

/* Category Dots */
.cat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--space-sm);
  vertical-align: middle;
  flex-shrink: 0;
}

.cat-dot-groceries { background: var(--cat-groceries); }
.cat-dot-dining { background: var(--cat-dining); }
.cat-dot-housing { background: var(--cat-housing); }
.cat-dot-transport { background: var(--cat-transport); }
.cat-dot-entertainment { background: var(--cat-entertainment); }
.cat-dot-health { background: var(--cat-health); }
.cat-dot-shopping { background: var(--cat-shopping); }
.cat-dot-services { background: var(--cat-services); }
.cat-dot-other { background: var(--cat-other); }

/* Frequency Badges */
.freq-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  display: inline-block;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* Badges (split, transfer, recurring, tag) */
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid;
  font-family: var(--font-mono);
  display: inline-block;
  line-height: 1.4;
  border-radius: var(--radius-sm);
}

.badge-split {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.badge-transfer {
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.badge-recurring {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.badge-tag {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

.badge-receipt {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

/* Row expansion / detail */
.row-detail {
  background: var(--blue-soft);
  border-left: 3px solid var(--blue);
  border-bottom: 1px solid var(--border);
}

.row-detail td {
  padding: var(--space-md) var(--space-lg);
  height: auto;
}

.row-detail .detail-header {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--blue);
  margin-bottom: var(--space-sm);
}

.row-detail .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-sm) var(--space-xl);
  font-size: 12px;
}

.row-detail .detail-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.split-rows {
  margin-top: var(--space-sm);
}

.split-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.split-row-name {
  font-weight: 500;
  font-size: 13px;
}

.split-row-category {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: var(--space-sm);
}

.split-row-amount {
  font-family: var(--font-mono);
  text-align: right;
}

/* Spending grid sticky */
.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-surface);
}

.data-table tbody tr:nth-child(even) .sticky-col {
  background: var(--bg-secondary);
}

.data-table thead th.sticky-col {
  z-index: 6;
  background: var(--bg-surface);
}

.highlight-cell {
  background: var(--highlight);
}

.bold-delta {
  font-weight: 600;
}

/* View empty / no-data states */
.view-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.view-disclaimer {
  padding: var(--space-md) var(--space-lg);
  background: var(--amber-light);
  border: 1px solid rgba(212, 148, 10, 0.15);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-lg);
}

.view-summary-row {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--space-lg);
}

.view-footnotes {
  padding: var(--space-md) var(--space-lg);
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.5;
  margin-top: var(--space-lg);
}

/* Load more */
.load-more-row {
  text-align: center;
  padding: var(--space-lg);
}

.load-more-btn {
  padding: var(--space-sm) var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background-color 150ms;
}

.load-more-btn:hover {
  background: var(--bg-secondary);
}

.load-more-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* ============================================================
   Transaction View — Summary Bar, Day Grouping, Compact Rows
   ============================================================ */

.txn-summary-bar {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.txn-summary-stat {
  display: flex;
  flex-direction: column;
}

.txn-summary-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.txn-summary-value {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Day grouping headers */
.txn-day-header td {
  padding: var(--space-sm) var(--space-md) !important;
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 12px;
}

.txn-day-date {
  font-weight: 600;
  color: var(--text-primary);
}

.txn-day-total {
  font-family: var(--font-mono);
  font-weight: 600;
  margin-left: var(--space-lg);
}

.txn-day-count {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: var(--space-md);
}

/* Compact transaction rows */
.txn-row {
  cursor: pointer;
}

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

.txn-table .txn-date-cell {
  width: 1px;
  padding: 0 !important;
}

.txn-desc {
  padding: var(--space-xs) var(--space-md);
}

.txn-payee {
  font-size: 13px;
  font-weight: 500;
}

.txn-category {
  font-size: 11px;
  color: var(--text-muted);
}

.txn-split-badge {
  font-size: 9px;
  font-weight: 600;
  color: var(--interactive);
  background: rgba(37, 99, 235, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
}

.txn-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.txn-account {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Expand row for transaction details */
.txn-expand-cell {
  padding: var(--space-sm) var(--space-md) var(--space-sm) var(--space-xl) !important;
  background: var(--bg-secondary) !important;
  font-size: 12px;
  color: var(--text-secondary);
}

.txn-splits {
  margin-top: var(--space-xs);
}

.txn-split-line {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 12px;
}

.txn-split-amt {
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ============================================================
   Sankey / Cash Flow
   ============================================================ */

.cashflow-content {
  padding: var(--space-md);
}

.cashflow-summary {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  font-size: 13px;
  flex-wrap: wrap;
}

.cashflow-divider {
  color: var(--border-strong);
}

.cashflow-chart-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow: hidden;
}

.sankey-link {
  transition: stroke-opacity 150ms;
}

.sankey-node {
  cursor: pointer;
}

/* ============================================================
   Settings Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 400;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background-color 150ms;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.modal-close:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.modal-body {
  padding: var(--space-xl);
}

.form-group {
  margin-bottom: var(--space-xl);
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.provider-toggle {
  display: flex;
  gap: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.provider-btn {
  flex: 1;
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background-color 150ms, color 150ms;
}

.provider-btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.provider-btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: none;
}

.provider-btn.active {
  background: var(--text-primary);
  color: #FFFFFF;
  border-color: var(--text-primary);
}

.provider-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.api-key-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.api-key-row input {
  flex: 1;
  height: var(--input-height);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color 150ms;
}

.api-key-row input:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.key-status {
  width: 12px;
  height: 12px;
  background: var(--border-strong);
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
  transition: background-color 200ms;
}

.key-status.saved {
  background: var(--positive);
}

.modal-body select {
  width: 100%;
  height: var(--input-height);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-md);
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-surface);
}

.modal-body select:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.form-actions {
  padding-top: var(--space-sm);
}

.btn-primary {
  width: 100%;
  height: var(--input-height);
  background: var(--green);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms;
}

.btn-primary:hover {
  background: var(--green-hover);
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

/* ============================================================
   Toast Notifications
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--text-primary);
  color: #FFFFFF;
  padding: var(--space-md) var(--space-lg);
  font-size: 13px;
  max-width: 360px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease;
}

.toast.error {
  background: var(--negative);
}

.toast.success {
  background: var(--positive);
}

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

/* ============================================================
   Dashboard
   ============================================================ */

/* New dashboard grid layout */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  padding: var(--space-lg);
}

.dash-row {
  display: grid;
  gap: var(--space-lg);
}

.dash-row-1 { grid-template-columns: 3fr 2fr; }
.dash-row-2 { grid-template-columns: 55fr 45fr; }
.dash-row-3 { grid-template-columns: 1fr; }
.dash-row-4 { grid-template-columns: 1fr 1fr; }

.dash-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  min-width: 0;
  overflow: hidden;
}

.dash-widget-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-xs);
}

.dash-hero-stat {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.pace-stats {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-top: var(--space-xs);
}

.pace-delta {
  font-size: 12px;
  font-family: var(--font-mono);
}

.pace-delta.negative { color: var(--negative); }
.pace-delta.positive { color: var(--positive); }

.pace-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Calendar heat map */
.calendar-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.cal-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 2px;
}

.calendar-legend {
  display: flex;
  gap: var(--space-md);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: var(--space-sm);
  justify-content: center;
}

.cal-tooltip {
  position: fixed;
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.cal-cell {
  cursor: pointer;
}

.cal-cell:hover {
  stroke: var(--text-secondary);
  stroke-width: 1.5;
}

/* Switchable heat map */
.heatmap-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.heatmap-mode-select {
  font-size: 11px;
  font-family: var(--font-body);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.heatmap-grid-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

.heatmap-grid {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: min-content;
}

.heatmap-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.heatmap-header-row {
  margin-bottom: var(--space-xs);
}

.heatmap-label {
  width: 130px;
  min-width: 130px;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: var(--space-sm);
}

.heatmap-col-label {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heatmap-cell {
  border-radius: 3px;
  flex-shrink: 0;
  transition: opacity 100ms;
}

.heatmap-row-highlight .heatmap-cell {
  opacity: 0.85;
}

.heatmap-col-highlight {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.heatmap-total {
  width: 65px;
  min-width: 65px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
  padding-left: var(--space-sm);
}

.heatmap-total-label {
  width: 65px;
  min-width: 65px;
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
  padding-left: var(--space-sm);
}

.heatmap-tooltip {
  position: fixed;
  z-index: 200;
  display: none;
  min-width: 200px;
  max-width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  pointer-events: none;
  font-size: 12px;
}

.heatmap-legend {
  display: flex;
  gap: var(--space-md);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: var(--space-sm);
  justify-content: center;
  align-items: center;
}

.heatmap-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 2px;
}

/* Legacy dashboard classes (kept for treemap + mini-lists) */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-lg);
}

.dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  cursor: pointer;
  min-width: 0;
  transition: box-shadow 200ms, border-color 200ms;
}

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

.dash-wide {
  grid-column: span 2;
}

.dash-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-sm);
}

.dash-card-value {
  font-size: 28px;
  font-weight: 400;
  font-family: var(--font-display);
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.dash-card-delta {
  font-size: 12px;
  font-family: var(--font-mono);
}

.dash-card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.dash-card .positive { color: var(--positive); }
.dash-card .negative { color: var(--negative); }

.dash-cat-list {
  margin-top: var(--space-sm);
}

.dash-cat-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 3px 0;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.dash-cat-item:hover {
  background: var(--bg-secondary);
}

.dash-cat-rank {
  width: 16px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

.dash-cat-name {
  width: 100px;
  min-width: 80px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-cat-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}

.dash-cat-bar {
  height: 100%;
  background: var(--text-secondary);
  border-radius: 3px;
  opacity: 0.4;
}

.dash-cat-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  width: 55px;
  text-align: right;
  flex-shrink: 0;
}

.dash-mini-list {
  margin-top: var(--space-sm);
}

.dash-mini-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.dash-mini-item:last-child {
  border-bottom: none;
}

.dash-treemap svg {
  display: block;
  width: 100%;
}

@media (max-width: 900px) {
  .dash-row-1, .dash-row-2, .dash-row-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   Visualizations — sparklines, heat map, bars, bullets
   ============================================================ */

/* Sparklines */
.sparkline-cell {
  padding: 0 var(--space-sm);
  vertical-align: middle;
}

/* Heat map — continuous gradients now applied via inline styles in views.js */

/* Merchant proportional bars — now rendered as cell background gradients (see views.js) */

/* Diverging bar chart */
.diverging-chart {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.diverging-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  height: 28px;
}

.diverging-label {
  width: 70px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.diverging-bars {
  flex: 1;
  display: flex;
  align-items: center;
  height: 16px;
}

.diverging-expense {
  height: 100%;
  background: var(--negative);
  opacity: 0.3;
  margin-left: auto;
  border-radius: 2px;
}

.diverging-center {
  width: 2px;
  height: 20px;
  background: var(--border-strong);
  flex-shrink: 0;
}

.diverging-income {
  height: 100%;
  background: var(--positive);
  opacity: 0.3;
  border-radius: 2px;
}

.diverging-net {
  width: 80px;
  font-size: 11px;
  font-family: var(--font-mono);
  text-align: right;
  flex-shrink: 0;
}

/* Income view */
.income-content {
  padding: var(--space-md);
}

.income-sources {
  margin-bottom: var(--space-lg);
}

.income-source-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-sm);
}

.income-source-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.income-source-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.income-source-amount {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.income-source-period {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.income-source-bar-wrap {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin: var(--space-sm) 0 var(--space-xs);
}

.income-source-bar {
  height: 100%;
  background: var(--positive);
  border-radius: 2px;
  opacity: 0.6;
}

.income-source-pct {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.income-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.income-chart-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.income-chart-legend {
  display: flex;
  gap: var(--space-lg);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

.income-chart-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Bullet charts */
.bullet-chart {
  position: relative;
  height: 14px;
  min-width: 100px;
  background: var(--bg-secondary);
  border-radius: 2px;
}

.bullet-bg {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--bg-tertiary);
  border-radius: 2px;
}

.bullet-bar {
  position: absolute;
  top: 3px;
  left: 0;
  height: 8px;
  border-radius: 2px;
}

.bullet-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--text-primary);
  border-radius: 1px;
}

/* Baseline vs Actual — bar-based layout */
.baseline-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.baseline-summary .stat-card.over {
  border-color: var(--negative);
  border-width: 1px;
}

.baseline-summary .stat-card.under {
  border-color: var(--positive);
  border-width: 1px;
}

.baseline-summary .stat-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.baseline-list {
  border-top: 1px solid var(--border);
}

.baseline-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 100ms;
}

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

.baseline-row.expanded {
  background: var(--bg-secondary);
  border-bottom-color: transparent;
}

.baseline-cat {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 160px;
  flex-shrink: 0;
}

.baseline-cat-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.baseline-bars {
  flex: 1;
  min-width: 200px;
}

.baseline-bar-track {
  position: relative;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: visible;
}

.baseline-bar-actual {
  position: absolute;
  top: 2px;
  left: 0;
  height: 20px;
  border-radius: 3px;
  transition: width 300ms ease;
  min-width: 2px;
}

.baseline-ref-mark {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 28px;
  background: var(--text-muted);
  border-radius: 1px;
  z-index: 2;
}

.baseline-ref-label {
  position: absolute;
  top: -16px;
  right: -4px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  transform: translateX(100%);
}

.baseline-ref-mark:first-of-type .baseline-ref-label {
  transform: none;
  right: 4px;
}

.baseline-amounts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 110px;
  flex-shrink: 0;
}

.baseline-actual-amt {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.baseline-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 2px;
}

.baseline-delta.over {
  color: var(--negative);
  background: var(--negative-bg);
}

.baseline-delta.under {
  color: var(--positive);
  background: var(--positive-bg);
}

.baseline-delta.flat {
  color: var(--text-muted);
}

.baseline-expand {
  padding: var(--space-md) var(--space-lg) var(--space-md) calc(160px + var(--space-lg) + var(--space-md));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  animation: fadeIn 150ms ease;
}

.baseline-expand .data-table {
  background: var(--bg-surface);
}

@media (max-width: 900px) {
  .baseline-summary {
    grid-template-columns: 1fr;
  }
  .baseline-cat {
    width: 120px;
  }
  .baseline-expand {
    padding-left: var(--space-lg);
  }
  .baseline-top-row {
    flex-direction: column;
  }
}

/* Income Column + Month Strip (Baseline view) */
.baseline-top-row {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  align-items: stretch;
}

.baseline-column-wrap {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.baseline-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
}

.baseline-stats-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
}

.baseline-strip-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  flex: 1;
}

.baseline-stat-header {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: var(--space-sm);
}

.baseline-stat-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  font-size: 13px;
}

.baseline-stat-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 600;
}

.baseline-stat-row.positive span:last-child { color: var(--positive); }
.baseline-stat-row.negative span:last-child { color: var(--negative); }

.baseline-stat-divider {
  border-top: 1px solid var(--border);
  margin: var(--space-sm) 0;
}

.baseline-stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.baseline-stat-impact {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}

.baseline-stat-impact span:last-child {
  font-family: var(--font-mono);
  color: var(--negative);
}

/* duplicate removed — .baseline-strip-section defined above */

.month-strip {
  overflow-x: auto;
  padding: var(--space-sm) 0;
}

/* Shared visualization padding */
.viz-treemap,
.viz-bars,
.viz-area,
.viz-scatter {
  border-bottom: 1px solid var(--border);
  padding: var(--space-lg);
}

/* Treemap */
.viz-treemap rect { cursor: pointer; }
.viz-treemap rect:hover { opacity: 0.8; }

/* Scatter plot */
.viz-scatter circle:hover { r: 4; opacity: 1; }

/* D3 axis styling */
.viz-treemap .domain, .viz-bars .domain, .viz-area .domain, .viz-scatter .domain { stroke: var(--border-strong); }
.viz-bars .tick line, .viz-area .tick line { stroke: var(--border); }

/* Slope chart legend */
.slope-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 11px;
}

.slope-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.15s;
}

.slope-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.slope-legend-name {
  color: var(--text-secondary);
}

.slope-legend-val {
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ============================================================
   Responsive — Tablet (900px-1100px): Collapsed sidebar
   ============================================================ */

@media (max-width: 1100px) and (min-width: 901px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }

  .sidebar-header {
    justify-content: center;
    padding: var(--space-lg) var(--space-sm);
  }

  .sidebar-header .brand-name {
    display: none;
  }

  .nav-section-label {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-sm);
  }

  .nav-item span {
    display: none;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .sidebar-footer-btn span {
    display: none;
  }

  .sidebar-footer-btn {
    justify-content: center;
  }
}

/* ============================================================
   Responsive — Mobile (<900px): Single column
   ============================================================ */

@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    height: auto;
    min-height: 0;
    flex: 1;
  }

  .chat-panel {
    width: 100%;
  }

  .topbar {
    padding: var(--space-lg);
    flex-wrap: wrap;
  }

  .view-title {
    font-size: 22px;
  }

  .period-selector {
    flex-wrap: wrap;
  }

  .view-content {
    padding: 0 var(--space-lg) var(--space-lg);
  }

  .view-toolbar {
    padding: var(--space-md) 0;
  }

  .upload-screen-inner {
    padding: var(--space-lg);
  }

  .chat-input-bar {
    padding: var(--space-sm) var(--space-md);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dash-wide {
    grid-column: span 1;
  }

  /* Mobile bottom nav bar */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    height: 56px;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    padding: var(--space-xs);
  }

  .mobile-nav-item.active {
    color: var(--green);
  }

  .mobile-nav-item .mobile-nav-icon {
    font-size: 18px;
  }
}

/* ============================================================
   Utility classes
   ============================================================ */

.mono {
  font-family: var(--font-mono);
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-negative {
  color: var(--negative);
}

.text-positive {
  color: var(--positive);
}

.text-warning {
  color: var(--warning);
}

.fw-600 {
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================
   Sidebar Refresh Section
   ============================================================ */

.sidebar-refresh {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.refresh-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-sm);
}

.refresh-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.refresh-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-refresh-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}

.sidebar-refresh-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-refresh-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.sidebar-refresh-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================================
   Legal / Privacy Modal
   ============================================================ */

.modal-wide {
  width: 560px;
}

.modal-body-scroll {
  max-height: 70vh;
  overflow-y: auto;
  padding: var(--space-xl);
}

.legal-section {
  margin-bottom: var(--space-xl);
}

.legal-section:last-of-type {
  margin-bottom: var(--space-md);
}

.legal-section h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.legal-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.legal-list li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  padding-left: var(--space-md);
  position: relative;
}

.legal-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

.legal-list li strong {
  color: var(--text-primary);
  font-weight: 600;
}

.legal-footer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.upload-legal-link {
  margin-top: var(--space-xs);
}

.upload-legal-link a {
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 150ms;
}

.upload-legal-link a:hover {
  color: var(--text-secondary);
}

/* Auto-refresh notification */
.refresh-notification {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--green);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  z-index: 500;
  animation: slideDown 300ms ease;
}

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

.refresh-notification .green {
  color: var(--green);
  font-weight: 600;
}

/* ============================================================
   Category Detail Drill-Down
   ============================================================ */

.category-detail-header {
  padding: var(--space-xl);
}

.back-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-bottom: var(--space-md);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back-link:hover {
  color: var(--text-primary);
}

.back-link:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.category-detail-title {
  font-family: var(--font-display);
  font-size: 28px;
  margin-bottom: var(--space-lg);
  letter-spacing: -0.02em;
}

.category-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.category-chart-section {
  padding: 0 var(--space-xl);
  margin-bottom: var(--space-xl);
}

.chart-toggles {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-md);
}

.chart-toggle {
  font-size: 12px;
  font-family: var(--font-body);
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 100ms;
}

.chart-toggle.active {
  background: var(--text-primary);
  color: var(--bg-surface);
  border-color: var(--text-primary);
}

.chart-toggle:hover:not(.active) {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

.trend-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
}

.trend-badge.rising {
  color: var(--negative);
  background: var(--negative-bg);
}

.trend-badge.falling {
  color: var(--positive);
  background: var(--positive-bg);
}

.category-chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow: hidden;
  position: relative;
}

.category-section {
  padding: 0 var(--space-xl);
  margin-bottom: var(--space-xl);
}

.category-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.subcat-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

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

.subcat-name {
  width: 140px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.subcat-bar-wrap {
  flex: 1;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.subcat-bar {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 300ms ease;
}

.subcat-amount {
  width: 90px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  flex-shrink: 0;
}

.subcat-pct {
  width: 50px;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.top-merchant-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

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

.top-merchant-name {
  width: 160px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.top-merchant-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.top-merchant-bar {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 300ms ease;
}

.top-merchant-count {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 60px;
  text-align: right;
}

.top-merchant-amount {
  width: 100px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  flex-shrink: 0;
}

.cat-clickable {
  cursor: pointer;
  transition: color 100ms;
}

.cat-clickable:hover {
  color: var(--text-primary);
}

.cat-clickable::after {
  content: ' \2192';
  opacity: 0;
  transition: opacity 100ms;
  font-size: 11px;
  color: var(--text-muted);
}

.cat-clickable:hover::after {
  opacity: 1;
}

.cat-icon-col {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  text-align: center;
  vertical-align: middle;
  padding: 0 8px 0 4px;
}

.cat-icon-col .cat-symbol {
  margin: 0 auto;
}

.sticky-col-name {
  position: sticky;
  left: 36px;
  z-index: 2;
  background: inherit;
  min-width: 100px;
  vertical-align: middle;
}

thead th.sticky-col-name {
  z-index: 6;
  background: var(--bg-surface);
}

.cat-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--bg-secondary);
  border-radius: 6px;
  flex-shrink: 0;
}

.cat-icon {
  width: 14px;
  height: 14px;
  stroke: var(--text-secondary);
  stroke-width: 1.75;
  flex-shrink: 0;
}

/* In category detail header, larger icon */
.category-detail-title .cat-symbol {
  width: 32px;
  height: 32px;
  margin-right: var(--space-md);
}

.category-detail-title .cat-icon {
  width: 18px;
  height: 18px;
}

@media (max-width: 900px) {
  .category-detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .subcat-name {
    width: 100px;
  }

  .top-merchant-name {
    width: 120px;
  }
}

/* ============================================================
   Merchants View — Cards + Grouped List
   ============================================================ */

/* Merchant cards */
.merch-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.merch-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.merch-card-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merch-card-amount {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: var(--space-sm);
}

.merch-spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 32px;
  margin-bottom: var(--space-sm);
}

.merch-spark-bar {
  flex: 1;
  background: var(--text-secondary);
  opacity: 0.25;
  border-radius: 1px 1px 0 0;
  min-height: 2px;
}

.merch-card-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Merchant filter pills */
.merch-pills {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.merch-pill {
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background 100ms, border-color 100ms;
}

.merch-pill:hover {
  background: var(--bg-tertiary);
}

.merch-pill.active {
  background: var(--text-primary);
  color: var(--bg-surface);
  border-color: var(--text-primary);
}

/* Merchant groups */
.merch-group {
  margin-bottom: var(--space-xl);
}

.merch-group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-xs);
  display: flex;
  justify-content: space-between;
}

.merch-row {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.merch-name {
  flex: 1;
  min-width: 100px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merch-spark-inline {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 18px;
  width: 80px;
  flex-shrink: 0;
}

.merch-spark-inline > div {
  flex: 1;
  background: var(--text-secondary);
  opacity: 0.2;
  border-radius: 1px 1px 0 0;
  min-height: 1px;
}

.merch-total {
  width: 70px;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  flex-shrink: 0;
}

.merch-count {
  width: 55px;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.merch-avg {
  width: 75px;
  text-align: right;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

.merch-freq {
  width: 70px;
  text-align: center;
  flex-shrink: 0;
}

.freq-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.freq-badge.weekly { background: rgba(37,99,235,0.08); border-color: rgba(37,99,235,0.2); color: #2563EB; }
.freq-badge.biweekly { background: rgba(22,128,60,0.08); border-color: rgba(22,128,60,0.2); color: #16803C; }
.freq-badge.monthly { background: rgba(217,119,6,0.08); border-color: rgba(217,119,6,0.2); color: #D97706; }
.freq-badge.quarterly { background: rgba(100,100,95,0.08); color: var(--text-muted); }
.freq-badge.annual { background: rgba(100,100,95,0.05); color: var(--text-muted); }
.freq-badge.occasional { color: var(--text-muted); border-color: transparent; }
.freq-badge.onetime { color: var(--text-muted); font-style: italic; border-color: transparent; }

@media (max-width: 900px) {
  .merch-cards { grid-template-columns: repeat(2, 1fr); }
  .merch-avg, .merch-spark-inline { display: none; }
  .merch-name { width: 120px; }
}

/* ============================================================
   Financial Review
   ============================================================ */

/* Sidebar review button */
.sidebar-review {
  padding: var(--space-sm) var(--space-md);
  margin-top: auto;
}

.sidebar-review-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: border-color 150ms, background-color 150ms;
}

.sidebar-review-btn:hover {
  border-color: var(--green);
  background: var(--green-light);
}

.sidebar-review-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

.sidebar-review-btn svg {
  width: 18px;
  height: 18px;
  color: var(--green);
  flex-shrink: 0;
}

.sidebar-review-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sidebar-review-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-review-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Review modal */
.review-modal {
  max-width: 440px;
}

.review-modal-desc {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: var(--space-xl);
}

.review-modal-options {
  margin-bottom: var(--space-lg);
}

.review-option label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.review-context-details {
  margin: var(--space-lg) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.review-context-details summary {
  padding: var(--space-md) var(--space-lg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
}

.review-context-details summary:hover {
  color: var(--text-primary);
}

.review-context-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.review-context-fields {
  padding: 0 var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.review-field label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.review-field input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--bg-surface);
}

.review-field input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(45, 139, 85, 0.1);
}

.review-cost-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.review-generate-btn {
  width: 100%;
  padding: var(--space-md);
  font-size: 15px;
  height: auto;
}

/* Review progress */
.review-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.review-progress-content {
  text-align: center;
}

.review-progress-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--space-lg);
}

.review-progress-status {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: var(--space-sm);
}

.thinking-indicator {
  display: inline-block;
  color: var(--green);
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

.thinking-preview {
  display: block;
  margin-top: var(--space-sm);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Review report header */
.review-header {
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.review-title {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text-primary);
  margin: 0 0 var(--space-xs);
}

.review-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
  font-family: var(--font-mono);
}

.review-actions {
  display: flex;
  gap: var(--space-sm);
}

.review-actions .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 32px;
  padding: 0 var(--space-md);
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 150ms, color 150ms;
}

.review-actions .btn-sm:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.review-actions .btn-sm svg {
  width: 14px;
  height: 14px;
}

/* Review report body */
.review-body {
  padding: var(--space-xl);
  line-height: 1.7;
  font-size: 14px;
  color: var(--text-primary);
  max-width: 800px;
}

.review-body h2 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-primary);
  margin: var(--space-3xl) 0 var(--space-md) 0;
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.review-body h2:first-child {
  margin-top: 0;
}

.review-body h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: var(--space-xl) 0 var(--space-sm) 0;
}

.review-body p {
  margin: 0 0 var(--space-md) 0;
}

.review-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0 var(--space-lg);
  font-size: 13px;
}

.review-body table thead th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-strong);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.review-body table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.review-body table td.num,
.review-body table th.num {
  text-align: right;
  font-family: var(--font-mono);
}

.review-body ul,
.review-body ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-xl);
}

.review-body li {
  margin-bottom: var(--space-sm);
}

.review-body strong {
  font-weight: 600;
}

.review-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

.review-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: var(--space-lg);
  margin: var(--space-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Review streaming cursor */
.review-body.streaming::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--green);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Print styles for review */
@media print {
  .sidebar,
  #chatPanel,
  .chat-overlay,
  .review-actions,
  .topbar,
  .toast-container,
  .modal-overlay {
    display: none !important;
  }
  .app-layout {
    display: block !important;
  }
  .main-content {
    height: auto !important;
    overflow: visible !important;
  }
  .view-content {
    overflow: visible !important;
  }
  .review-body {
    padding: 0;
    max-width: none;
  }
  .review-header {
    border-bottom: 2px solid #000;
    padding: 0 0 var(--space-md);
  }
}

/* =================== Bedrock View =================== */
.bedrock-content {
  padding: var(--space-lg);
}

.bedrock-filter-note {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* Summary headline */
.bedrock-summary {
  margin-bottom: var(--space-lg);
}

.bedrock-headline {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
}

.bedrock-headline strong {
  font-weight: 700;
}

.bedrock-subhead {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.bedrock-section {
  margin-bottom: var(--space-xl);
}

.bedrock-landscape {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-top: var(--space-sm);
  overflow: hidden;
}

.bedrock-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.bedrock-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bedrock-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* Financial Anatomy */
.anatomy-bar-wrap {
  margin: var(--space-md) 0;
}

.anatomy-bar {
  display: flex;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-secondary);
}

.anatomy-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.anatomy-seg-label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: white;
  font-weight: 600;
}

.bedrock-seg { background: #374151; }
.subsoil-seg { background: #6B7280; }
.topsoil-seg { background: #9CA3AF; }
.surface-seg { background: #D1D5DB; }
.surface-seg .anatomy-seg-label { color: var(--text-primary); }
.breathing-seg {
  background: repeating-linear-gradient(
    45deg, transparent, transparent 3px, rgba(22,128,60,0.08) 3px, rgba(22,128,60,0.08) 6px
  );
  border-left: 2px solid rgba(22,128,60,0.3);
}
.breathing-seg .anatomy-seg-label { color: var(--positive); font-size: 11px; }

.anatomy-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.anatomy-stat {
  padding: var(--space-sm);
}

.anatomy-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.anatomy-stat-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.anatomy-mo {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.anatomy-stat.breathing .anatomy-stat-value {
  color: var(--positive);
}

.anatomy-stat.over .anatomy-stat-value {
  color: var(--negative);
}

.anatomy-verdict {
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  margin-top: var(--space-md);
}

.anatomy-verdict.negative {
  background: var(--negative-bg);
  color: var(--negative);
}

.anatomy-verdict.positive {
  background: var(--positive-bg);
  color: var(--positive);
}

/* Impact Timeline */
.impact-list {
  margin-top: var(--space-sm);
}

.impact-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

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

.impact-date {
  width: 80px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.impact-payee {
  width: 180px;
  flex-shrink: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.impact-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.impact-bar {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.impact-amount {
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
}

.impact-summary {
  display: flex;
  gap: var(--space-xl);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.impact-summary .negative { color: var(--negative); font-weight: 600; }
.impact-summary .positive { color: var(--positive); font-weight: 600; }

@media (max-width: 900px) {
  .anatomy-stats { grid-template-columns: repeat(2, 1fr); }
  .impact-payee { width: 120px; }
}

/* Bedrock tooltip */
.bedrock-tooltip {
  position: fixed;
  z-index: 200;
  display: none;
  min-width: 220px;
  max-width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  pointer-events: none;
  font-size: 12px;
}

.tip-header {
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tip-header.red {
  background: var(--negative-bg);
  color: var(--negative);
}

.tip-header.amber {
  background: #FEF3C7;
  color: #92400E;
}

.tip-body {
  padding: var(--space-sm) var(--space-md);
}

.tip-impact-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 12px;
}

.tip-amount {
  font-family: var(--font-mono);
  font-weight: 600;
}

.tip-divider {
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.tip-stat {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.tip-stat-active {
  font-weight: 600;
  color: var(--text-primary);
}

.tip-bar-wrap {
  position: relative;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  margin: 6px 0;
  overflow: visible;
}

.tip-bar {
  height: 100%;
  border-radius: 4px;
}

.tip-margin-mark {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 12px;
  background: var(--text-muted);
  border-radius: 1px;
}

.tip-savings-hit, .tip-savings-ok {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 0 0;
}

.tip-more {
  font-size: 10px;
  color: var(--text-muted);
  padding: 2px 0;
}

/* Impact row highlight (cross-reference) */
.impact-row {
  transition: background 100ms ease;
}

.impact-row-highlight {
  background: var(--bg-tertiary) !important;
}

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

/* Impact circle hover */
.impact-circle {
  transition: r 100ms ease, opacity 100ms ease;
}

.impact-circle-highlight {
  filter: brightness(1.2);
}

/* Month detail panel */
.month-detail {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-xl);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-lg);
  animation: fadeIn 150ms ease;
}

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

.month-detail-header {
  font-family: var(--font-display);
  font-size: 16px;
  margin-bottom: var(--space-md);
}

.month-detail-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.month-detail-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}

.month-detail-item span:last-child {
  font-family: var(--font-mono);
  font-weight: 500;
}

.month-detail-item.breathing {
  font-weight: 600;
  color: var(--positive);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
}

.month-detail-item.impact span:first-child {
  padding-left: 16px;
}

.month-detail-item.total {
  font-weight: 600;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
}

.month-detail-divider {
  border-top: 1px dashed var(--border);
  margin: 6px 0;
}

.month-detail-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.month-detail-close:hover {
  color: var(--text-primary);
}

/* =================== Category Classification Modal =================== */

.classify-modal {
  max-width: 600px;
  max-height: 85vh;
}

.classify-modal .modal-body {
  overflow-y: auto;
  max-height: calc(85vh - 60px);
}

.classify-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.classify-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: var(--space-lg);
}

.classify-tier-group {
  margin-bottom: var(--space-lg);
}

.classify-tier-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-xs);
}

.classify-tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.classify-tier-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
}

.classify-tier-total {
  margin-left: auto;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.classify-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
}

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

.classify-cat-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classify-cat-amount {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  width: 70px;
  text-align: right;
  flex-shrink: 0;
}

.classify-dots {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.classify-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 100ms;
  background: transparent;
  font-family: var(--font-mono);
}

.classify-dot:hover {
  border-color: var(--text-secondary);
  transform: scale(1.15);
}

.classify-dot.active {
  border-color: transparent;
  color: #fff;
}

.classify-legend {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.classify-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.classify-legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 600;
  color: #fff;
  font-family: var(--font-mono);
}

.classify-more-toggle {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs) 0;
}

.classify-more-toggle:hover {
  color: var(--interactive);
}

.classify-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.settings-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.settings-toggle-row {
  margin-bottom: var(--space-md);
}

.settings-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 13px;
  cursor: pointer;
}

.settings-toggle-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--interactive);
  cursor: pointer;
}

.settings-toggle-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: var(--space-xs) 0 0 22px;
  line-height: 1.4;
}

.classify-settings-link {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
}

.classify-settings-link:hover {
  color: var(--text-primary);
}

/* ============================================================
   AI Insight Anchors
   ============================================================ */

.insight-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--interactive);
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
  cursor: pointer;
  transition: all 150ms;
  vertical-align: middle;
  flex-shrink: 0;
  margin-left: 6px;
  white-space: nowrap;
}

.insight-anchor:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--interactive);
  color: var(--interactive);
}

.insight-loading {
  animation: insightPulse 0.8s ease-in-out infinite;
}

@keyframes insightPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; color: var(--interactive); }
}

.insight-panel {
  margin: var(--space-sm) 0;
  padding: var(--space-md) var(--space-lg);
  padding-right: 28px;
  background: rgba(79, 125, 243, 0.04);
  border-left: 2px solid var(--interactive);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 480px;
  position: relative;
  animation: insightIn 200ms ease;
}

.insight-text {
  display: block;
}

.insight-close {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.insight-close:hover {
  color: var(--text-primary);
}

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

/* =================== NET WORTH REDESIGN =================== */

.nw-content {
  padding: var(--space-md);
}

.nw-hero {
  margin-bottom: var(--space-lg);
}

.nw-chart-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 8px);
  padding: var(--space-md);
  overflow: hidden;
}

.nw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.nw-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nw-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.nw-legend-line {
  display: inline-block;
  width: 16px;
  border-top: 2.5px solid var(--text-primary);
}

.nw-tooltip {
  position: fixed;
  z-index: 200;
  display: none;
  min-width: 220px;
  max-width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  pointer-events: none;
  font-size: 12px;
}

.nw-tip-header {
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.nw-tip-body {
  padding: var(--space-sm) var(--space-md);
}

.nw-tip-section {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
  margin-bottom: 2px;
}

.nw-tip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 1px 0;
  font-size: 12px;
}

.nw-tip-val {
  font-family: var(--font-mono);
  font-weight: 500;
}

.nw-tip-total {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  padding-top: var(--space-xs);
  margin-top: var(--space-xs);
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.nw-tip-total span:last-child {
  font-family: var(--font-mono);
}

.nw-tip-delta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  padding: 1px 0;
}

/* Account breakdown */
.nw-breakdown {
  margin-top: var(--space-xl);
}

.nw-group {
  margin-bottom: var(--space-md);
}

.nw-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.nw-group-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.nw-group-name {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}

.nw-group-pct {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.nw-group-val {
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 600;
}

.nw-group-bar-wrap {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: var(--space-xs);
}

.nw-group-bar {
  height: 100%;
  border-radius: 3px;
  opacity: 0.6;
}

.nw-group-accounts {
  padding-left: 18px;
}

.nw-acct-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 1px 0;
  color: var(--text-secondary);
}

.nw-acct-row span:last-child {
  font-family: var(--font-mono);
}

.nw-totals {
  border-top: 1px solid var(--border);
  padding-top: var(--space-md);
  margin-top: var(--space-md);
}

.nw-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: var(--space-xs) 0;
}

.nw-total-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 600;
}

.nw-net {
  font-size: 15px;
  font-weight: 700;
  border-top: 1px solid var(--border);
  padding-top: var(--space-sm);
  margin-top: var(--space-xs);
}

@media (max-width: 900px) {
  .nw-group-accounts { padding-left: var(--space-sm); }
}

/* =================== YEAR/YEAR SLOPE CHART & CHANGE SUMMARY =================== */

.yoy-chart-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 8px);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.yoy-changes {
  margin-bottom: var(--space-xl);
}

.yoy-change-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  margin-top: var(--space-md);
}

.yoy-col-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border);
}

.yoy-col-header.negative { color: var(--negative); border-color: var(--negative); }
.yoy-col-header.positive { color: var(--positive); border-color: var(--positive); }

.yoy-change-item {
  margin-bottom: var(--space-md);
}

.yoy-change-name {
  font-size: 13px;
  font-weight: 600;
}

.yoy-change-detail {
  font-size: 12px;
  margin-top: 2px;
}

.yoy-change-pct {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: var(--space-xs);
}

.yoy-change-bar-wrap {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin: var(--space-xs) 0;
}

.yoy-change-bar {
  height: 100%;
  border-radius: 2px;
}

.yoy-change-bar.negative { background: rgba(220,38,38,0.4); }
.yoy-change-bar.positive { background: rgba(22,128,60,0.4); }

.yoy-change-range {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.yoy-stable {
  margin-top: var(--space-md);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.yoy-stable-item {
  font-size: 12px;
  padding: 3px 8px;
  background: var(--bg-secondary);
  border-radius: 12px;
  color: var(--text-secondary);
}

@media (max-width: 900px) {
  .yoy-change-cols { grid-template-columns: 1fr; }
}

/* =================== RECURRING VIEW REDESIGN =================== */

.recurring-content {
  padding: var(--space-md);
}

.recurring-summary {
  margin-bottom: var(--space-lg);
}

.recurring-hero {
  margin-bottom: var(--space-xs);
}

/* Alerts */
.recurring-alerts {
  margin-bottom: var(--space-lg);
}

.recurring-alert-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.recurring-alert {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.recurring-alert.up {
  border-left: 3px solid var(--negative);
}

.recurring-alert.down {
  border-left: 3px solid var(--positive);
}

.recurring-alert.new {
  border-left: 3px solid var(--interactive);
}

.recurring-alert-icon {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--negative);
  flex-shrink: 0;
}

.recurring-alert.down .recurring-alert-icon { color: var(--positive); }
.recurring-alert.new .recurring-alert-icon { color: var(--interactive); font-size: 9px; }

.recurring-alert-name { font-size: 13px; font-weight: 600; }
.recurring-alert-detail { font-size: 11px; color: var(--text-muted); }
.recurring-alert-amount { margin-left: auto; font-family: var(--font-mono); font-size: 13px; font-weight: 600; flex-shrink: 0; }

/* Composition bar */
.recurring-composition {
  margin-bottom: var(--space-lg);
}

.recurring-comp-bar {
  display: flex;
  height: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: var(--space-sm);
}

.recurring-comp-seg {
  min-width: 2px;
  transition: opacity 150ms;
}

.recurring-comp-seg:hover { opacity: 0.8; }

.recurring-comp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.recurring-comp-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Grouped list */
.recurring-group {
  margin-bottom: var(--space-lg);
}

.recurring-group-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-xs);
  color: var(--text-secondary);
}

.recurring-group-total {
  font-family: var(--font-mono);
}

.recurring-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.recurring-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

.recurring-item-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recurring-item-freq {
  font-size: 11px;
  color: var(--text-muted);
  width: 70px;
  text-align: center;
  flex-shrink: 0;
}

.recurring-item-trend {
  width: 50px;
  text-align: center;
  font-size: 11px;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.recurring-new-badge {
  font-size: 9px;
  font-weight: 600;
  color: var(--interactive);
  text-transform: uppercase;
}

.recurring-item-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  width: 80px;
  text-align: right;
  flex-shrink: 0;
}

/* Excluded section */
.recurring-excluded {
  margin-top: var(--space-xl);
}

.recurring-excluded-list {
  margin-top: var(--space-sm);
}

.recurring-excluded-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
}

.recurring-excluded-item span:first-child { flex: 1; }
.recurring-excluded-reason { font-size: 10px; background: var(--bg-secondary); padding: 1px 6px; border-radius: 3px; }
.recurring-excluded-amount { font-family: var(--font-mono); width: 80px; text-align: right; flex-shrink: 0; }
