:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --surface: #1a1f27;
  --surface2: #242a33;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #e6edf3;
  --text2: #8b949e;
  --text3: #6e7681;
  --accent: #7C3AED;
  --accent2: #9D5CF7;
  --accent-glow: rgba(124,58,237,0.25);
  --green: #00e676;
  --green-dim: rgba(0,230,118,0.12);
  --red: #ff5252;
  --red-dim: rgba(255,82,82,0.12);
  --amber: #ffab40;
  --amber-dim: rgba(255,171,64,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --nav-h: 72px;
  --header-h: 56px;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

[data-theme="light"] {
  --bg: #f0f2f5;
  --bg2: #ffffff;
  --bg3: #e8eaed;
  --surface: #ffffff;
  --surface2: #f5f5f7;
  --border: rgba(0,0,0,0.08);
  --border2: rgba(0,0,0,0.14);
  --text: #1a1a2e;
  --text2: #5a6270;
  --text3: #9099a4;
  --accent: #6D28D9;
  --accent2: #7C3AED;
  --accent-glow: rgba(109,40,217,0.15);
  --green: #00a854;
  --green-dim: rgba(0,168,84,0.1);
  --red: #e53935;
  --red-dim: rgba(229,57,53,0.1);
  --amber: #f57c00;
  --amber-dim: rgba(245,124,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden { display: none !important; }

/* SPLASH */
#splash {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  animation: splashOut 0.5s ease 2s forwards;
}
.splash-logo { display: flex; align-items: center; justify-content: center; gap: 14px; }
.splash-img { max-width: 220px; max-height: 220px; object-fit: contain; border-radius: 20px; }
.splash-title {
  font-size: 36px; font-weight: 700; letter-spacing: -1px;
  background: linear-gradient(135deg, #7C3AED, #A78BFA, #00e676);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-sub { color: var(--text2); font-size: 15px; }
@keyframes splashOut { to { opacity: 0; pointer-events: none; } }

/* APP SHELL */
#app {
  height: 100dvh; display: flex; flex-direction: column;
  position: relative;
}

/* HEADER */
#app-header {
  height: var(--header-h); min-height: var(--header-h);
  background: var(--bg2);
  border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; padding: 0 12px; gap: 8px;
  position: relative; z-index: 10;
}
#app-header h1 {
  flex: 1; font-size: 18px; font-weight: 700; letter-spacing: -0.5px;
}
.header-actions { display: flex; gap: 4px; }
.btn-icon {
  width: 40px; height: 40px; border: none; background: transparent;
  color: var(--text2); cursor: pointer; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.btn-icon:hover { color: var(--text); background: var(--bg3); }
.btn-icon:active { transform: scale(0.92); }

/* MAIN CONTENT */
#main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + 16px);
  -webkit-overflow-scrolling: touch;
}

/* VIEWS */
.view { display: none; padding: 16px; animation: slideIn 0.25s ease; }
.view.active { display: block; }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* BOTTOM NAV */
#bottom-nav {
  height: var(--nav-h); min-height: var(--nav-h);
  background: var(--bg2);
  border-top: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 4px; padding-bottom: env(safe-area-inset-bottom);
  position: relative; z-index: 10;
}
.nav-btn {
  flex: 1; border: none; background: transparent;
  color: var(--text3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: var(--radius-sm);
  transition: color 0.2s; font-size: 11px;
  min-height: 52px;
}
.nav-btn svg { transition: stroke 0.2s; }
.nav-btn.active { color: var(--accent2); }
.nav-btn:active { transform: scale(0.92); }

.nav-fab {
  width: 54px; height: 54px; border-radius: 50% !important;
  background: var(--accent); color: #fff !important;
  box-shadow: 0 4px 20px var(--accent-glow);
  flex: none; position: relative; top: -8px;
  padding: 0; align-items: center; justify-content: center;
  transition: transform 0.25s, box-shadow 0.25s;
}
.nav-fab.open { transform: rotate(45deg) translateY(-8px); box-shadow: 0 6px 28px var(--accent-glow); }
.nav-fab span { display: none; }

/* FAB MENU */
.fab-menu { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.fab-menu:not(.hidden) { pointer-events: all; }
.fab-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.25s;
}
.fab-menu:not(.hidden) .fab-backdrop { opacity: 1; }
.fab-options {
  position: absolute; bottom: calc(var(--nav-h) + 70px); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  transform: translateX(-50%) translateY(20px);
}
.fab-menu:not(.hidden) .fab-options { opacity: 1; transform: translateX(-50%) translateY(0); }
.fab-option {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text); border-radius: var(--radius);
  padding: 14px 20px; cursor: pointer; font-size: 15px; font-weight: 500;
  min-width: 220px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab-option:active { transform: scale(0.97); }
.fab-opt-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent2);
}

