/* ============================================================
   Expense Tracker — App CSS
   Mobile-first, touch-friendly, dark mode support
   ============================================================ */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
  --header-h: 56px;
  --nav-h: 60px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Layout */
.app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 16px);
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow);
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 700;
}

.header-actions { display: flex; gap: 8px; align-items: center; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.btn-icon:active { background: var(--surface-2); }

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  transition: color 0.2s;
}
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 22px; height: 22px; }

/* Screens */
.screen { display: none; padding: 16px; }
.screen.active { display: block; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* Forms */
.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 60px; }

/* Amount input with keypad feel */
.amount-input {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: right;
  letter-spacing: 1px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  min-height: 48px;
}

.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:active { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; }

.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; min-height: 36px; }

/* Denomination Grid */
.denom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.denom-row {
  display: contents;
}

.denom-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 4px;
}

.denom-input {
  text-align: center;
  font-size: 1rem;
  padding: 8px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}

.denom-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
}

/* Running total */
.running-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 8px 0;
}

.running-total.match { color: var(--success); }
.running-total.mismatch { color: var(--danger); }

/* Available balance */
.balance-badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.balance-badge.warn { color: var(--warning); }
.balance-badge.danger { color: var(--danger); }

/* Recent expenses list */
.expense-list { list-style: none; }
.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.expense-item:last-child { border-bottom: none; }

.expense-info { flex: 1; }
.expense-cat { font-weight: 600; font-size: 0.95rem; }
.expense-meta { font-size: 0.8rem; color: var(--text-muted); }
.expense-amount { font-weight: 700; font-size: 1rem; color: var(--primary); }

.expense-actions { display: flex; gap: 4px; }

/* Passcode screen */
.passcode-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.passcode-pad {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  gap: 14px;
  justify-content: center;
  margin: 24px auto;
}

/* Escape hatch on the login screen — lets the API URL be fixed even when
   the stored value points at a dead host. */
.passcode-api-link {
  display: block;
  margin: 4px auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}
.passcode-api-link:hover { color: var(--primary); }

.passcode-key {
  width: 68px;
  height: 68px;
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.passcode-key:active { transform: scale(0.94); background: var(--surface-2); }

.passcode-dots {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 20px 0;
}
.passcode-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  transition: background 0.15s;
}
.passcode-dot.filled { background: var(--primary); }

/* Search */
.search-box {
  position: relative;
  margin-bottom: 10px;
}
.search-box input {
  padding-left: 40px;
}
.search-box svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 20px;
  font-size: 0.8rem;
  margin: 4px;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.chip.selected { border-color: var(--primary); background: var(--primary); color: white; }
.chip.active-true { opacity: 1; }
.chip.active-false { opacity: 0.5; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 1.1rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); color: white; }
.toast.success { background: var(--success); color: white; }

/* Toggle */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.3s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* Reports */
.report-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.report-filters input, .report-filters select {
  width: auto;
  min-width: 120px;
}

.chart-container {
  position: relative;
  height: 250px;
  margin: 16px 0;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}
table.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
table.data-table tr:last-child td { border-bottom: none; }

.summary-total {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}

