/* ============================================================
   Dev Finance — design system (mobile-first)
   Palette is taken from the Dev Finance logo: royal blue, gold, emerald.
   ============================================================ */

:root,
:root[data-theme='light'] {
  --bg: #f2f6fd;
  --bg-grad: radial-gradient(1200px 500px at 85% -10%, rgba(47, 107, 255, 0.10), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(245, 163, 0, 0.09), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f6f8fd;
  --surface-3: #eaeff9;
  --border: #e1e7f3;
  --border-strong: #cdd6e8;
  --text: #0d1630;
  --text-2: #36425f;
  --muted: #5d6a88;
  --primary: #2563f5;
  --primary-hover: #1b50d6;
  --primary-soft: rgba(37, 99, 245, 0.10);
  --primary-ink: #ffffff;
  --gold: #f5a300;
  --gold-soft: rgba(245, 163, 0, 0.14);
  --success: #0b9b6a;
  --success-soft: rgba(11, 155, 106, 0.12);
  --danger: #dc3a40;
  --danger-soft: rgba(220, 58, 64, 0.10);
  --warn: #c77d00;
  --warn-soft: rgba(245, 163, 0, 0.16);
  --shadow-sm: 0 1px 2px rgba(16, 28, 66, 0.06), 0 1px 1px rgba(16, 28, 66, 0.04);
  --shadow: 0 8px 24px -10px rgba(16, 28, 66, 0.18), 0 2px 6px rgba(16, 28, 66, 0.05);
  --shadow-lg: 0 24px 60px -20px rgba(16, 28, 66, 0.35);
  --hero-from: #1747d1;
  --hero-to: #3b82ff;
  --overlay: rgba(9, 16, 38, 0.5);
  --grid: #e6ebf5;
  --focus: 0 0 0 3px rgba(37, 99, 245, 0.28);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #070d1c;
  --bg-grad: radial-gradient(1000px 500px at 90% -10%, rgba(59, 130, 255, 0.16), transparent 60%),
    radial-gradient(800px 420px at -10% 0%, rgba(245, 163, 0, 0.08), transparent 55%);
  --surface: #0e1630;
  --surface-2: #121c3b;
  --surface-3: #18244a;
  --border: #1d2a52;
  --border-strong: #2a3a6c;
  --text: #ecf1ff;
  --text-2: #c5d0ee;
  --muted: #94a3c8;
  --primary: #5b8cff;
  --primary-hover: #7aa2ff;
  --primary-soft: rgba(91, 140, 255, 0.16);
  --primary-ink: #04112e;
  --gold: #ffb829;
  --gold-soft: rgba(255, 184, 41, 0.16);
  --success: #2dd4a0;
  --success-soft: rgba(45, 212, 160, 0.14);
  --danger: #ff6b70;
  --danger-soft: rgba(255, 107, 112, 0.14);
  --warn: #ffb829;
  --warn-soft: rgba(255, 184, 41, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, 0.8);
  --hero-from: #1b3a9e;
  --hero-to: #2f63e8;
  --overlay: rgba(0, 4, 16, 0.66);
  --grid: #1a2650;
  --focus: 0 0 0 3px rgba(91, 140, 255, 0.4);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}

p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.num, .money { font-variant-numeric: tabular-nums; }
.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; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; display: flex; }

.sidebar {
  display: none;
  position: sticky;
  top: 0;
  height: 100dvh;
  width: 260px;
  flex: none;
  flex-direction: column;
  gap: 6px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 14px; color: inherit; text-decoration: none !important; }
.brand-logo { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none; background: #010205; box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); }
.brand-name { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 600; font-size: 14.5px; text-decoration: none !important; transition: background 0.15s, color 0.15s;
}
.nav-link svg { width: 19px; height: 19px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.topbar .brand { padding: 0; gap: 10px; }
.topbar .brand-logo { width: 38px; height: 38px; }
.topbar .brand-name { font-size: 17px; }
.topbar-spacer { flex: 1; }

.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); flex: 1; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr 1fr 74px 1fr 1fr; align-items: end;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px -18px rgba(10, 20, 60, 0.4);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; padding: 4px 2px; border: 0; background: none; color: var(--muted);
  font-size: 11px; font-weight: 600; text-decoration: none !important; border-radius: 12px;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--primary); }
