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

/* ── THEMES ── */
:root, [data-theme="dark"] {
  --bg: #0e0e11; --surface: #17171c; --surface2: #1e1e26;
  --border: #2a2a36; --accent: #c8f542; --accent2: #f5425a;
  --accentIncome: #42d9f5; --text: #f0f0f0; --muted: #6b6b80;
  --card: #1a1a22; --radius: 16px; --bar-bg: #2a2a36;
}
[data-theme="bright"] {
  --bg: #f5f7fa; --surface: #ffffff; --surface2: #eef0f4;
  --border: #d8dce6; --accent: #2563eb; --accent2: #e11d48;
  --accentIncome: #059669; --text: #111827; --muted: #6b7280;
  --card: #ffffff; --radius: 16px; --bar-bg: #d8dce6;
}
[data-theme="cream"] {
  --bg: #faf6f0; --surface: #fff9f2; --surface2: #f0e8db;
  --border: #ddd0c0; --accent: #b45309; --accent2: #dc2626;
  --accentIncome: #16a34a; --text: #292524; --muted: #78716c;
  --card: #fff9f2; --radius: 16px; --bar-bg: #ddd0c0;
}
[data-theme="purple"] {
  --bg: #0f0a1e; --surface: #1a1130; --surface2: #251840;
  --border: #3b2d5e; --accent: #c084fc; --accent2: #f472b6;
  --accentIncome: #34d399; --text: #f5f0ff; --muted: #7c6fa0;
  --card: #1a1130; --radius: 16px; --bar-bg: #3b2d5e;
}

/* ── NEON THEME — inspired by the Kharcha logo palette ── */
[data-theme="neon"] {
  --bg: #000000;
  --surface: #080810;
  --surface2: #0d0d1a;
  --border: #1a1a2e;
  --accent: #39ff14;        /* neon lime — logo wallet green */
  --accent2: #ff2d78;       /* neon pink/magenta — logo pink arrow */
  --accentIncome: #00e5ff;  /* neon cyan — logo blue arrow */
  --text: #f0f0ff;
  --muted: #4a4a6a;
  --card: #07070f;
  --radius: 16px;
  --bar-bg: #111120;
  /* glow helpers */
  --glow-green: 0 0 8px #39ff14, 0 0 20px #39ff1466, 0 0 40px #39ff1422;
  --glow-pink:  0 0 8px #ff2d78, 0 0 20px #ff2d7866, 0 0 40px #ff2d7822;
  --glow-cyan:  0 0 8px #00e5ff, 0 0 20px #00e5ff66, 0 0 40px #00e5ff22;
}

/* ── BASE ── */
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  transition: background .3s, color .3s;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Subtle neon grid on bg */
[data-theme="neon"] body {
  background-color: #000;
  background-image:
    linear-gradient(rgba(57,255,20,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57,255,20,.025) 1px, transparent 1px);
  background-size: 36px 36px;
}