/* Month close badge */
.month-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.month-badge.open { background: #dcfce7; color: #166534; }
.month-badge.closed { background: #fef2f2; color: #991b1b; }
[data-theme="dark"] .month-badge.open { background: #14532d; color: #86efac; }
[data-theme="dark"] .month-badge.closed { background: #450a0a; color: #fca5a5; }

/* Audit log */
.audit-entry {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.audit-action {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 8px;
}
.audit-action.create { background: #dbeafe; color: #1e40af; }
.audit-action.edit { background: #fef3c7; color: #92400e; }
.audit-action.delete { background: #fee2e2; color: #991b1b; }
.audit-action.merge { background: #e9d5ff; color: #6b21a8; }
.audit-action.split { background: #d1fae5; color: #065f46; }
.audit-action.close { background: #fee2e2; color: #991b1b; }
.audit-action.reopen { background: #dbeafe; color: #1e40af; }

[data-theme="dark"] .audit-action.create { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .audit-action.edit { background: #422006; color: #fbbf24; }
[data-theme="dark"] .audit-action.delete { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .audit-action.merge { background: #3b0764; color: #c4b5fd; }
[data-theme="dark"] .audit-action.split { background: #052e16; color: #6ee7b7; }
[data-theme="dark"] .audit-action.close { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .audit-action.reopen { background: #1e3a5f; color: #93c5fd; }

/* Utility */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* ============================================================
   Component additions
   ============================================================ */

.section-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.45;
}
.field-hint.warn { color: var(--warning); }
.field-hint.strong { font-weight: 700; color: var(--text); }
.field-hint.neg { color: var(--danger); }

.banner {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.banner-edit { background: #fef3c7; color: #92400e; }
.banner-copy { background: #dbeafe; color: #1e40af; }
[data-theme="dark"] .banner-edit { background: #422006; color: #fbbf24; }
[data-theme="dark"] .banner-copy { background: #1e3a5f; color: #93c5fd; }

/* Chips */
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow-y: auto;
  padding: 2px 0;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 13px;
  background: var(--surface-2);
  border-radius: 18px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  color: var(--text);
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  min-height: 36px;
}
.chip.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.chip-frequent { background: transparent; border-color: var(--border); }

/* Form actions */
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.form-actions .btn { flex: 1; }

.inline-form {
  display: flex;
  gap: 8px;
}
.inline-form input { flex: 1; }
.btn-inline { width: auto; flex: 0 0 auto; padding: 12px 20px; }

/* Denomination grid */
.denom-grid {
  display: grid;
  grid-template-columns: 1fr 88px 88px;
  gap: 7px;
  align-items: center;
}
.denom-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 10px;
  height: 44px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--surface-2);
  border-radius: 8px;
}
.denom-header {
  display: grid;
  grid-template-columns: 1fr 88px 88px;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.denom-header span:first-child { text-align: left; padding-left: 10px; }

.denom-input {
  width: 100%;
  height: 44px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  padding: 0 6px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
.denom-input:focus { outline: none; border-color: var(--primary); }
.denom-input.invalid { border-color: var(--danger); background: rgba(239,68,68,0.07); }

.running-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  background: var(--surface-2);
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  margin: 12px 0 0;
  transition: color 0.15s, background 0.15s;
}
.running-total::before { content: 'Breakdown total'; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.running-total.match { color: var(--success); background: rgba(34,197,94,0.1); }
.running-total.mismatch { color: var(--danger); background: rgba(239,68,68,0.08); }

/* Balance badge */
.balance-badge {
  display: inline-block;
  padding: 5px 11px;
  background: var(--surface-2);
  border-radius: 16px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Expense list */
.expense-list { list-style: none; }
.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.expense-item:last-child { border-bottom: none; }
.expense-info { flex: 1; min-width: 0; }
.expense-cat { font-weight: 600; font-size: 0.92rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.expense-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.expense-right { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.expense-amount { font-weight: 700; font-size: 0.95rem; color: var(--text); white-space: nowrap; }
.expense-actions { display: flex; gap: 0; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 7px;
  line-height: 1;
  min-width: 30px;
  min-height: 34px;
  transition: background 0.15s, color 0.15s;
}
.btn-icon:hover, .btn-icon:active { background: var(--surface-2); color: var(--text); }

/* Pick list (modals) */
.pick-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.pick-row:last-child { border-bottom: none; }
.pick-row:active { background: var(--surface-2); }
.pick-row input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; }
.pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pick-title { font-size: 0.88rem; font-weight: 600; }
.pick-meta { font-size: 0.74rem; color: var(--text-muted); }
.pick-amount { font-weight: 700; font-size: 0.88rem; white-space: nowrap; }

/* Export / action rows */
.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.export-row .btn { flex: 0 0 auto; }

/* Reports */
.range-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.range-grid input { font-size: 0.9rem; }

.bar-chart { margin-top: 16px; }
.bar-row { margin-bottom: 9px; }
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
  gap: 8px;
}
.bar-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
table.data-table th {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
table.data-table td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data-table .neg { color: var(--danger); }
table.data-table .total-row td { font-weight: 700; border-top: 2px solid var(--border); }

.summary-total {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.summary-total.center { text-align: center; }

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tag-ok { background: rgba(34,197,94,0.14); color: #15803d; }
.tag-bad { background: rgba(239,68,68,0.14); color: #b91c1c; }
[data-theme="dark"] .tag-ok { color: #6ee7b7; }
[data-theme="dark"] .tag-bad { color: #fca5a5; }

/* Month badge */
.month-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.month-badge.open { background: rgba(34,197,94,0.15); color: #15803d; }
.month-badge.closed { background: rgba(239,68,68,0.14); color: #b91c1c; }
[data-theme="dark"] .month-badge.open { color: #86efac; }
[data-theme="dark"] .month-badge.closed { color: #fca5a5; }

/* Audit log */
.audit-entry {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.audit-entry:last-child { border-bottom: none; }
.audit-action {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  color: var(--text-muted);
}
.audit-action.create { background: rgba(59,130,246,0.14); color: #1d4ed8; }
.audit-action.edit { background: rgba(245,158,11,0.16); color: #b45309; }
.audit-action.delete { background: rgba(239,68,68,0.14); color: #b91c1c; }
.audit-action.merge { background: rgba(168,85,247,0.14); color: #7e22ce; }
.audit-action.split { background: rgba(16,185,129,0.14); color: #047857; }
.audit-action.close { background: rgba(239,68,68,0.14); color: #b91c1c; }
.audit-action.reopen { background: rgba(59,130,246,0.14); color: #1d4ed8; }

[data-theme="dark"] .audit-action.create { color: #93c5fd; }
[data-theme="dark"] .audit-action.edit { color: #fbbf24; }
[data-theme="dark"] .audit-action.delete,
[data-theme="dark"] .audit-action.close { color: #fca5a5; }
[data-theme="dark"] .audit-action.merge { color: #c4b5fd; }
[data-theme="dark"] .audit-action.split { color: #6ee7b7; }
[data-theme="dark"] .audit-action.reopen { color: #93c5fd; }

.audit-time { font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.audit-desc { font-size: 0.84rem; margin-top: 5px; line-height: 1.4; }
.audit-entity { font-size: 0.7rem; color: var(--text-muted); margin-top: 3px; font-family: ui-monospace, monospace; }

/* Funding grid */
.fund-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 7px;
  align-items: center;
  margin-bottom: 7px;
}

/* Bulk tools (split) */
.bulk-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 10px;
}
.bulk-tools .btn { grid-column: 1 / -1; }
.bulk-tools input { font-size: 0.85rem; padding: 9px 11px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Utilities */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* Prevent iOS zoom on focus (16px minimum) */
input, select, textarea { font-size: 16px; }
.denom-input, .bulk-tools input { font-size: 16px; }

/* Available count inside the denomination label */
.denom-label {
  justify-content: space-between;
  gap: 6px;
}
.denom-avail {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 10px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.denom-avail.neg { color: var(--danger); }

/* Cash mode toggle (breakdown vs snapshot) */
.cash-mode-toggle {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.cash-mode-toggle .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
/* "Was" column in snapshot mode */
.denom-was {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-width: 44px;
}
