/* ============================================
   Receipt Tracker — Design System & Stylesheet
   ============================================ */

/* Fonts loaded via <link> in HTML — no @import blocking */

/* --- Design Tokens: Light Mode --- */
:root {
  /* Colors */
  --clr-bg: #F8F9FB;
  --clr-surface: #FFFFFF;
  --clr-border: #E8EBF0;
  --clr-border-subtle: #F0F2F5;
  --clr-text-primary: #0F172A;
  --clr-text-secondary: #475569;
  --clr-text-muted: #94A3B8;
  --clr-accent: #6366F1;
  --clr-accent-hover: #4F46E5;
  --clr-accent-subtle: #EEF2FF;
  --clr-success: #10B981;
  --clr-success-bg: #ECFDF5;
  --clr-danger: #EF4444;
  --clr-danger-bg: #FEF2F2;
  --clr-header: #FFFFFF;
  --clr-header-border: #E8EBF0;
  --clr-overlay: rgba(0, 0, 0, 0.5);

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

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

  /* Layout */
  --chat-width: 400px;
  --header-height: 48px;
  --transition-speed: 0.3s;
}

/* --- Dark Mode Tokens --- */
html.dark {
  --clr-bg: #09090B;
  --clr-surface: #111113;
  --clr-border: #27272A;
  --clr-border-subtle: #1C1C1F;
  --clr-text-primary: #FAFAFA;
  --clr-text-secondary: #A1A1AA;
  --clr-text-muted: #52525B;
  --clr-accent: #818CF8;
  --clr-accent-hover: #6366F1;
  --clr-accent-subtle: rgba(99, 102, 241, 0.18);
  --clr-success: #34D399;
  --clr-success-bg: rgba(16, 185, 129, 0.14);
  --clr-danger: #F87171;
  --clr-danger-bg: rgba(239, 68, 68, 0.14);
  --clr-header: #09090B;
  --clr-header-border: #27272A;
  --clr-overlay: rgba(0, 0, 0, 0.75);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(99, 102, 241, 0.015) 2px,
      rgba(99, 102, 241, 0.015) 4px
    ),
    var(--clr-bg);
  color: var(--clr-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease;
}

html.dark body {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(99, 102, 241, 0.03) 2px,
      rgba(99, 102, 241, 0.03) 4px
    ),
    var(--clr-bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

/* ============================================
   1. Header / Top Bar
   ============================================ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--clr-header) 0%, var(--clr-surface) 100%);
  border-bottom: 1px solid var(--clr-header-border);
  padding: 0 var(--space-xl);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

html.dark .top-bar {
  background: linear-gradient(180deg, #0c0c0f 0%, #09090B 100%);
  border-bottom-color: rgba(99, 102, 241, 0.15);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.top-bar-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--clr-text-primary);
}

.top-bar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 var(--space-xl);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Dark mode toggle */
.btn-dark-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  color: var(--clr-text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.btn-dark-toggle:hover {
  background: var(--clr-accent-subtle);
  border-color: var(--clr-accent);
  color: var(--clr-accent);
}

/* Chat toggle button */
.btn-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--clr-accent);
  color: #FFFFFF;
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

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

.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  border-color: var(--clr-danger);
  color: var(--clr-danger);
  background: var(--clr-danger-bg);
}

/* ============================================
   2. Search Bar (inline in header center)
   ============================================ */
.search-bar {
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  padding: var(--space-md) var(--space-xl);
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

.search-input-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
}

.search-input-wrap::before {
  content: "\2315";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  pointer-events: none;
}

.search-input-wrap .search-hint {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--clr-text-muted);
  background: var(--clr-border-subtle);
  border: 1px solid var(--clr-border);
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
  font-family: inherit;
  line-height: 1.4;
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  padding-left: 34px;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--clr-text-primary);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color var(--transition-speed) ease;
}

.search-input::placeholder {
  color: var(--clr-text-muted);
}

.search-input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-subtle);
}

/* ============================================
   3. Main Layout
   ============================================ */
.main-layout {
  display: flex;
  position: relative;
  min-height: calc(100vh - var(--header-height));
}

.content {
  flex: 1;
  padding: var(--space-xl);
  overflow: auto;
  transition: margin-right var(--transition-speed) ease;
}

.main-layout.chat-visible .content {
  margin-right: var(--chat-width);
}

/* ============================================
   4. Console Stats Strip
   ============================================ */