.bn-fab-wrap { display: flex; justify-content: center; }
.bn-fab {
  width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; border: 4px solid var(--bg);
  display: grid; place-items: center; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  box-shadow: 0 10px 24px -6px rgba(37, 99, 245, 0.7);
}
.bn-fab svg { width: 26px; height: 26px; }
.bn-fab:active { transform: scale(0.95); }

/* ---------- Cards, grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { font-size: 16px; }
.card-sub { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* hero balance */
.hero {
  position: relative; overflow: hidden; color: #fff; border: 0; border-radius: 22px; padding: 20px 18px;
  background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
  box-shadow: 0 22px 50px -22px rgba(30, 80, 220, 0.75);
}
.hero::before { content: ''; position: absolute; right: -60px; top: -80px; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 184, 41, 0.55), transparent 65%); }
.hero::after { content: ''; position: absolute; left: -40px; bottom: -90px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 65%); }
.hero > * { position: relative; z-index: 1; }
.hero-label { font-size: 13px; opacity: 0.85; font-weight: 600; }
.hero-amount { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-weight: 800; font-size: clamp(28px, 8vw, 40px); letter-spacing: -0.03em; margin: 4px 0 14px; overflow-wrap: anywhere; }
.hero-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-mini > div { background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 14px; padding: 10px 12px; backdrop-filter: blur(6px); }
.hero-mini .l { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.hero-mini .v { font-weight: 800; font-size: 15.5px; margin-top: 2px; overflow-wrap: anywhere; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-ico svg { width: 19px; height: 19px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-value { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-weight: 800; font-size: 21px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; width: fit-content; }
.delta.good { background: var(--success-soft); color: var(--success); }
.delta.bad { background: var(--danger-soft); color: var(--danger); }
.delta.flat { background: var(--surface-3); color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 14.5px; transition: transform 0.08s, background 0.15s, border-color 0.15s; text-decoration: none !important; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; border-color: transparent; box-shadow: 0 10px 22px -10px rgba(37, 99, 245, 0.75); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.gold { background: linear-gradient(135deg, #ffb829, #f59f00); color: #2b1d00; border-color: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn.icon { width: 44px; padding: 0; }
.btn.icon.sm { width: 36px; }
.btn.block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; appearance: none; -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.select {
  padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d89a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.8; }
.input[aria-invalid='true'], .select[aria-invalid='true'] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.field-hint { color: var(--muted); font-size: 12.5px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.input-affix { position: relative; }
.input-affix .affix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.input-affix .input { padding-left: 38px; }
.amount-input { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-weight: 800; font-size: 26px !important; min-height: 58px; }
.checkbox { display: flex; align-items: center; gap: 10px; min-height: 40px; font-weight: 600; font-size: 14.5px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 4px; }

.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-3); border-radius: 14px; width: 100%; }
.seg button { flex: 1; min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed='true'], .seg button[aria-checked='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.income button[aria-checked='true'] { color: var(--success); }
.seg.expense button[aria-checked='true'] { color: var(--danger); }
.seg.transfer button[aria-checked='true'] { color: var(--primary); }

/* tags/chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 10px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: 12.5px; font-weight: 600; border: 0; }
.chip button { border: 0; background: none; padding: 0; display: grid; place-items: center; color: inherit; opacity: 0.7; }
.chip svg { width: 13px; height: 13px; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--primary-soft); color: var(--primary); }
.chip.on { background: var(--primary); color: var(--primary-ink); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--success-soft); color: var(--success); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--primary-soft); color: var(--primary); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Progress ---------- */
.progress { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--hero-from), var(--hero-to)); transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.progress.warn > span { background: linear-gradient(90deg, #f59f00, #ffb829); }
.progress.over > span { background: linear-gradient(90deg, #d92d34, #ff6b70); }
.progress.good > span { background: linear-gradient(90deg, #0b9b6a, #2dd4a0); }

/* ---------- Lists / transactions ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row.click { cursor: pointer; border-radius: 12px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.list-row.click:hover { background: var(--surface-2); }
.avatar { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 15px; color: #fff; }
.avatar svg { width: 20px; height: 20px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 14.5px; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.row-amt { text-align: right; font-weight: 800; font-size: 15px; flex: none; max-width: 42%; overflow-wrap: anywhere; }
.row-amt small { display: block; font-weight: 600; font-size: 11.5px; color: var(--muted); }
.date-head { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 14px 0 4px; display: flex; justify-content: space-between; gap: 10px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }

/* empty */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 34px 18px; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .ico svg { width: 30px; height: 30px; }
.empty h3 { color: var(--text); font-size: 17px; }
.empty p { max-width: 420px; font-size: 14px; }

/* insights */
.insight { display: flex; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.insight .ii { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.insight .ii svg { width: 18px; height: 18px; }
.insight.good .ii { background: var(--success-soft); color: var(--success); }
.insight.warn .ii { background: var(--warn-soft); color: var(--warn); }
.insight.bad .ii { background: var(--danger-soft); color: var(--danger); }
.insight.info .ii { background: var(--primary-soft); color: var(--primary); }
.insight b { display: block; font-size: 14px; }
.insight span { font-size: 13px; color: var(--muted); }

/* notice banners */
.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; align-items: flex-start; background: var(--primary-soft); color: var(--text-2); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); }
.notice svg { width: 20px; height: 20px; flex: none; color: var(--primary); margin-top: 1px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.notice.warn svg { color: var(--warn); }
.notice.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.bad svg { color: var(--danger); }
.notice.good { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.notice.good svg { color: var(--success); }
.notice b { color: var(--text); }

/* filters */
.filter-bar { display: flex; flex-direction: column; gap: 10px; }
.search { position: relative; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 40px; }
.scroll-x { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-x > * { flex: none; }

/* ---------- Modal / bottom sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-height: 94dvh; display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg); animation: sheet 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-grip { width: 42px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 8px; flex: none; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 18px 18px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal.sm { max-width: 440px; }
.modal.md { max-width: 560px; }
.modal.lg { max-width: 760px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 14px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 460px; width: 100%; padding: 12px 14px; border-radius: 14px; background: #0f1a3c; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600; animation: rise 0.25s ease both; border: 1px solid rgba(255, 255, 255, 0.1); }
:root[data-theme='dark'] .toast { background: #1b2a5a; }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.success svg { color: #2dd4a0; }
.toast.error svg { color: #ff6b70; }
.toast.info svg { color: #7aa2ff; }
.toast button { margin-left: auto; background: none; border: 0; color: #ffb829; font-weight: 800; }

/* ---------- Calculator ---------- */
.calc { display: flex; flex-direction: column; gap: 12px; }
.calc-screen { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; min-height: 104px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; gap: 4px; overflow: hidden; }
.calc-expr { font-size: 15px; color: var(--muted); min-height: 22px; max-width: 100%; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.calc-result { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-weight: 800; font-size: clamp(30px, 9vw, 42px); letter-spacing: -0.03em; max-width: 100%; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.calc-result.err { color: var(--danger); font-size: 18px; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.ck { min-height: 58px; border-radius: 16px; border: 0; background: var(--surface-3); color: var(--text); font-size: 21px; font-weight: 700; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; display: grid; place-items: center; transition: transform 0.06s, filter 0.15s; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.ck:active { transform: scale(0.94); }
.ck.op { background: var(--primary-soft); color: var(--primary); }
.ck.fn { background: var(--gold-soft); color: var(--warn); }
.ck.eq { background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; }
.ck svg { width: 22px; height: 22px; }
.calc-use { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.calc-history { display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow-y: auto; }
.calc-history button { display: flex; justify-content: space-between; gap: 10px; border: 0; background: none; color: var(--muted); font-size: 13px; padding: 6px 4px; border-radius: 8px; text-align: left; }
.calc-history button:hover { background: var(--surface-2); color: var(--text); }

.fab-calc { position: fixed; right: 14px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 35; width: 52px; height: 52px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--primary); display: grid; place-items: center; box-shadow: var(--shadow); }
.fab-calc svg { width: 24px; height: 24px; }

/* ---------- Charts ---------- */
.chart-box { width: 100%; height: 240px; }
.chart-box.tall { height: 300px; }
.chart-box.short { height: 180px; }
.chart-tip { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 13px; min-width: 150px; }
.chart-tip .t { font-weight: 800; margin-bottom: 6px; }
.chart-tip .r { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.donut-wrap { position: relative; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center b { display: block; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 18px; }
.donut-center span { font-size: 12px; color: var(--muted); }

/* ---------- Misc ---------- */
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface); font-weight: 700; font-size: 13.5px; }
.theme-opt svg { width: 22px; height: 22px; }
.theme-opt[aria-checked='true'] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv b { text-align: right; overflow-wrap: anywhere; }
.color-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 10px; border: 3px solid transparent; padding: 0; }
.swatch[aria-pressed='true'] { border-color: var(--text); }
.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 3px; }
.month-nav strong { min-width: 118px; text-align: center; font-size: 14px; }
.hr { height: 1px; background: var(--border); border: 0; margin: 14px 0; }
.legal h2 { font-size: 18px; margin: 26px 0 8px; }
.legal h3 { font-size: 15px; margin: 16px 0 6px; }
.legal p, .legal li { color: var(--text-2); font-size: 14.5px; line-height: 1.7; }
.legal p + p { margin-top: 10px; }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal .updated { color: var(--muted); font-size: 13px; margin-top: 6px; }

.footer { border-top: 1px solid var(--border); background: var(--surface); padding: 24px 16px calc(100px + env(safe-area-inset-bottom)); }
.footer-inner { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; grid-template-columns: 1fr; }
.footer .brand { padding: 0; }
.footer h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.footer a { display: block; padding: 5px 0; color: var(--text-2); font-weight: 600; font-size: 14px; }
.footer .legal-line { grid-column: 1 / -1; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; }

/* Onboarding / splash */
.splash { min-height: 100dvh; display: grid; place-items: center; }
.splash img { width: 96px; height: 96px; border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: 0.85; } }
.onboard { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(20px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom)); }
.onboard-card { width: 100%; max-width: 520px; padding: 22px 18px; border-radius: 26px; box-shadow: var(--shadow-lg); }
.onboard-logo { width: 112px; height: 112px; border-radius: 50%; margin: 0 auto 10px; box-shadow: 0 0 0 1px var(--border), 0 14px 40px -14px rgba(245, 163, 0, 0.6); background: #010205; object-fit: cover; }
.steps { display: flex; gap: 6px; justify-content: center; margin: 4px 0 16px; }
.steps i { width: 26px; height: 5px; border-radius: 99px; background: var(--surface-3); }
.steps i.on { background: var(--primary); }
.cur-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 280px; overflow-y: auto; padding: 2px; }
.cur-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); text-align: left; min-height: 56px; }
.cur-opt[aria-checked='true'] { border-color: var(--primary); background: var(--primary-soft); }
.cur-opt .sym { font-weight: 800; font-size: 16px; min-width: 32px; }
.cur-opt .nm { font-size: 12px; color: var(--muted); line-height: 1.2; }
.cur-opt b { display: block; font-size: 14px; }

.storage-banner { margin: 10px 14px 0; }
.kebab-menu { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 170px; padding: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); }
.kebab-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px; border: 0; background: none; border-radius: 10px; font-weight: 600; font-size: 14px; text-align: left; }
.kebab-menu button svg { width: 17px; height: 17px; color: var(--muted); }
.kebab-menu button:hover { background: var(--surface-2); }
.kebab-menu button.danger, .kebab-menu button.danger svg { color: var(--danger); }
.rel { position: relative; }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 640px) {
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .footer-inner { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
  .filter-bar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 24px; max-height: 90dvh; padding-bottom: 0; }
  .modal-grip { display: none; }
  .modal-head { padding: 18px 22px 8px; }
  .modal-body { padding: 8px 22px 22px; }
  .page { padding: 22px 22px 40px; }
  .page-head h1 { font-size: 28px; }
}

@media (min-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .grid.main-side { grid-template-columns: 1.65fr 1fr; align-items: start; }
  .toasts { bottom: 24px; }
}

@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .bottomnav, .fab-calc { display: none; }
  .topbar:not(.always) { display: none; }
    .page { padding: 28px 32px 48px; }
  .footer { padding-bottom: 28px; }
  .card { padding: 20px; }
  .overlay { align-items: center; }
}


@media (max-width: 1023px) {
  .desktop-only { display: none !important; }
}
@media (min-width: 1024px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 380px) {
  .ck { min-height: 52px; font-size: 19px; }
  .stat-value { font-size: 18px; }
  .month-nav strong { min-width: 96px; }
}

@media print {
  .sidebar, .bottomnav, .topbar, .fab-calc, .footer, .toasts, .head-actions, .btn { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
}

/* ============================================================
   Static-site additions
   ============================================================ */
svg.i { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.gold { color: var(--gold); }
.stat-ico svg.i { width: 19px; height: 19px; vertical-align: 0; }
.avatar svg.i { width: 20px; height: 20px; vertical-align: 0; }
.bn-item svg.i { width: 22px; height: 22px; }
.nav-link svg.i { width: 19px; height: 19px; }
.empty .ico svg.i { width: 30px; height: 30px; vertical-align: 0; }
.notice svg.i { width: 20px; height: 20px; }
.insight .ii svg.i { width: 18px; height: 18px; vertical-align: 0; }
.fab-calc svg.i { width: 24px; height: 24px; vertical-align: 0; }
.bn-fab svg.i { width: 26px; height: 26px; vertical-align: 0; }
button.bn-item { border: 0; background: none; font-family: inherit; cursor: pointer; }
button.nav-link { font-family: inherit; }
.grow { flex: 1; }
.narrow { max-width: 640px; margin-inline: auto; width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.seg button svg.i { width: 16px; height: 16px; vertical-align: 0; }
.seg.wrap-seg { flex-wrap: wrap; }
.seg.wrap-seg button { flex: 1 1 45%; }
.seg3 button { padding: 0 6px; }
.dot.lg { width: 14px; height: 14px; }
.linklike { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.footer .foot-link { display: block; padding: 5px 0; color: var(--text-2); font-weight: 600; font-size: 14px; text-decoration: none; }
.footer .foot-link:hover { color: var(--primary); }
.footer a:hover { color: var(--primary); }
.chip { font-family: inherit; }
.chip.removable { padding-right: 4px; }
.chip.removable button { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; }
.chip.removable button:hover { background: var(--danger-soft); color: var(--danger); opacity: 1; }
.cat-chip { min-height: 36px; padding: 0 12px; font-size: 13.5px; border: 1px solid var(--border); background: var(--surface); }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; max-width: 420px; }
.month-label { flex: 1; text-align: center; font-weight: 800; font-size: 16px; }
.amount-row { display: flex; align-items: center; gap: 8px; }
.amount-row .cur-sym { font-weight: 800; font-size: 20px; color: var(--muted); min-width: 22px; text-align: center; }
.input.amount { font-size: 24px; font-weight: 800; min-height: 54px; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.due.overdue .row-title { color: var(--danger); }
.dim { opacity: 0.55; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.file-btn { cursor: pointer; }
.sent-card { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.hero-note { font-size: 12.5px; opacity: 0.85; margin-top: 4px; }
.stack.narrow > .card { width: 100%; }
.stack.narrow > .stack { width: 100%; }
details summary { cursor: pointer; }
.goal h3 { font-weight: 800; }
.card.click, button.card { font: inherit; color: inherit; width: 100%; }
.list-row.click:focus-visible { box-shadow: var(--focus); }

/* charts */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; max-height: 300px; touch-action: manipulation; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 12.5px; font-family: inherit; }
.chart .b-inc { fill: var(--success); }
.chart .b-exp { fill: var(--danger); }
.chart .a-inc { fill: var(--success); opacity: 0.12; }
.chart .a-exp { fill: var(--danger); opacity: 0.12; }
.chart .l-inc { fill: none; stroke: var(--success); stroke-width: 2.2; stroke-linejoin: round; }
.chart .l-exp { fill: none; stroke: var(--danger); stroke-width: 2.2; stroke-linejoin: round; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bg:hover .hit, .chart rect.hit:hover { fill: var(--primary-soft); }
.chart-tipline { margin-top: 6px; min-height: 20px; font-size: 13px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.donut-wrap { position: relative; width: min(220px, 70vw); aspect-ratio: 1; margin: 0 auto; }
.donut-wrap svg { width: 100%; height: 100%; display: block; }
.donut-center b { display: block; font-size: 16px; font-weight: 800; overflow-wrap: anywhere; padding: 0 30px; }
.legend .dot { width: 10px; height: 10px; }

/* calculator */
.calc-display { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 12px 16px; min-height: 118px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; gap: 2px; overflow: hidden; margin-bottom: 12px; }
.calc-hist { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; max-width: 100%; }
.calc-hist span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-expr { font-family: inherit; font-weight: 800; font-size: clamp(26px, 8vw, 36px); letter-spacing: -0.02em; color: var(--text); max-width: 100%; overflow-x: auto; white-space: nowrap; scrollbar-width: none; min-height: 40px; }
.calc-res { min-height: 22px; font-size: 16px; color: var(--muted); font-weight: 700; }
.calc-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }

/* onboarding */
.ob-hero { text-align: center; margin-bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ob-hero img { box-shadow: 0 0 0 1px var(--border), 0 14px 40px -14px rgba(245, 163, 0, 0.6); background: #010205; }
.ob-hero h1 { font-size: 30px; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin: 0 0 16px; }
.ob-dot { width: 26px; height: 5px; border-radius: 99px; background: var(--surface-3); }
.ob-dot.on { background: var(--primary); }
.ob-dot.done { background: var(--success); }
.onboard-card { background: var(--surface); border: 1px solid var(--border); }
.cur-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 46dvh; overflow-y: auto; padding: 2px; }
.cur-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); text-align: left; min-height: 58px; color: var(--text); font-family: inherit; }
.cur-item.on { border-color: var(--primary); background: var(--primary-soft); }
.cur-item > b { font-size: 16px; min-width: 30px; }
.cur-item small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.cur-item svg.i { margin-left: auto; color: var(--primary); }
.ob-acc { padding: 12px; }
#app > .splash { min-height: 100dvh; display: grid; place-items: center; }
.splash img { width: 96px; height: 96px; border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); opacity: 0.85; } }
noscript p { padding: 24px; text-align: center; }

@media (min-width: 640px) {
  .cur-list { grid-template-columns: 1fr 1fr 1fr; }
  .seg.wrap-seg button { flex: 1; }
}
@media (min-width: 900px) {
  .chart svg { max-height: 340px; }
}
@media (max-width: 380px) {
  .cur-list { grid-template-columns: 1fr; }
}
[hidden] { display: none !important; }

@media (max-width: 639px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid.cols-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-value { font-size: 19px; }
}

body.modal-open .toasts { bottom: auto; top: calc(12px + env(safe-area-inset-top)); }

@media (max-width: 639px) {
  .table { font-size: 12.5px; }
  .table th { padding: 8px 6px; font-size: 11px; letter-spacing: 0.02em; }
  .table td { padding: 10px 6px; }
  .table td.r, .table th.r { white-space: nowrap; }
  .card:has(> .table-wrap) { padding: 10px; }
}

.toast { padding: 10px 14px; font-size: 13.5px; }