/* DASHBOARD */
.dashboard-hero {
  background: linear-gradient(135deg, var(--bg2) 0%, #1a1040 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 16px;
}
[data-theme="light"] .dashboard-hero { background: linear-gradient(135deg, #ffffff 0%, #f3e8ff 100%); }
.hero-label { font-size: 13px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.hero-amount {
  font-size: 42px; font-weight: 700; font-family: var(--font-mono);
  background: linear-gradient(135deg, #e0e7ff, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  line-height: 1.1; margin-bottom: 8px;
}
.hero-sub { font-size: 13px; color: var(--text3); }

.budget-overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.budget-bar-labels { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.budget-bar-labels span:first-child { color: var(--text2); }
.budget-bar-labels span:last-child { font-weight: 600; }
.budget-bar-track {
  height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin-bottom: 6px;
}
.budget-bar-fill {
  height: 100%; border-radius: 4px; background: var(--green);
  transition: width 0.6s ease, background 0.3s;
  width: 0%;
}
.budget-bar-fill.warn { background: var(--amber); }
.budget-bar-fill.over { background: var(--red); }
.budget-bar-sub { display: flex; justify-content: space-between; font-size: 12px; color: var(--text3); }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title { font-size: 15px; font-weight: 600; }
.dash-cur-filter {
  font-size: 12px; padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg3); color: var(--text2);
  cursor: pointer;
}
.btn-text {
  background: none; border: none; color: var(--accent2);
  font-size: 13px; cursor: pointer; padding: 4px 8px;
}

/* EXPENSE LIST */
.expense-list { display: flex; flex-direction: column; gap: 8px; }
.expense-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  position: relative; overflow: hidden;
}
.expense-item:active { transform: scale(0.99); }
.expense-item:hover { border-color: var(--border2); }
.expense-cat-dot {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.expense-info { flex: 1; min-width: 0; }
.expense-name {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.expense-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.expense-amount {
  font-size: 15px; font-weight: 700; font-family: var(--font-mono);
  color: var(--red); white-space: nowrap;
}
.expense-amount.positive { color: var(--green); }
.expense-delete-btn {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 0; overflow: hidden;
  background: var(--red-dim);
  display: flex; align-items: center; justify-content: center;
  transition: width 0.2s;
  border-left: 1px solid rgba(255,82,82,0.3);
  cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0;
}
.expense-item.swipe-open .expense-delete-btn { width: 60px; }

/* TICKET GROUP */
.ticket-group {
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 4px;
}
.ticket-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg3);
  font-size: 13px; cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.ticket-group-header:hover { background: var(--surface2); }
.ticket-group-icon { font-size: 15px; flex-shrink: 0; }
.ticket-group-brand { font-weight: 600; flex: 1; color: var(--text); }
.ticket-group-count { font-size: 11px; color: var(--text3); }
.ticket-group-total { font-family: var(--font-mono); font-weight: 700; color: var(--red); font-size: 13px; }
.ticket-chevron { color: var(--text3); transition: transform 0.2s; flex-shrink: 0; }
.btn-edit-ticket {
  flex-shrink: 0; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text3); cursor: pointer;
  transition: all 0.15s;
}
.btn-edit-ticket:hover { background: var(--accent-glow); color: var(--accent2); }
.ticket-group.collapsed .ticket-chevron { transform: rotate(-90deg); }
.ticket-group-body { transition: none; }
.ticket-group.collapsed .ticket-group-body { display: none; }
.ticket-group .expense-item {
  border: none; border-top: 1px solid var(--border);
  border-radius: 0; padding-left: 20px;
}

/* PAYMENT SELECTOR */
.payment-selector { display: flex; gap: 8px; }
.pay-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg3);
  color: var(--text2); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.15s;
}
.pay-btn.active { border-color: var(--accent); background: var(--accent-glow); color: var(--accent2); }

/* INCOME NAV ACTIVE */
.nav-btn[data-view="income"].active { color: #00e676; }
.expense-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}
.btn-edit-exp, .btn-del-exp {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border2); background: var(--bg3);
  color: var(--text3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-edit-exp:hover { color: var(--accent2); border-color: var(--accent); background: var(--accent-glow); }
.btn-del-exp:hover { color: var(--red); border-color: rgba(255,82,82,0.4); background: var(--red-dim); }

.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text3);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.empty-state span { font-size: 13px; }

/* CATEGORY CHIPS */
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  background: var(--surface);
}
.cat-chip .cat-chip-amount {
  font-family: var(--font-mono); font-weight: 700;
}

/* FORMS */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
}
.amount-input-wrap {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 24px;
}
.amount-input {
  flex: 1; background: transparent; border: none;
  border-bottom: 2px solid var(--accent);
  color: var(--text); font-size: 40px; font-weight: 700;
  font-family: var(--font-mono);
  padding: 4px 0; width: 0;
  outline: none; min-width: 0;
}
.amount-input::placeholder { color: var(--bg3); }
.currency-select {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 6px; font-size: 14px; font-weight: 700;
  width: auto; flex-shrink: 0;
}
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.label-hint { font-size: 11px; color: var(--text3); text-transform: none; letter-spacing: 0; font-weight: 400; }
.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="search"],
.form-field input[type="password"],
.form-field select,
.form-field textarea,
select, input[type="date"], input[type="time"], input[type="number"],
input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 15px;
  outline: none; transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: none; }