.console-strip {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 4px var(--space-sm);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  white-space: nowrap;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

html.dark .console-strip {
  background: rgba(17, 17, 19, 0.8);
  border-color: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.04);
}

.console-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 14px;
  flex-shrink: 0;
  border-left: 2px solid transparent;
  position: relative;
}

.console-stat:nth-child(1) { border-left-color: #6366f1; }
.console-stat:nth-child(3) { border-left-color: #818cf8; }
.console-stat:nth-child(5) { border-left-color: #f59e0b; }
.console-stat:nth-child(7) { border-left-color: #10b981; }
.console-stat:nth-child(9) { border-left-color: #06b6d4; }
.console-stat:nth-child(11) { border-left-color: #ec4899; }

.console-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.console-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--clr-text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

html.dark .console-value {
  color: #e2e8f0;
}

/* Pulsing indicator dot */
.console-stat::before {
  content: '';
  position: absolute;
  top: 8px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--clr-success);
  animation: pulse-dot 2.5s infinite ease-in-out;
  opacity: 0.7;
}

/* Amber dot for the "Change" stat */
.console-stat:nth-child(5)::before {
  background: #f59e0b;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

.console-divider {
  width: 1px;
  height: 28px;
  background: var(--clr-border);
  flex-shrink: 0;
  margin: 0 2px;
}

html.dark .console-divider {
  background: rgba(99, 102, 241, 0.1);
}

/* Hide pulse dot on vendor stat (too busy) */
.console-stat.top-vendor::before {
  display: none;
}

/* Vendor logo */
.vendor-logo {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.vendor-emoji {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  line-height: 20px;
}

/* Month-over-month badge */
.badge-mom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.badge-mom.down {
  background: var(--clr-success-bg);
  color: var(--clr-success);
}

.badge-mom.up {
  background: var(--clr-danger-bg);
  color: var(--clr-danger);
}

/* (Chart removed — stats are in the console strip) */

/* ============================================
   5b. Table Toolbar
   ============================================ */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: 0;
  flex-wrap: wrap;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: var(--space-sm) var(--space-lg);
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

html.dark .table-toolbar {
  background: rgba(17, 17, 19, 0.6);
  border-color: rgba(99, 102, 241, 0.1);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.date-presets {
  display: flex;
  gap: 4px;
}

@media (max-width: 768px) {
  .action-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }
  .action-bar .category-chips {
    justify-content: center;
  }
  .action-buttons {
    justify-content: center;
  }
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }
  .toolbar-left, .toolbar-right {
    justify-content: center;
  }
  .toolbar-search {
    width: 100%;
    flex: 1;
  }
  .date-presets {
    flex-wrap: wrap;
    justify-content: center;
  }
  .date-filter {
    display: none;
  }
}

.toolbar-results-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--clr-accent);
  background: var(--clr-accent-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.toolbar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.toolbar-search-wrap::before {
  content: "\2315";
  position: absolute;
  left: 10px;
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  pointer-events: none;
  z-index: 1;
}

.toolbar-search-wrap .search-shortcut-hint {
  position: absolute;
  right: 10px;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: 3px;
  padding: 0px 5px;
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.5;
  opacity: 0.7;
}

.toolbar-search {
  width: 200px;
  padding: 5px var(--space-md);
  padding-left: 28px;
  padding-right: 32px;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--clr-text-primary);
  outline: none;
  transition: width 0.25s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color var(--transition-speed) ease;
}

.toolbar-search::placeholder { color: var(--clr-text-muted); }
.toolbar-search:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-subtle);
  width: 260px;
}

html.dark .toolbar-search:focus {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 0 12px rgba(99, 102, 241, 0.1);
}

.toolbar-search:focus + .search-shortcut-hint {
  display: none;
}

.date-filter {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'JetBrains Mono', monospace;
}

.date-filter-arrow {
  color: var(--clr-text-muted);
  font-size: 0.7rem;
  opacity: 0.5;
}

.date-input {
  padding: 5px var(--space-sm);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--clr-text-primary);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color var(--transition-speed) ease;
  -webkit-appearance: none;
  appearance: none;
}

.date-input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-subtle);
}

.date-input:hover {
  border-color: var(--clr-accent);
}

/* Modern calendar icon */
.date-input::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
  filter: none;
  transition: opacity 0.15s ease;
}