/* ── SIDEBAR ── */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .3s;
}
.sidebar-overlay.open { opacity: 1; pointer-events: all; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 285px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 100; transform: translateX(-100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; padding: 28px 0;
  padding-top: calc(28px + env(safe-area-inset-top));
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
.sidebar.open { transform: translateX(0); }

[data-theme="neon"] .sidebar {
  border-right-color: #39ff1430;
  box-shadow: 4px 0 30px #39ff1412;
  background-image:
    linear-gradient(rgba(57,255,20,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57,255,20,.02) 1px, transparent 1px);
  background-size: 36px 36px;
  background-color: #080810;
}

.sidebar-logo {
  font-size: 1.6rem; font-weight: 800;
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -1px;
}
.sidebar-logo span { color: var(--accent); }

[data-theme="neon"] .sidebar-logo {
  border-bottom-color: #39ff1428;
}
[data-theme="neon"] .sidebar-logo span {
  background: linear-gradient(90deg, #39ff14 0%, #00e5ff 55%, #ff2d78 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 6px #39ff1480);
}

.sidebar-menu { list-style: none; padding: 16px 0; flex: 1; overflow-y: auto; }
.sidebar-menu li {
  display: flex; align-items: center; gap: 14px;
  padding: 15px 24px; cursor: pointer;
  font-size: .95rem; font-weight: 600; color: var(--muted);
  border-left: 3px solid transparent; transition: all .2s;
  min-height: 56px; -webkit-user-select: none; user-select: none;
}
.sidebar-menu li:hover,
.sidebar-menu li.active {
  color: var(--text); background: var(--surface2); border-left-color: var(--accent);
}
[data-theme="neon"] .sidebar-menu li.active {
  color: #39ff14;
  text-shadow: 0 0 8px #39ff1460;
  border-left-color: #39ff14;
  background: rgba(57,255,20,.05);
}
.sidebar-menu li .icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: background .2s; flex-shrink: 0;
}
.sidebar-menu li:hover .icon,
.sidebar-menu li.active .icon { background: var(--accent); color: var(--bg); }
[data-theme="neon"] .sidebar-menu li.active .icon {
  background: transparent;
  box-shadow: 0 0 0 1px #39ff14, var(--glow-green);
  color: #39ff14;
}

/* ── TOPBAR ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; min-height: 60px;
}
[data-theme="neon"] .topbar {
  background: rgba(0,0,0,.9);
  border-bottom-color: #39ff1422;
  box-shadow: 0 1px 20px #39ff140e;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hamburger {
  width: 46px; height: 46px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  transition: background .2s; -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: all .3s; }
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px,-5px); }
[data-theme="neon"] .hamburger {
  border-color: #39ff1430;
  background: rgba(57,255,20,.04);
}
[data-theme="neon"] .hamburger span { background: #39ff14; box-shadow: 0 0 4px #39ff14; }

.topbar-month { font-size: 1rem; font-weight: 700; letter-spacing: -.5px; }
[data-theme="neon"] .topbar-month {
  background: linear-gradient(90deg, #39ff14, #00e5ff);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 4px #39ff1450);
}

.topbar-actions { display: flex; gap: 8px; }
.topbar-actions button {
  width: 42px; height: 42px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s; touch-action: manipulation;
}
.topbar-actions button:active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
[data-theme="neon"] .topbar-actions button {
  border-color: #39ff1428; color: #39ff14;
  background: rgba(57,255,20,.04);
}
[data-theme="neon"] .topbar-actions button:active {
  background: #39ff14; color: #000;
  box-shadow: var(--glow-green);
}

/* ── MAIN ── */
.main {
  padding: 18px 14px;
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
  max-width: 540px; margin: 0 auto;
}

/* ── SUMMARY CARDS ── */
.summary-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 22px;
}

/* Mobile: Make grid responsive - 3 columns on larger screens */
@media (min-width: 480px) {
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 720px) {
  .summary-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.summary-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  transition: border-color .3s;
}
.summary-card.accent-card {
  background: var(--accent); border-color: var(--accent); color: var(--bg);
}
[data-theme="neon"] .summary-card.accent-card {
  background: transparent;
  border: 1px solid #39ff14;
  box-shadow: var(--glow-green), inset 0 0 24px #39ff1406;
  color: #39ff14;
}
[data-theme="neon"] .summary-card {
  background: var(--card);
  border-color: #14142a;
  box-shadow: inset 0 0 20px rgba(0,229,255,.02);
}
.summary-card .label {
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 5px;
}
.summary-card.accent-card .label { color: rgba(0,0,0,.5); }
[data-theme="neon"] .summary-card.accent-card .label { color: #39ff1455; }
.summary-card .amount {
  font-family: 'DM Mono', monospace;
  font-size: 1.25rem; font-weight: 500; letter-spacing: -1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="neon"] .summary-card.accent-card .amount { text-shadow: var(--glow-green); }
.summary-card .sub { font-size: .65rem; color: var(--muted); margin-top: 3px; }
.summary-card.accent-card .sub { color: rgba(0,0,0,.4); }
[data-theme="neon"] .summary-card.accent-card .sub { color: #39ff1450; }

/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 12px;
}
.section-title {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted);
}
[data-theme="neon"] .section-title { color: #39ff1460; letter-spacing: 2px; }
.count-badge {
  font-family: 'DM Mono', monospace; font-size: .67rem;
  padding: 3px 10px; border-radius: 20px;
  background: var(--surface2); color: var(--muted);
}
[data-theme="neon"] .count-badge {
  background: transparent;
  border: 1px solid #39ff1228;
  color: #39ff1260;
}

/* ── TRANSACTION ITEMS ── */
.transaction-list { display: flex; flex-direction: column; gap: 9px; }
.tx-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 13px 12px;
  display: flex; align-items: center; gap: 11px;
  animation: fadeUp .3s ease both;
}
[data-theme="neon"] .tx-item {
  border-color: #14142a;
  box-shadow: inset 0 0 16px rgba(0,229,255,.015);
}
@keyframes fadeUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}
.tx-icon {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.tx-icon.expense { background: rgba(245,66,90,.12); }
.tx-icon.income  { background: rgba(66,217,245,.1); }
[data-theme="neon"] .tx-icon.expense {
  background: rgba(255,45,120,.07);
  box-shadow: 0 0 0 1px #ff2d7828, 0 0 8px #ff2d7818;
}
[data-theme="neon"] .tx-icon.income {
  background: rgba(0,229,255,.07);
  box-shadow: 0 0 0 1px #00e5ff28, 0 0 8px #00e5ff18;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: .66rem; color: var(--muted); margin-top: 2px; font-family: 'DM Mono', monospace; }
.tx-amount { font-family: 'DM Mono', monospace; font-size: .92rem; font-weight: 500; flex-shrink: 0; }
.tx-amount.expense { color: var(--accent2); }
.tx-amount.income  { color: var(--accentIncome); }
[data-theme="neon"] .tx-amount.expense { color: #ff2d78; text-shadow: 0 0 6px #ff2d7850; }
[data-theme="neon"] .tx-amount.income  { color: #00e5ff; text-shadow: 0 0 6px #00e5ff50; }
.tx-delete {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .85rem; padding: 10px 8px;
  border-radius: 8px; flex-shrink: 0; touch-action: manipulation;
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.tx-delete:active { color: var(--accent2); background: rgba(245,66,90,.1); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.empty-state .big { font-size: 2rem; margin-bottom: 10px; display: block; }

/* ── MONTHLY GRAPH ── */
.graph-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 22px;
}
[data-theme="neon"] .graph-card {
  border-color: #14142a;
  box-shadow: inset 0 0 30px rgba(57,255,20,.025);
}
.graph-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.graph-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.graph-legend { display: flex; gap: 12px; }
.graph-legend-item { display: flex; align-items: center; gap: 5px; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.graph-legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.graph-legend-dot.expense { background: var(--accent2); }
.graph-legend-dot.income  { background: var(--accentIncome); }
[data-theme="neon"] .graph-legend-dot.expense { background: #ff2d78; box-shadow: 0 0 6px #ff2d78; }
[data-theme="neon"] .graph-legend-dot.income  { background: #00e5ff; box-shadow: 0 0 6px #00e5ff; }
.graph-bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; }
.graph-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; }
.graph-bar-wrap { flex: 1; display: flex; align-items: flex-end; gap: 2px; width: 100%; }
.graph-bar {
  flex: 1; border-radius: 5px 5px 0 0; min-height: 3px;
  transition: height .5s cubic-bezier(.4,0,.2,1), opacity .2s;
  cursor: pointer;
  opacity: .8;
}
.graph-bar:hover {
  opacity: 1;
  filter: brightness(1.1);
}
.graph-bar.expense { background: var(--accent2); }
.graph-bar.income  { background: var(--accentIncome); }
[data-theme="neon"] .graph-bar.expense { background: #ff2d78; box-shadow: 0 0 8px #ff2d7850; opacity: 1; }
[data-theme="neon"] .graph-bar.income  { background: #00e5ff; box-shadow: 0 0 8px #00e5ff50; opacity: 1; }
[data-theme="neon"] .graph-bar:hover { box-shadow: 0 0 16px currentColor; }
.graph-bar-label { font-family: 'DM Mono', monospace; font-size: .56rem; color: var(--muted); margin-top: 5px; text-align: center; }
.graph-bar-group.current .graph-bar-label { color: var(--accent); font-weight: 700; }
[data-theme="neon"] .graph-bar-group.current .graph-bar-label { text-shadow: 0 0 6px #39ff14; }
.graph-bar-group.current .graph-bar { opacity: 1; }

/* ── EXPORT BTN ── */
.export-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-family: 'Syne', sans-serif;
  font-size: .82rem; font-weight: 700; cursor: pointer;
  transition: all .2s; margin-bottom: 20px; width: 100%;
  justify-content: center; min-height: 50px; touch-action: manipulation;
}
.export-btn:active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
[data-theme="neon"] .export-btn {
  border-color: #00e5ff35;
  color: #00e5ff;
  background: rgba(0,229,255,.04);
  box-shadow: 0 0 10px #00e5ff12;
}
[data-theme="neon"] .export-btn:active {
  background: #00e5ff; color: #000;
  box-shadow: var(--glow-cyan);
}

/* ── CALENDAR ── */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-nav {
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s; touch-action: manipulation;
}
.cal-nav:active { background: var(--accent); color: var(--bg); }
[data-theme="neon"] .cal-nav {
  border-color: #39ff1228; color: #39ff14;
  background: rgba(57,255,20,.04);
}
[data-theme="neon"] .cal-nav:active { background: #39ff14; color: #000; box-shadow: var(--glow-green); }
.cal-month-label { font-size: 1rem; font-weight: 800; letter-spacing: -.3px; }
[data-theme="neon"] .cal-month-label { color: #39ff14; text-shadow: var(--glow-green); }

.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-day-name {
  text-align: center; font-size: .58rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; padding: 4px 0 7px;
}
.cal-day-name:first-child { color: var(--accent2); }
.cal-day-name:last-child  { color: var(--accentIncome); }
[data-theme="neon"] .cal-day-name:first-child { color: #ff2d78; text-shadow: 0 0 4px #ff2d7838; }
[data-theme="neon"] .cal-day-name:last-child  { color: #00e5ff; text-shadow: 0 0 4px #00e5ff38; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; position: relative; transition: background .15s, border-color .15s;
  min-height: 40px; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.cal-cell.empty { cursor: default; pointer-events: none; }
.cal-cell.has-tx { background: var(--surface); border-color: var(--border); }
[data-theme="neon"] .cal-cell.has-tx {
  background: rgba(57,255,20,.035);
  border-color: #39ff1222;
}
.cal-cell:not(.empty):active { background: var(--surface2); }
.cal-cell.selected { background: rgba(200,245,66,.08) !important; border-color: var(--accent) !important; }
[data-theme="neon"] .cal-cell.selected {
  background: rgba(57,255,20,.08) !important;
  border-color: #39ff14 !important;
  box-shadow: 0 0 12px #39ff1428 !important;
}
.cal-cell.today .day-num { color: var(--accent); font-weight: 800; }
[data-theme="neon"] .cal-cell.today .day-num { text-shadow: var(--glow-green); }
.day-num { font-size: .78rem; font-weight: 600; line-height: 1; }
.day-dot-row { display: flex; gap: 2px; margin-top: 3px; justify-content: center; }
.day-dot { width: 4px; height: 4px; border-radius: 50%; }
.day-dot.expense { background: var(--accent2); }
.day-dot.income  { background: var(--accentIncome); }
[data-theme="neon"] .day-dot.expense { background: #ff2d78; box-shadow: 0 0 4px #ff2d78; }
[data-theme="neon"] .day-dot.income  { background: #00e5ff; box-shadow: 0 0 4px #00e5ff; }

/* ── DAY PANEL ── */
.day-panel { overflow: hidden; max-height: 0; opacity: 0; transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s; }
.day-panel.open { max-height: 2000px; opacity: 1; }
.day-panel-inner {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin: 10px 0 4px;
}
[data-theme="neon"] .day-panel-inner {
  border-color: #39ff1228;
  box-shadow: 0 0 20px #39ff1412;
  background: #080810;
}
.day-panel-title {
  font-size: .76rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--accent);
  margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between;
}
[data-theme="neon"] .day-panel-title { text-shadow: var(--glow-green); }
.day-panel-close {
  background: none; border: none; color: var(--muted);
  font-size: 1rem; cursor: pointer; padding: 8px 10px;
  border-radius: 6px; touch-action: manipulation;
  min-width: 38px; min-height: 38px;
  display: flex; align-items: center; justify-content: center;
}
.day-panel-close:active { color: var(--accent2); }

/* ── ACCORDION ── */
.accordion {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; margin-top: 18px; overflow: hidden;
}
[data-theme="neon"] .accordion { border-color: #14142a; }
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px; cursor: pointer;
  -webkit-user-select: none; user-select: none;
  min-height: 60px; touch-action: manipulation;
}
.accordion-header:active { background: var(--surface2); }
.accordion-left { display: flex; flex-direction: column; gap: 3px; }
.accordion-title { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.accordion-count { font-family: 'DM Mono', monospace; font-size: .7rem; color: var(--muted); }
.accordion-arrow { font-size: .9rem; color: var(--muted); transition: transform .3s; }
.accordion.open .accordion-arrow { transform: rotate(180deg); }
[data-theme="neon"] .accordion-arrow { color: #39ff1240; }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height .4s cubic-bezier(.4,0,.2,1); }
.accordion.open .accordion-body { max-height: 9999px; }
.accordion-content { padding: 4px 12px 16px; display: flex; flex-direction: column; gap: 9px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.82);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--border);
  padding: 22px 18px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  width: 100%; max-width: 500px;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  max-height: 92dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.open .modal { transform: translateY(0); }
[data-theme="neon"] .modal {
  border-top-color: #39ff1228;
  box-shadow: 0 -4px 40px #39ff1412, 0 -1px 0 #39ff1228;
  background: #080810;
  background-image:
    linear-gradient(rgba(57,255,20,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57,255,20,.018) 1px, transparent 1px);
  background-size: 36px 36px;
}
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 20px; }
[data-theme="neon"] .modal-handle { background: #39ff1228; }
.modal-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 18px; letter-spacing: -.5px; }
[data-theme="neon"] .modal-title {
  background: linear-gradient(90deg, #39ff14, #00e5ff);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 4px #39ff1440);
}

/* ── FORM ── */
.form-group { margin-bottom: 13px; }
.form-label {
  display: block; font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 7px;
}
[data-theme="neon"] .form-label { color: #39ff1255; letter-spacing: 1.5px; }
.form-input, .form-select {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
  font-family: 'DM Mono', monospace;
  padding: 14px 15px; outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
  font-size: 16px;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
[data-theme="neon"] .form-input,
[data-theme="neon"] .form-select {
  background: rgba(57,255,20,.03);
  border-color: #39ff1220;
  color: #f0f0ff;
}
[data-theme="neon"] .form-input:focus,
[data-theme="neon"] .form-select:focus {
  border-color: #39ff14;
  box-shadow: 0 0 0 1px #39ff1428, 0 0 14px #39ff141a;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center; padding-right: 40px;
}
.form-select option { background: var(--surface2); }

/* ── TYPE TOGGLE ── */
.type-toggle { display: flex; gap: 10px; margin-bottom: 13px; }
.type-btn {
  flex: 1; padding: 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--muted); font-family: 'Syne', sans-serif;
  font-size: .88rem; font-weight: 700; cursor: pointer;
  transition: all .2s; touch-action: manipulation; min-height: 50px;
}
.type-btn.active-expense { background: rgba(245,66,90,.15); border-color: var(--accent2); color: var(--accent2); }
.type-btn.active-income  { background: rgba(66,217,245,.1); border-color: var(--accentIncome); color: var(--accentIncome); }
[data-theme="neon"] .type-btn.active-expense {
  background: rgba(255,45,120,.09);
  border-color: #ff2d78;
  color: #ff2d78;
  box-shadow: 0 0 14px #ff2d7828;
}
[data-theme="neon"] .type-btn.active-income {
  background: rgba(0,229,255,.07);
  border-color: #00e5ff;
  color: #00e5ff;
  box-shadow: 0 0 14px #00e5ff28;
}

/* ── BUTTONS ── */
.btn-primary {
  width: 100%; padding: 17px; border-radius: 14px; border: none;
  background: var(--accent); color: var(--bg);
  font-family: 'Syne', sans-serif; font-size: .95rem; font-weight: 800;
  cursor: pointer; margin-top: 8px;
  min-height: 56px; touch-action: manipulation;
}
.btn-primary:active { opacity: .85; }
[data-theme="neon"] .btn-primary {
  background: linear-gradient(90deg, #39ff14, #00e5ff);
  color: #000; font-weight: 900; letter-spacing: .5px;
  box-shadow: var(--glow-green);
}
[data-theme="neon"] .btn-primary:active {
  box-shadow: 0 0 22px #39ff14, 0 0 44px #00e5ff38;
  opacity: .9;
}
.btn-secondary {
  width: 100%; padding: 15px; border-radius: 14px;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  font-family: 'Syne', sans-serif; font-size: .88rem; font-weight: 700;
  cursor: pointer; margin-top: 10px;
  min-height: 50px; touch-action: manipulation;
}
.btn-secondary:active { background: var(--surface2); }
[data-theme="neon"] .btn-secondary {
  border-color: #39ff1228; color: #39ff1270;
}
[data-theme="neon"] .btn-secondary:active {
  background: rgba(57,255,20,.05);
  border-color: #39ff14; color: #39ff14;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  right: 18px;
  width: 60px; height: 60px; border-radius: 18px;
  background: var(--accent); border: none; color: var(--bg);
  font-size: 1.8rem; cursor: pointer;
  box-shadow: 0 8px 28px rgba(200,245,66,.3);
  z-index: 80; display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
  transition: transform .15s, box-shadow .15s;
}
.fab:active { transform: scale(.92); }
[data-theme="neon"] .fab {
  background: linear-gradient(135deg, #39ff14, #00e5ff);
  color: #000; border-radius: 20px;
  box-shadow: var(--glow-green), 0 8px 32px rgba(57,255,20,.35);
}
[data-theme="neon"] .fab:active {
  transform: scale(.92);
  box-shadow: 0 0 32px #39ff14, 0 0 64px #00e5ff38;
}
/* Neon FAB pulse ring */
[data-theme="neon"] .fab::after {
  content: '';
  position: absolute; inset: -5px;
  border-radius: 25px;
  background: conic-gradient(from 0deg, #39ff14, #00e5ff, #ff2d78, #39ff14);
  opacity: 0;
  z-index: -1;
  animation: neon-ring 2.5s ease-in-out infinite;
}
@keyframes neon-ring {
  0%, 100% { opacity: 0; transform: scale(1); }
  50%       { opacity: .18; transform: scale(1.1); }
}

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: block; }

/* ── THEME SWITCHER ── */
.theme-switcher { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.theme-btn {
  flex: 1; min-width: 56px;
  padding: 10px 4px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface2);
  cursor: pointer; font-family: 'Syne', sans-serif;
  font-size: .66rem; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all .2s; min-height: 68px; touch-action: manipulation;
}
.theme-btn.active { border-color: var(--accent); color: var(--text); }
.theme-btn:active { opacity: .8; }
.theme-swatch { width: 24px; height: 24px; border-radius: 8px; border: 1px solid rgba(0,0,0,.1); }
[data-theme="neon"] .theme-btn.active {
  border-color: #39ff14;
  color: #39ff14;
  box-shadow: 0 0 10px #39ff1225;
}
/* Neon swatch: gradient matching the logo */
.theme-swatch-neon {
  background: linear-gradient(135deg, #39ff14 0%, #00e5ff 50%, #ff2d78 100%);
  border: none !important;
  box-shadow: 0 0 8px #39ff1250;
  width: 24px; height: 24px; border-radius: 8px;
}

/* ── RECURRING ── */
.recurring-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 13px 14px;
  display: flex; align-items: center; gap: 12px;
}
[data-theme="neon"] .recurring-item { border-color: #14142a; }
.recurring-info { flex: 1; min-width: 0; }
.recurring-name { font-size: .88rem; font-weight: 600; }
.recurring-meta { font-size: .67rem; color: var(--muted); margin-top: 2px; font-family: 'DM Mono', monospace; }
.recurring-actions { display: flex; gap: 6px; flex-shrink: 0; }
.rec-use-btn {
  padding: 9px 14px; border-radius: 9px;
  border: 1px solid var(--accent); background: transparent;
  color: var(--accent); font-family: 'Syne', sans-serif;
  font-size: .72rem; font-weight: 700; cursor: pointer;
  touch-action: manipulation; min-height: 40px;
}
.rec-use-btn:active { background: var(--accent); color: var(--bg); }
[data-theme="neon"] .rec-use-btn {
  border-color: #39ff1240; color: #39ff14;
}
[data-theme="neon"] .rec-use-btn:active {
  background: #39ff14; color: #000;
  box-shadow: var(--glow-green);
}
.rec-del-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .85rem; padding: 9px 8px;
  border-radius: 6px; touch-action: manipulation;
  min-width: 38px; min-height: 38px;
  display: flex; align-items: center; justify-content: center;
}
.rec-del-btn:active { color: var(--accent2); }

.settings-note {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 14px; padding: 15px; color: var(--muted);
  font-size: .82rem; line-height: 1.6; margin-top: 14px;
}
[data-theme="neon"] .settings-note {
  background: rgba(57,255,20,.025);
  border-color: #39ff1218;
}

/* ── QUICK CHIPS ── */
.quick-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.quick-chip {
  padding: 9px 14px; border-radius: 30px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--muted); font-family: 'Syne', sans-serif;
  font-size: .75rem; font-weight: 700; cursor: pointer;
  transition: all .15s; touch-action: manipulation; min-height: 40px;
  display: flex; align-items: center;
}
.quick-chip:active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
[data-theme="neon"] .quick-chip {
  border-color: #39ff1218;
  color: #39ff1260;
  background: rgba(57,255,20,.03);
}
[data-theme="neon"] .quick-chip:active {
  background: #39ff14; color: #000;
  box-shadow: var(--glow-green);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
[data-theme="neon"] ::-webkit-scrollbar-thumb { background: #39ff1228; }

/* ── MOBILE OPTIMIZATIONS FOR APP CONVERSION ── */
@media (max-width: 480px) {
  /* Reduce padding on small screens */
  .main {
    padding: 14px 10px;
    padding-bottom: calc(90px + env(safe-area-inset-bottom));
  }
  
  /* Make summary cards stack better */
  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }
  
  /* Reduce font sizes for readability */
  .summary-card .label {
    font-size: .6rem;
  }
  
  .summary-card .amount {
    font-size: 1.1rem;
  }
  
  /* Optimize transaction items */
  .tx-item {
    padding: 11px 10px;
    border-radius: 12px;
    gap: 9px;
  }
  
  .tx-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  
  .tx-desc {
    font-size: .8rem;
  }
  
  .tx-date {
    font-size: .62rem;
  }
  
  .tx-amount {
    font-size: .85rem;
  }
  
  /* FAB positioning for notch devices */
  .fab {
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: calc(20px + env(safe-area-inset-right));
  }
  
  /* Modal optimization */
  .modal {
    border-radius: 24px 24px 0 0;
    max-height: 90vh;
  }
  
  .form-input, .form-select {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px 14px;
    min-height: 44px; /* Touch target size */
  }
  
  /* Button touch size optimization */
  .btn-primary, .btn-secondary {
    min-height: 48px;
    font-size: .9rem;
  }
  
  /* Sidebar optimization */
  .sidebar {
    width: 280px;
  }
  
  .hamburger {
    width: 40px;
    height: 40px;
    min-height: 44px;
  }
}

/* Landscape orientation tweaks */
@media (max-height: 600px) and (orientation: landscape) {
  .main {
    padding-top: 10px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
  
  .summary-grid {
    margin-bottom: 12px;
  }
  
  .summary-card .label {
    font-size: .55rem;
  }
  
  .summary-card .amount {
    font-size: 1rem;
  }
}

/* Large screen optimization */
@media (min-width: 900px) {
  .main {
    max-width: 900px;
    padding: 28px 20px;
  }
  
  .summary-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 28px;
  }
  
  .summary-card {
    padding: 16px 14px;
  }
}

/* Tablet optimization */
@media (min-width: 600px) and (max-width: 900px) {
  .main {
    max-width: 600px;
    padding: 18px 16px;
  }
  
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* Safe area optimization for notch devices */
@supports (padding: max(0px)) {
  .sidebar {
    padding-left: max(28px, env(safe-area-inset-left));
    padding-right: max(28px, env(safe-area-inset-right));
  }
  
  .main {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
}

/* Prevent zoom on input focus for iOS */
input, select, textarea {
  font-size: 16px;
}

/* Touch feedback optimization */
button, input[type="button"], input[type="submit"] {
  -webkit-user-select: none;
  user-select: none;
}

/* Optimize graph for mobile */
@media (max-width: 480px) {
  .graph-bars {
    gap: 6px;
  }
  
  .graph-bar-group {
    min-width: 40px;
  }
  
  .graph-bar-label {
    font-size: .65rem;
  }
}

/* ── RESPONSIVE ── */
@media (max-width: 360px) {
  .summary-card .amount { font-size: 1.05rem; }
  .sidebar { width: 260px; }
  .main { padding: 14px 12px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  .cal-cell { min-height: 36px; }
  .theme-btn { min-width: 48px; font-size: .6rem; }
}
@media (min-width: 480px) {
  .summary-card .amount { font-size: 1.5rem; }
  .main { padding: 22px 20px; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
}