.form-row { display: flex; gap: 12px; }
.flex1 { flex: 1; }

/* CATEGORY SELECTOR */
.cat-selector {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.cat-sel-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg3); color: var(--text2);
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.15s;
}
.cat-sel-btn.selected {
  color: #fff;
  border-color: transparent;
}
.cat-sel-btn:active { transform: scale(0.96); }

/* BUTTONS */
.btn-primary {
  width: 100%; padding: 14px;
  background: var(--accent);
  color: white; border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.1s, opacity 0.1s;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary.btn-sm { width: auto; padding: 10px 16px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-save { margin-top: 8px; }

.btn-secondary {
  width: 100%; padding: 12px;
  background: transparent; color: var(--text2);
  border: 1px solid var(--border2); border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg3); }
.btn-secondary.btn-sm { width: auto; padding: 10px 14px; font-size: 13px; border-radius: var(--radius-sm); }

.btn-danger {
  width: 100%; padding: 12px;
  background: var(--red-dim); color: var(--red);
  border: 1px solid rgba(255,82,82,0.3); border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s;
}

/* SEARCH */
.search-bar-wrap {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.search-bar {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 14px;
}
.search-bar svg { color: var(--text3); flex-shrink: 0; }
.search-bar input {
  flex: 1; background: none; border: none;
  color: var(--text); font-size: 15px; padding: 12px 0; outline: none;
  box-shadow: none;
}
.btn-filter {
  width: 46px; height: 46px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text2); display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

.filter-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.filter-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.filter-row label { font-size: 13px; color: var(--text2); flex-shrink: 0; }
.filter-row input, .filter-row select { flex: 1; }
.filter-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* SCAN */
#view-scan {
  padding: 0;
}
#view-scan > *:not(#scan-area) {
  padding: 0 16px;
  margin-top: 12px;
}
#view-scan #scan-result,
#view-scan #scan-loading {
  padding: 0 16px;
}
.scan-area {
  background: var(--surface);
  border: 2px dashed var(--border2);
  border-radius: 0;
  width: 100%;
  height: calc(100dvh - var(--header-h) - var(--nav-h));
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color 0.2s;
  margin-bottom: 0;
}
@media (min-width: 600px) {
  #view-scan { padding: 16px; }
  #view-scan > *:not(#scan-area) { padding: 0; }
  #view-scan #scan-result, #view-scan #scan-loading { padding: 0; }
  .scan-area {
    border-radius: var(--radius-lg);
    height: 320px;
    margin-bottom: 16px;
  }
}
.scan-area:hover { border-color: var(--accent); }
.scan-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 24px; text-align: center; color: var(--text3);
}
.scan-icon-wrap { color: var(--accent2); margin-bottom: 4px; }
.scan-placeholder p { font-size: 15px; font-weight: 500; color: var(--text2); }
.scan-placeholder span { font-size: 13px; }
.scan-source-btns {
  display: flex; gap: 10px; margin-top: 8px;
}
.btn-scan-source {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--border2); background: var(--surface2);
  color: var(--text2); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
}
.btn-scan-source:hover, .btn-scan-source:active { border-color: var(--accent); color: var(--accent2); }
.scan-drop-hint { font-size: 13px; color: var(--text3); text-align: center; }
#scan-desktop-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#scan-preview {
  width: 100%; height: 100%;
  object-fit: contain; position: absolute; inset: 0;
  background: #000;
}
#scan-analyze-btn {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 6; white-space: nowrap;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 14px 32px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,58,237,0.5);
  display: flex; align-items: center; gap: 8px;
}
.scan-result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.scan-badge {
  background: var(--accent-glow);
  color: var(--accent2);
  border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(124,58,237,0.3);
}
.scan-items-list {
  display: flex; flex-direction: column; gap: 8px;
}
.scan-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.scan-item input[type="text"] { flex: 1; font-size: 14px; padding: 8px 10px; }
.scan-item input[type="number"] { width: 100px; font-size: 14px; padding: 8px 10px; font-family: var(--font-mono); }
.scan-item-del {
  background: var(--red-dim); border: 1px solid rgba(255,82,82,0.3);
  color: var(--red); border-radius: 8px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.scan-loading {
  position: absolute; inset: 0;
  background: rgba(13,17,23,0.85);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 5;
}
.scan-loading-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.scan-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#scan-loading-text { font-size: 14px; color: var(--text2); }

/* REPORTS */
.report-period {
  display: flex; gap: 4px; overflow-x: auto;
  padding-bottom: 4px; margin-bottom: 16px;
  scrollbar-width: none;
}
.report-period::-webkit-scrollbar { display: none; }
.period-btn {
  flex-shrink: 0; padding: 8px 16px; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text2); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s;
}
.period-btn.active {
  background: var(--accent); border-color: var(--accent); color: white;
}
.custom-range {
  display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.custom-range input { flex: 1; min-width: 130px; }

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); }
.stat-value { font-size: 22px; font-weight: 700; font-family: var(--font-mono); color: var(--text); }