.date-input:hover::-webkit-calendar-picker-indicator,
.date-input:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
}

html.dark .date-input {
  color-scheme: dark;
}

html.dark .date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.5;
}

html.dark .date-input:hover::-webkit-calendar-picker-indicator,
html.dark .date-input:focus::-webkit-calendar-picker-indicator {
  opacity: 0.8;
}

.btn-clear-dates {
  background: none;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-clear-dates:hover { color: var(--clr-danger); border-color: var(--clr-danger); }

/* ============================================
   5c. Pagination
   ============================================ */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
}

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

.page-btn {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--clr-text-secondary);
  cursor: pointer;
  min-width: 28px;
  text-align: center;
  transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) { border-color: var(--clr-accent); color: var(--clr-accent); }
.page-btn.active { background: var(--clr-accent); color: #fff; border-color: var(--clr-accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   6. Receipt Table
   ============================================ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--clr-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--clr-surface);
  min-height: 500px;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

html.dark .table-wrap {
  border-color: rgba(99, 102, 241, 0.1);
  background: rgba(17, 17, 19, 0.6);
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.receipt-table th,
.receipt-table td {
  padding: 7px var(--space-lg);
  text-align: left;
  border-bottom: 1px solid var(--clr-border-subtle);
}

.receipt-table thead th {
  background: var(--clr-surface);
  font-weight: 600;
  color: var(--clr-text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--clr-border);
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease;
}

html.dark .receipt-table thead th {
  background: rgba(17, 17, 19, 0.9);
  border-bottom-color: rgba(99, 102, 241, 0.1);
}

.receipt-table tbody tr {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  border-left: 2px solid transparent;
}

.receipt-table tbody tr:hover {
  background: var(--clr-accent-subtle);
  border-left: 2px solid var(--clr-accent);
}

html.dark .receipt-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.08);
  box-shadow: inset 0 0 30px rgba(99, 102, 241, 0.03);
}

.receipt-table tbody tr:last-child td {
  border-bottom: none;
}

html.dark .receipt-table tbody td {
  border-bottom-color: rgba(39, 39, 42, 0.5);
}

/* Right-align currency columns */
.receipt-table td.cell-total,
.receipt-table td.cell-currency {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 0.78rem;
}

.receipt-table th.col-currency {
  text-align: right;
}

/* Vendor name: medium weight */
.cell-vendor {
  font-weight: 500;
  color: var(--clr-text-primary);
}

/* Short ID */
.cell-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--clr-text-muted);
  letter-spacing: 0.05em;
}

