/* ==========================================================================
   SpendSense — Design System
   Clean finance SaaS UI: muted sage green, warm off-white, white cards,
   subtle borders, professional typography, consistent spacing.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --surface-3: #f0eee8;
  --border: #e6e3da;
  --border-strong: #d9d5c9;

  --ink: #23281f;
  --ink-2: #3d4437;
  --muted: #6e7568;
  --faint: #9aa093;

  --primary: #6f9166;
  --primary-600: #5d7d55;
  --primary-700: #4d6a47;
  --primary-100: #eaf1e6;
  --primary-ring: rgba(111, 145, 102, 0.32);

  --accent: #c9a26b;
  --accent-100: #f6efdf;
  --teal: #5f8f8b;
  --teal-100: #e6f0ef;
  --blue: #5f7f9e;
  --blue-100: #e8eef4;
  --rose: #b06a63;
  --rose-100: #f7eae8;
  --amber: #b9803a;
  --amber-100: #f7eedd;
  --danger: #ab5049;
  --danger-600: #93423c;
  --danger-100: #f7e9e7;
  --success: #4f7d5c;
  --success-100: #e8f0e9;
  --warn: #b9803a;
  --warn-100: #f7eedd;
  --info: #5f7f9e;
  --info-100: #e8eef4;

  --r-sm: 8px;
  --r: 11px;
  --r-lg: 16px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(31, 36, 28, 0.06);
  --shadow: 0 4px 14px rgba(31, 36, 28, 0.07);
  --shadow-lg: 0 18px 44px rgba(31, 36, 28, 0.12);

  --sidebar-w: 256px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

/* Theme colour variants (Settings page) */
:root[data-theme-color="blue"] {
  --primary: #5f7f9e;
  --primary-600: #4f6d8c;
  --primary-700: #425c77;
  --primary-100: #e8eef4;
  --primary-ring: rgba(95, 127, 158, 0.32);
}
:root[data-theme-color="red"] {
  --primary: #ac5f57;
  --primary-600: #954e47;
  --primary-700: #7e413b;
  --primary-100: #f7eae8;
  --primary-ring: rgba(172, 95, 87, 0.32);
}
:root[data-theme-color="yellow"] {
  --primary: #b0803a;
  --primary-600: #986d30;
  --primary-700: #805b28;
  --primary-100: #f7eedd;
  --primary-ring: rgba(176, 128, 58, 0.32);
}

/* Dark mode */
:root[data-mode="dark"] {
  color-scheme: dark;
  --bg: #151814;
  --surface: #1d211c;
  --surface-2: #22261f;
  --surface-3: #2a2f27;
  --border: #2e342b;
  --border-strong: #3a4136;

  --ink: #e9ece4;
  --ink-2: #c9cec2;
  --muted: #9aa294;
  --faint: #6f776a;

  --primary-100: rgba(111, 145, 102, 0.18);
  --teal-100: rgba(95, 143, 139, 0.16);
  --blue-100: rgba(95, 127, 158, 0.16);
  --rose-100: rgba(176, 106, 99, 0.16);
  --amber-100: rgba(185, 128, 58, 0.16);
  --danger-100: rgba(171, 80, 73, 0.16);
  --success-100: rgba(79, 125, 92, 0.16);
  --warn-100: rgba(185, 128, 58, 0.16);
  --info-100: rgba(95, 127, 158, 0.16);
  --accent-100: rgba(201, 162, 107, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

a { color: inherit; text-decoration: none; }
a.link { color: var(--primary-600); font-weight: 600; }
a.link:hover { text-decoration: underline; }

img, svg { display: block; }
[hidden] { display: none !important; }

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

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono-num { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--primary-100); }

/* ---------- Buttons ---------- */
.btn, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  text-align: center;
  white-space: nowrap;
}
.btn:disabled, .button:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.primary, .button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px var(--primary-ring);
}
.btn.primary:hover, .button.primary:hover { background: var(--primary-600); }

.btn.secondary, .button.secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink-2);
}
.btn.secondary:hover, .button.secondary:hover { background: var(--surface-2); border-color: var(--muted); }

.btn.ghost, .button.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.ghost:hover, .button.ghost:hover { background: var(--surface-3); }