.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; overflow: hidden;
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.chart-card canvas { display: block; width: 100% !important; max-width: 100%; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text2);
}
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.export-actions { display: flex; gap: 8px; margin-top: 8px; }
.export-actions .btn-secondary { width: auto; flex: 1; }

/* SETTINGS */
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.settings-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text3);
}
.collapsible-title {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; padding: 2px 0;
}
.collapse-chevron { transition: transform 0.2s; flex-shrink: 0; }
.collapsible-title.open .collapse-chevron { transform: rotate(180deg); }
.collapsible-body { display: none; margin-top: 12px; }
.collapsible-body.open { display: block; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.settings-row label { font-size: 14px; color: var(--text2); }
.settings-row-col { display: flex; flex-direction: column; gap: 8px; }
.settings-hint { font-size: 12px; color: var(--text3); }
.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
}
.settings-toggle-row span { font-size: 14px; }

/* TOGGLE SWITCH */
.toggle-switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--bg3);
  border-radius: 13px; border: 1px solid var(--border);
  transition: background 0.2s; cursor: pointer;
}
.toggle-track::after {
  content: ''; position: absolute; width: 20px; height: 20px;
  background: var(--text3); border-radius: 50%;
  top: 2px; left: 2px; transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent-glow); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); background: var(--accent2); }

/* CATEGORY MANAGEMENT */
.cats-manage-list { display: flex; flex-direction: column; gap: 8px; }
.cat-manage-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: var(--bg3);
  border-radius: var(--radius-sm);
}
.cat-manage-icon { font-size: 20px; width: 28px; text-align: center; }
.cat-manage-name { flex: 1; font-size: 14px; }
.cat-manage-del {
  background: none; border: none; color: var(--text3);
  cursor: pointer; padding: 4px;
  transition: color 0.15s;
}
.cat-manage-del:hover { color: var(--red); }

.add-cat-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.add-cat-row input[type="text"] { flex: 1; min-width: 100px; }

.app-version {
  text-align: center; font-size: 12px; color: var(--text3); padding: 8px;
}

/* TOAST */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 12px 20px;
  font-size: 14px; font-weight: 500; z-index: 200;
  white-space: nowrap; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast:not(.hidden) { transform: translateX(-50%) translateY(0); }

/* CONFIRM MODAL */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 24px;
  width: 100%; max-width: 320px;
}
.modal-box p { font-size: 15px; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-secondary { flex: 1; }
.modal-actions .btn-danger { flex: 1; width: auto; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* CURRENCY WIDGETS */
.currency-widgets {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 8px;
}
.currency-widget {
  background: linear-gradient(135deg, var(--bg2) 0%, #1a1040 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
}
[data-theme="light"] .currency-widget {
  background: linear-gradient(135deg, #ffffff 0%, #f3e8ff 100%);
}
.currency-widget.primary { padding: 22px 20px; }
.currency-widget-flag { font-size: 24px; flex-shrink: 0; }
.currency-widget-body { flex: 1; min-width: 0; }
.currency-widget-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text3); margin-bottom: 4px; }
.currency-widget-amount {
  font-size: 28px; font-weight: 700; font-family: var(--font-mono); line-height: 1.1;
  background: linear-gradient(135deg, #e0e7ff, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.currency-widget.primary .currency-widget-amount { font-size: 36px; }
.currency-widget-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }
.currency-widget-fx { font-size: 11px; color: var(--amber); margin-top: 2px; }

/* BALANCE WIDGET */
.balance-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 13px; color: var(--text2);
  display: flex; align-items: center; justify-content: space-between;
}
.balance-widget.hidden { display: none; }

/* REPORT FILTERS */
.report-filters {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.report-filters select { flex: 1; font-size: 13px; padding: 8px 10px; }