/* Total amount: large and bold */
.cell-total {
  font-weight: 700;
  font-size: 1rem;
  color: var(--clr-text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Subtotal/tax/tip: smaller, muted */
.cell-sub {
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Currency cells (subtotal, tax, tip) */
.cell-currency {
  font-weight: 400;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--clr-text-secondary);
}

/* Payment method pill badge */
.badge-payment {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  background: var(--clr-accent-subtle);
  color: var(--clr-accent);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Category badges */
.badge-category {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cat-meals { background: #EDE9FE; color: #5B21B6; }
.cat-fuel { background: #FEF3C7; color: #92400E; }
.cat-grocery { background: #D1FAE5; color: #065F46; }
.cat-lodging { background: #DBEAFE; color: #1E40AF; }
.cat-transportation { background: #FEE2E2; color: #991B1B; }
.cat-misc { background: var(--clr-bg); color: var(--clr-text-muted); border: 1px solid var(--clr-border); }

html.dark .cat-meals { background: rgba(139, 92, 246, 0.15); color: #C4B5FD; }
html.dark .cat-fuel { background: rgba(251, 191, 36, 0.15); color: #FCD34D; }
html.dark .cat-grocery { background: rgba(16, 185, 129, 0.15); color: #6EE7B7; }
html.dark .cat-lodging { background: rgba(59, 130, 246, 0.15); color: #93C5FD; }
html.dark .cat-transportation { background: rgba(239, 68, 68, 0.15); color: #FCA5A5; }
html.dark .cat-misc { background: var(--clr-border-subtle); color: var(--clr-text-muted); border-color: var(--clr-border); }

/* Sortable columns */
.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  color: var(--clr-text-primary);
}

.sort-arrow {
  font-size: 0.6rem;
  margin-left: var(--space-xs);
  vertical-align: middle;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}

.sortable:hover .sort-arrow {
  opacity: 0.7;
}

.sortable .sort-arrow:not(:empty) {
  opacity: 1;
}

/* Empty state */
.empty-state {
  text-align: center;
  color: var(--clr-text-muted);
  padding: 48px var(--space-lg) !important;
  font-style: italic;
}

/* ============================================
   7. View Receipt Link
   ============================================ */
.view-receipt-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--clr-text-muted);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-receipt-link::before {
  content: "\2197";
  font-size: 0.85rem;
}

.view-receipt-link:hover {
  color: var(--clr-accent);
  border-color: var(--clr-accent);
  background: var(--clr-accent-subtle);
}

/* ============================================
   8. Mobile Receipt Cards (hidden by default)
   ============================================ */
.receipt-cards {
  display: none;
}

.receipt-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

.receipt-card + .receipt-card {
  margin-top: var(--space-sm);
}

.receipt-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.receipt-card-vendor {
  font-weight: 600;
  color: var(--clr-text-primary);
  font-size: 0.95rem;
}

.receipt-card-total {
  font-weight: 700;
  color: var(--clr-text-primary);
  font-size: 1rem;
}

.receipt-card-breakdown {
  display: flex;
  gap: var(--space-md);
  padding: 4px 0;
  font-size: 0.75rem;
}

.receipt-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.receipt-card-date {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
}

/* ============================================
   9. Chat Panel (slide-in from right)
   ============================================ */
.chat-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: var(--chat-width);
  background: var(--clr-surface);
  border-left: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition:
    transform var(--transition-speed) ease,
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
  z-index: 90;
}

html.dark .chat-panel {
  background: #0a0a0d;
  border-left-color: rgba(99, 102, 241, 0.12);
}

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

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

html.dark .chat-header {
  border-bottom-color: rgba(99, 102, 241, 0.12);
  background: rgba(12, 12, 15, 0.5);
}

.chat-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--clr-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-powered-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  background: var(--clr-accent-subtle);
  color: var(--clr-accent);
  border-radius: var(--radius-full);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.btn-chat-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-chat-close:hover {
  background: var(--clr-bg);
  color: var(--clr-text-primary);
}

.btn-fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-fullscreen-toggle:hover {
  background: var(--clr-bg);
  color: var(--clr-text-primary);
}

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

.chat-bubble {
  max-width: 85%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.bubble-user {
  align-self: flex-end;
  background: var(--clr-accent);
  color: #FFFFFF;
  border-bottom-right-radius: var(--space-xs);
}

.bubble-assistant {
  align-self: flex-start;
  background: var(--clr-bg);
  color: var(--clr-text-primary);
  border: 1px solid var(--clr-border);
  border-left: 3px solid var(--clr-accent);
  border-bottom-left-radius: var(--space-xs);
  font-size: 0.84rem;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease,
    color var(--transition-speed) ease;
}

html.dark .bubble-assistant {
  background: rgba(6, 6, 10, 0.6);
  border-color: rgba(99, 102, 241, 0.12);
  border-left-color: var(--clr-accent);
}

/* Markdown inside assistant bubbles */
.bubble-assistant p {
  margin: 0 0 var(--space-sm);
}

.bubble-assistant p:last-child {
  margin-bottom: 0;
}

.bubble-assistant code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.82rem;
}

html.dark .bubble-assistant code {
  background: rgba(255, 255, 255, 0.08);
}

.bubble-assistant pre {
  background: rgba(0, 0, 0, 0.06);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: var(--space-sm) 0;
}

html.dark .bubble-assistant pre {
  background: rgba(255, 255, 255, 0.06);
}

.bubble-assistant pre code {
  background: none;
  padding: 0;
}

.bubble-assistant ul,
.bubble-assistant ol {
  margin: var(--space-xs) 0 var(--space-sm) 18px;
}

/* --- Suggestion Chips --- */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  background: var(--clr-accent-subtle);
  color: var(--clr-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
}

html.dark .chip {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
}

.chip:hover {
  background: var(--clr-accent);
  color: #FFFFFF;
  border-color: var(--clr-accent);
}

html.dark .chip:hover {
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

/* --- Loading Dots --- */
.chat-loading {
  display: flex;
  gap: 5px;
  padding: var(--space-sm) 0;
  align-self: flex-start;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--clr-text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Chat Input --- */
.chat-input-area {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--clr-border);
  flex-shrink: 0;
  transition: border-color var(--transition-speed) ease;
}

html.dark .chat-input-area {
  border-top-color: rgba(99, 102, 241, 0.12);
  background: rgba(8, 8, 12, 0.5);
}

.chat-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--clr-text-primary);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color var(--transition-speed) ease;
}

html.dark .chat-input {
  background: #06060a;
  border-color: rgba(99, 102, 241, 0.15);
}

.chat-input::placeholder {
  color: var(--clr-text-muted);
}

.chat-input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-subtle);
}

html.dark .chat-input:focus {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2), 0 0 12px rgba(99, 102, 241, 0.08);
}

.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-accent);
  color: #FFFFFF;
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

html.dark .btn-send:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

.btn-send:hover:not(:disabled) {
  background: var(--clr-accent-hover);
}

.btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================
   10. Chat Fullscreen Mode
   ============================================ */
.chat-panel.fullscreen {
  position: fixed;
  inset: 0;
  width: 100%;
  top: 0;
  border-left: none;
  z-index: 200;
  transform: translateX(0);
}

.chat-panel.fullscreen .chat-messages {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.chat-panel.fullscreen .chat-input-area {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.chat-panel.fullscreen .suggestion-chips {
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================
   11. Image Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--clr-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  position: relative;
  animation: modalEnter 0.25s ease;
}

.modal-image {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  cursor: default;
}

.modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--clr-text-secondary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background-color 0.15s ease;
}

.modal-close:hover {
  background: var(--clr-bg);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================
   12. Loading Skeletons
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--clr-border-subtle) 25%,
    var(--clr-border) 50%,
    var(--clr-border-subtle) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-sm);
  width: 80%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-md);
}

.skeleton-row {
  height: 44px;
  margin-bottom: var(--space-xs);
}

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

/* ============================================
   13. Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 400;
}

.toast {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--clr-text-primary);
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--clr-border);
}

.toast.toast-success {
  border-left-color: var(--clr-success);
}

.toast.toast-danger {
  border-left-color: var(--clr-danger);
}

.toast.toast-info {
  border-left-color: var(--clr-accent);
}

.toast-message {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: var(--clr-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: var(--space-xs);
  transition: color 0.15s ease;
}

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

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================
   14. Login Page
   ============================================ */
/* --- Login page animated orbit ring --- */
@keyframes orbit-spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes card-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.15), 0 0 60px rgba(99, 102, 241, 0.05); }
  50% { box-shadow: 0 0 30px rgba(99, 102, 241, 0.3), 0 0 80px rgba(99, 102, 241, 0.1); }
}

@keyframes emoji-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-lg);
  background: #050508;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 500;
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Scanline overlay */
.login-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(99, 102, 241, 0.03) 2px,
    rgba(99, 102, 241, 0.03) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* Animated orbit ring behind card */