.btn.danger, .button.danger { background: var(--danger); color: #fff; }
.btn.danger:hover, .button.danger:hover { background: var(--danger-600); }

.btn.danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn.danger-ghost:hover { background: var(--danger-100); }

.btn.sm, .button.sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 7px; }
.btn.block { width: 100%; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }

.icon-btn svg, .nav-ico svg, .stat-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 0.83rem; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 0.78rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="month"], input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 74px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236e7568' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 30px;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--ink-2); }
.check-row input { width: auto; }

.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field button {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
}
.password-field button:hover { background: var(--surface-3); color: var(--ink-2); }

/* Inline feedback messages (forms + pages) */
.msg, .expense-message, .income-message, .budget-message, .category-message, .auth-message {
  font-size: 0.86rem;
  color: var(--muted);
  min-height: 1.2em;
}
.msg.error, .expense-message.error, .income-message.error, .budget-message.error,
.category-message.error, .auth-message.error { color: var(--danger); }
.msg.success, .expense-message.success, .income-message.success, .budget-message.success,
.category-message.success, .auth-message.success { color: var(--success); }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  box-shadow: 0 2px 6px var(--primary-ring);
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-group {
  margin: 14px 8px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}
.sidebar-group:first-child { margin-top: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8.5px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.14s, color 0.14s;
}
.sidebar-link:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-link.active { background: var(--primary-100); color: var(--primary-700); }
.nav-ico { width: 18px; height: 18px; color: var(--muted); flex: 0 0 18px; }
.sidebar-link.active .nav-ico, .sidebar-link:hover .nav-ico { color: inherit; }
.nav-ico svg { width: 18px; height: 18px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.user-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-700);
  font-weight: 700;
  font-size: 0.88rem;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 0.87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 26, 20, 0.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 35;
}

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-toggle { display: none; }
.topbar-titles { display: flex; flex-direction: column; min-width: 0; }
.topbar-title { font-size: 1.06rem; font-weight: 700; }
.topbar-sub { font-size: 0.78rem; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 26px 28px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 0.98rem; font-weight: 700; }
.card-sub { font-size: 0.8rem; color: var(--muted); margin-top: 1px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.section-gap { margin-top: 22px; }

/* ---------- Stat cards ---------- */
.stat-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.stat-icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--primary-100);
  color: var(--primary-600);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.tone-amber { background: var(--amber-100); color: var(--amber); }