.login-page::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-top-color: rgba(99, 102, 241, 0.5);
  animation: orbit-spin 12s linear infinite;
  pointer-events: none;
  z-index: 0;
}

.login-card {
  position: relative;
  z-index: 2;
  background: rgba(17, 17, 19, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  width: 90%;
  max-width: 400px;
  animation: card-glow 4s ease-in-out infinite;
  transition:
    background-color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

.login-card h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: #E0E7FF;
  margin-bottom: var(--space-xs);
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-card p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #818CF8;
  margin-bottom: var(--space-xl);
  text-align: center;
  letter-spacing: 0.03em;
}

.login-emoji {
  display: block;
  text-align: center;
  margin-bottom: 20px;
  font-size: 64px;
  animation: emoji-pulse 2s ease-in-out infinite;
}

.login-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: #10B981;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  animation: status-pulse 2s ease-in-out infinite;
}

.login-field {
  margin-bottom: var(--space-lg);
}

.login-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--clr-text-secondary);
  margin-bottom: var(--space-xs);
}

.login-field input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--clr-text-primary);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.login-field input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-subtle);
}

.btn-login {
  width: 100%;
  padding: 12px var(--space-lg);
  background: linear-gradient(180deg, #6366F1 0%, #4F46E5 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3), 0 1px 2px rgba(0, 0, 0, 0.08);
}

.btn-login:hover {
  background: linear-gradient(180deg, #4F46E5 0%, #4338CA 100%);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.2);
}

/* ============================================
   15. Utility Classes
   ============================================ */
.text-muted {
  color: var(--clr-text-muted);
}

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

.text-accent {
  color: var(--clr-accent);
}

.text-success {
  color: var(--clr-success);
}

.text-danger {
  color: var(--clr-danger);
}

.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;
}

/* Thumbnail images in table */
.thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.thumb:hover {
  opacity: 0.8;
}

/* ============================================
   15b. Action Bar (category chips + action buttons)
   ============================================ */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* ============================================
   16. Category Filter Chips
   ============================================ */
.category-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chip-filter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chip-filter:hover { border-color: var(--clr-accent); color: var(--clr-accent); }
.chip-filter.active { background: var(--clr-accent); color: #fff; border-color: var(--clr-accent); }

/* ============================================
   17. Toolbar Buttons (Export, Upload, Trips)
   ============================================ */
.btn-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--clr-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

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

/* ============================================
   18. Trip Badge
   ============================================ */
.badge-trip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #DBEAFE;
    color: #1E40AF;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

html.dark .badge-trip {
    background: rgba(59, 130, 246, 0.15);
    color: #93C5FD;
}

/* ============================================
   19. Trip Manager Modal
   ============================================ */
.trip-modal {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 301;
}

.trip-input {
    padding: 8px 12px;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--clr-text-primary);
    outline: none;
    width: 100%;
    transition: border-color 0.2s ease;
}

.trip-input:focus { border-color: var(--clr-accent); }
html.dark .trip-input { color-scheme: dark; }

.btn-create-trip {
    width: 100%;
    padding: 8px;
    background: var(--clr-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-create-trip:hover { background: var(--clr-accent-hover); }

.trip-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--clr-border-subtle);
}

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

.btn-delete-trip {
    background: none;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    color: var(--clr-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.btn-delete-trip:hover { border-color: var(--clr-danger); color: var(--clr-danger); }

/* ============================================
   20. Upload Modal
   ============================================ */
.upload-modal {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 301;
    text-align: center;
}

.upload-dropzone {
    border: 2px dashed var(--clr-border);
    border-radius: var(--radius-md);
    padding: 32px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--clr-text-secondary);
    font-size: 0.85rem;
}

.upload-dropzone:hover {
    border-color: var(--clr-accent);
    background: var(--clr-accent-subtle);
}

.btn-upload {
    width: 100%;
    padding: 10px;
    margin-top: 12px;
    background: var(--clr-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-upload:hover:not(:disabled) { background: var(--clr-accent-hover); }
.btn-upload:disabled { opacity: 0.5; cursor: not-allowed; }

.upload-result {
    padding: 6px 0;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    border-bottom: 1px solid var(--clr-border-subtle);
}

.text-success { color: var(--clr-success); }
.text-danger { color: var(--clr-danger); }

/* ============================================
   21. Responsive: <= 768px
   ============================================ */
@media (max-width: 768px) {
  .top-bar {
    padding: 0 var(--space-lg);
  }

  .top-bar-center {
    display: none;
  }

  .search-bar {
    padding: var(--space-sm) var(--space-lg);
  }

  .search-input {
    max-width: 100%;
  }

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

  /* Dashboard: 2-column grid */
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .stat-card {
    padding: var(--space-lg);
  }

  .stat-card-value {
    font-size: 1.35rem;
  }

  /* Hide table, show card view */
  .table-wrap {
    display: none;
  }

  .receipt-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
  }

  /* Chat becomes a full-width overlay */
  .chat-panel {
    width: 100%;
  }

  .main-layout.chat-visible .content {
    margin-right: 0;
  }

  /* Console strip: 3-column grid on mobile */
  .console-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow-x: visible;
    white-space: normal;
    padding: var(--space-xs, 4px);
    gap: 0;
  }

  .console-divider {
    display: none;
  }

  .console-stat {
    padding: 4px 8px;
    min-width: 0;
  }

  .console-label {
    font-size: 0.55rem;
  }

  .console-value {
    font-size: 0.75rem;
  }

  .category-chips { gap: 4px; justify-content: center; }
  .chip-filter { font-size: 0.65rem; padding: 3px 8px; }
  .btn-toolbar { font-size: 0.65rem; padding: 3px 8px; }
  .action-buttons { justify-content: center; }
}

/* ============================================
   22. Print Styles
   ============================================ */
/* ============================================
   21. Edit / Detail Modal
   ============================================ */
/* ── Edit Modal: side-by-side layout ── */
.edit-modal {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 0;
  width: 92%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 301;
  animation: modalEnter 0.25s ease;
}

.edit-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  color: var(--clr-text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.edit-modal-close:hover {
  color: var(--clr-text-primary);
  border-color: var(--clr-text-muted);
}

.edit-modal-body {
  display: flex;
  min-height: 0;
}

/* Left panel: image + meta */
.edit-panel-left {
  width: 40%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-right: 1px solid var(--clr-border);
  background: var(--clr-bg);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.edit-modal-thumb {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--clr-border);
  flex: 1;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-surface);
  transition: border-color 0.2s ease;
}
.edit-modal-thumb:hover {
  border-color: var(--clr-accent);
}

.edit-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 420px;
}

.edit-thumb-placeholder {
  cursor: default;
  background: var(--clr-surface);
}
.edit-placeholder-emoji {
  font-size: 3rem;
  line-height: 1;
  opacity: 0.5;
}

.edit-panel-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 0;
}

.edit-meta-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--clr-text-muted);
  letter-spacing: 0.02em;
}

.badge-id {
  display: inline-block;
  padding: 2px 8px;
  background: var(--clr-accent-subtle);
  color: var(--clr-accent);
  border-radius: var(--radius-full);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Right panel: form */
.edit-panel-right {
  flex: 1;
  min-width: 0;
  padding: 20px 22px;
  overflow-y: auto;
  max-height: 90vh;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edit-field-full {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.edit-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.edit-grid-2 > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.edit-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.edit-input {
  padding: 8px 12px;
  background: var(--clr-bg);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--clr-text-primary);
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.edit-input:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-subtle);
}

html.dark .edit-input {
  color-scheme: dark;
}

.edit-input-date {
  font-variant-numeric: tabular-nums;
}
.edit-input-date::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.edit-input-date::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
html.dark .edit-input-date::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}

.edit-input-money {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

.edit-input-total {
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 12px;
  border-color: var(--clr-accent-subtle);
}
.edit-input-total:focus {
  box-shadow: 0 0 0 3px var(--clr-accent-subtle), 0 0 12px rgba(99, 102, 241, 0.08);
}

.edit-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.edit-textarea {
  resize: vertical;
  min-height: 52px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.edit-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

.btn-edit-save {
  flex: 1;
  padding: 10px;
  background: var(--clr-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.btn-edit-save:hover {
  background: var(--clr-accent-hover);
}

.btn-edit-save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-edit-cancel {
  padding: 10px 18px;
  background: transparent;
  color: var(--clr-text-secondary);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-edit-cancel:hover {
  color: var(--clr-text-primary);
  border-color: var(--clr-text-muted);
}

.edit-danger-zone {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--clr-border-subtle);
}

.btn-edit-delete {
  width: 100%;
  padding: 7px;
  background: transparent;
  color: var(--clr-danger);
  border: 1px solid var(--clr-danger);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.btn-edit-delete:hover {
  background: var(--clr-danger-bg);
  opacity: 1;
}

/* Mobile: stack vertically */
@media (max-width: 600px) {
  .edit-modal {
    width: 95%;
    max-width: none;
    max-height: 95vh;
  }

  .edit-modal-body {
    flex-direction: column;
  }

  .edit-panel-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--clr-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px;
  }

  .edit-modal-thumb {
    min-height: 140px;
    max-height: 200px;
  }

  .edit-thumb-img {
    max-height: 200px;
  }

  .edit-panel-right {
    padding: 16px;
    max-height: none;
  }

  .edit-grid-2 {
    grid-template-columns: 1fr;
  }

  .edit-actions {
    flex-direction: column;
  }
}

@media print {
  .top-bar {
    position: static;
    background: none;
    color: #000;
    border-bottom: 1px solid #ccc;
  }

  .btn-chat-toggle,
  .btn-dark-toggle,
  .chat-panel,
  .search-bar,
  .modal-overlay,
  .toast-container {
    display: none !important;
  }

  .main-layout.chat-visible .content {
    margin-right: 0;
  }

  body {
    background: #FFFFFF;
    color: #000;
  }

  .stat-card,
  .table-wrap,
  .chart-container {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .receipt-table th,
  .receipt-table td {
    border: 1px solid #ccc;
  }

  .thumb {
    width: 32px;
    height: 32px;
  }
}