.stat-icon.tone-teal { background: var(--teal-100); color: var(--teal); }
.stat-icon.tone-blue { background: var(--blue-100); color: var(--blue); }
.stat-icon.tone-rose { background: var(--rose-100); color: var(--rose); }
.stat-value { font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 0.78rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.stat-delta.pos { color: var(--success); }
.stat-delta.neg { color: var(--danger); }
.stat-delta.neutral { color: var(--muted); }
.stat-foot { font-size: 0.78rem; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
}
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 11px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-main { font-weight: 600; }
.table .cell-sub { font-size: 0.78rem; color: var(--muted); }

.amount-pos { color: var(--success); font-weight: 650; font-variant-numeric: tabular-nums; }
.amount-neg { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.amount-danger { color: var(--danger); font-weight: 650; }

/* Badges & pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.green { background: var(--primary-100); color: var(--primary-700); }
.pill.amber { background: var(--amber-100); color: var(--amber); }
.pill.teal { background: var(--teal-100); color: var(--teal); }
.pill.blue { background: var(--blue-100); color: var(--blue); }
.pill.rose { background: var(--rose-100); color: var(--rose); }
.pill.danger { background: var(--danger-100); color: var(--danger); }
.pill.success { background: var(--success-100); color: var(--success); }
.pill.neutral { background: var(--surface-3); color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 8px; }
.dot.amber { background: var(--amber); }
.dot.teal { background: var(--teal); }
.dot.blue { background: var(--blue); }
.dot.rose { background: var(--rose); }

/* Row actions */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.row-btn:hover { background: var(--surface-2); }
.row-btn.danger { color: var(--danger); }
.row-btn.danger:hover { background: var(--danger-100); border-color: var(--danger-100); }

/* ---------- Progress & CSS charts ---------- */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--primary); transition: width 0.4s ease; }
.progress.warn > span { background: var(--amber); }
.progress.danger > span { background: var(--danger); }

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-row .bar-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 0.84rem; margin-bottom: 6px; }
.bar-row .bar-meta strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-row .bar-meta span { color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.bar-fill.amber { background: var(--amber); }
.bar-fill.teal { background: var(--teal); }
.bar-fill.blue { background: var(--blue); }
.bar-fill.rose { background: var(--rose); }

.columns-chart { display: flex; align-items: stretch; gap: 22px; height: 170px; padding-top: 6px; }
.columns-chart .col { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.columns-chart .col-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
.columns-chart .col-bar { width: 34%; max-width: 46px; border-radius: 7px 7px 3px 3px; background: var(--primary); min-height: 3px; transition: height 0.4s ease; }
.columns-chart .col-bar.alt { background: var(--surface-3); border: 1px solid var(--border-strong); }
.columns-chart .col-label { text-align: center; font-size: 0.78rem; color: var(--muted); }
.columns-chart .col-value { text-align: center; font-size: 0.78rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; color: var(--ink-2); }

/* ---------- States (loading / empty / error) ---------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.state .state-ico {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--faint);
}
.state .state-ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.state.error { color: var(--danger); }
.state.error .state-ico { background: var(--danger-100); color: var(--danger); }
.state .btn { margin-top: 6px; }

.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.skeleton.line { height: 12px; }
.skeleton.block { height: 64px; border-radius: var(--r); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink);
  color: var(--surface);
  padding: 11px 15px;
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal (auth) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 28, 22, 0.5);
  backdrop-filter: blur(3px);
}
#auth-modal[aria-hidden="true"] { display: none; }

.modal {
  position: relative;
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 26px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-3); color: var(--ink); }
.modal h2 { font-size: 1.2rem; }
.modal .modal-sub { font-size: 0.86rem; color: var(--muted); margin-top: 4px; }

.auth-tabs { display: flex; gap: 4px; background: var(--surface-3); border-radius: 10px; padding: 4px; margin: 18px 0; }
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.auth-tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.modal form { display: flex; flex-direction: column; gap: 14px; }
.modal .auth-message { margin-top: 12px; }

/* ---------- Landing ---------- */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.l-container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.landing-nav .l-bar { display: flex; align-items: center; gap: 26px; min-height: 62px; }
.landing-nav .brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1rem; }
.landing-nav .l-links { display: flex; align-items: center; gap: 22px; font-size: 0.88rem; font-weight: 600; color: var(--muted); margin-left: auto; }
.landing-nav .l-links a:hover { color: var(--ink); }
.landing-nav .l-actions { display: flex; align-items: center; gap: 8px; }

.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 54px; align-items: center; padding: 64px 0 46px; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--primary-100);
  color: var(--primary-700);
  font-size: 0.78rem;
  font-weight: 650;
  width: fit-content;
}
.hero h1 { font-size: clamp(1.85rem, 3.4vw, 2.5rem); margin-top: 16px; letter-spacing: -0.025em; }
.hero .hero-sub { color: var(--muted); font-size: 1rem; margin-top: 14px; max-width: 48ch; }
.hero-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.trust-row { display: flex; gap: 20px; margin-top: 26px; flex-wrap: wrap; }
.trust-row div { display: flex; flex-direction: column; }
.trust-row strong { font-size: 1.02rem; font-weight: 750; }
.trust-row span { font-size: 0.78rem; color: var(--muted); }

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-head .pill { font-size: 0.72rem; }
.preview-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.preview-stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; }
.preview-stat span { font-size: 0.72rem; color: var(--muted); display: block; }
.preview-stat strong { font-size: 0.98rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.preview-bars { display: flex; flex-direction: column; gap: 10px; }
.preview-bars .bar-meta { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 5px; }
.preview-rows { display: flex; flex-direction: column; gap: 9px; }
.preview-row { display: flex; align-items: center; gap: 10px; font-size: 0.84rem; }
.preview-row .amt { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

.features { padding: 34px 0 84px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.feature-card .stat-icon { margin-bottom: 14px; }
.feature-card h3 { font-size: 0.98rem; }
.feature-card p { color: var(--muted); font-size: 0.88rem; margin-top: 6px; }

.landing-footer { border-top: 1px solid var(--border); padding: 22px 0; }
.landing-footer .l-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 0.82rem; color: var(--muted); flex-wrap: wrap; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 36px 18px; }
.auth-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 30px;
}
.auth-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-head .brand-mark { width: 42px; height: 42px; border-radius: 12px; font-size: 1.1rem; }
.auth-head h1 { font-size: 1.3rem; }
.auth-head p { color: var(--muted); font-size: 0.88rem; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form .btn { margin-top: 2px; }
.auth-switch { text-align: center; font-size: 0.86rem; color: var(--muted); margin-top: 16px; }
.auth-switch a { color: var(--primary-600); font-weight: 650; }
.secondary-switch { margin-top: 6px; font-size: 0.82rem; }

/* ---------- Page-specific: dashboard ---------- */
.budget-list { display: flex; flex-direction: column; gap: 16px; }
.budget-item { display: flex; flex-direction: column; gap: 7px; }
.budget-item .b-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 0.85rem; }
.budget-item .b-meta span { color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.budget-item .b-meta strong { font-weight: 650; font-variant-numeric: tabular-nums; }

.tx-list { display: flex; flex-direction: column; }
.tx-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tx-row:last-child { border-bottom: 0; }
.tx-row .tx-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: 0 0 34px; }
.tx-row .tx-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tx-row .tx-main { min-width: 0; }
.tx-row .tx-title { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row .tx-sub { font-size: 0.76rem; color: var(--muted); }
.tx-row .tx-amt { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Page-specific: categories ---------- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.category-tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
}
.category-tile .c-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-100); color: var(--primary-600); font-weight: 700; font-size: 0.85rem; flex: 0 0 34px; }
.category-tile .c-ico.income { background: var(--teal-100); color: var(--teal); }
.category-tile .c-main { min-width: 0; }
.category-tile .c-name { font-weight: 650; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-tile .c-meta { font-size: 0.75rem; color: var(--muted); }
.category-tile .row-btn { margin-left: auto; }

.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary-700); background: var(--primary-100); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Page-specific: notifications ---------- */
.notif-list { display: flex; flex-direction: column; }
.notif-item { display: flex; gap: 13px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-item .n-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: 0 0 38px; }
.notif-item .n-ico svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.notif-item.read { opacity: 0.62; }
.notif-item .n-body { min-width: 0; }
.notif-item .n-title { font-weight: 650; font-size: 0.92rem; display: flex; align-items: center; gap: 8px; }
.notif-item .n-text { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.notif-item .n-time { font-size: 0.75rem; color: var(--faint); margin-top: 4px; }

/* ---------- Page-specific: support ---------- */
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-list details { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); padding: 0; overflow: hidden; }
.faq-list summary { cursor: pointer; padding: 13px 16px; font-weight: 650; font-size: 0.9rem; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; color: var(--muted); font-weight: 600; }
.faq-list details[open] summary::after { content: "–"; }
.faq-list details p { padding: 0 16px 14px; color: var(--muted); font-size: 0.87rem; }

/* ---------- Page-specific: reports ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box canvas { max-height: 100%; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.right { margin-left: auto; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.hide-sm { display: initial; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side { grid-template-columns: 1fr; }
}

@media (max-width: 1080px) {
  .sidebar { transform: translateX(-104%); transition: transform 0.24s ease; box-shadow: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar-toggle { display: inline-grid; }
  .hero { grid-template-columns: 1fr; gap: 34px; padding-top: 44px; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .content { padding: 20px 16px 56px; }
  .topbar { padding: 10px 16px; }
  .topbar-sub { display: none; }
  .card-head { flex-wrap: wrap; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .feature-grid { grid-template-columns: 1fr; }
  .preview-stats { grid-template-columns: 1fr; }
  .hero { padding-top: 34px; }
  .hide-sm { display: none; }
  .landing-nav .l-links { display: none; }
  .columns-chart { height: 140px; gap: 12px; }
}

@media (max-width: 640px) {
  .topbar-actions { gap: 6px; }
  .topbar-actions [data-refresh] { display: none; }
}
