/* Capsynthesis Finance — visual redesign */

:root {
  color-scheme: dark;
  --bg-0: #050505;
  --bg-1: #0a0a0a;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-solid: #111111;
  --surface-hover: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.1);
  --text: #ffffff;
  --text-dim: #e2e2ea;
  --muted: #8a8a93;
  --mint: #2ecc71;
  --cyan: #12c2e9;
  --violet: #c471ed;
  --green: #2ecc71;
  --red: #ff4757;
  --amber: #f39c12;
  --gradient-primary: linear-gradient(135deg, #c471ed 0%, #12c2e9 100%);
  --gradient-violet: linear-gradient(135deg, #a78bfa 0%, #f0abfc 100%);
  --gradient-warm: linear-gradient(135deg, #ff4757 0%, #f39c12 100%);
  --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.2);
  --shadow-elev: 0 10px 30px rgba(0, 0, 0, 0.5);
  --tabbar-h: 68px;
  --radius-card: 28px;
  --radius-row: 20px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-0: #f2f2f7;
  --bg-1: #e5e5ea;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-2: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-hover: rgba(255, 255, 255, 1);
  --line: rgba(0, 0, 0, 0.05);
  --line-strong: rgba(0, 0, 0, 0.1);
  --text: #1c1c1e;
  --text-dim: #3a3a3c;
  --muted: #8e8e93;
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.05);
  --shadow-elev: 0 24px 60px rgba(0, 0, 0, 0.1);
}

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

html, body { margin: 0; min-height: 100vh; overflow-x: hidden; }

body {
  background: var(--bg-0);
  color: var(--text);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* Animated Ambient Background */
.ambient-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-0);
    transition: background 0.3s ease;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: floatOrb 20s infinite ease-in-out alternate;
}
[data-theme="light"] .ambient-orb {
    opacity: 0.6;
    filter: blur(100px);
}

.orb-1 { top: -10%; left: -10%; width: 300px; height: 300px; background: var(--violet); animation-delay: 0s; }
.orb-2 { bottom: 20%; right: -10%; width: 250px; height: 250px; background: var(--cyan); animation-delay: -5s; }
.orb-3 { top: 40%; left: 40%; width: 200px; height: 200px; background: var(--red); opacity: 0.2; animation-delay: -10s; }

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, 50px) scale(1.1); }
    100% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Typography */
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tnum { font-variant-numeric: tabular-nums; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }
.hidden, [hidden] { display: none !important; }

/* Bootstrap loader */
.bootstrap { display: grid; place-items: center; min-height: 100vh; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--mint);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell ---------- */
.app-root { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px); }

#pageRoot {
  border-radius: 26px 26px 0 0;
  overflow: clip;
  background: var(--bg-0);
  min-height: 100vh;
}

.app-main {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 0 16px 8px;
  animation: viewIn 0.32s var(--ease);
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  position: sticky; top: 0; z-index: 12;
  display: flex; align-items: flex-end; justify-content: space-between;
  margin: 0 -4px 18px;
  padding: 20px 8px 12px;
  background: linear-gradient(180deg, var(--bg-0) 40%, rgba(8, 9, 15, 0.56) 80%, rgba(8, 9, 15, 0));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
[data-theme="light"] .page-head {
  background: linear-gradient(180deg, var(--bg-0) 40%, rgba(242, 242, 247, 0.58) 80%, rgba(242, 242, 247, 0));
}
.page-head h1 { font-size: 26px; }
.page-head .chip { margin-bottom: 4px; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.btn-secondary.compact {
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
}

/* ---------- Tabbar (floating, glassy) ---------- */
.tabbar {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  height: 60px;
  border-radius: 32px;
  background: rgba(15, 15, 15, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 20;
  padding: 8px 12px;
}
[data-theme="light"] .tabbar {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.tabbar button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 0; background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 22px;
  transition: all 0.3s ease;
}
.tabbar button svg { width: 22px; height: 22px; stroke-width: 1.8; stroke: currentColor; fill: none; }
.tabbar button small { display: none; }
.tabbar button:hover { color: var(--text); }
.tabbar button.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
[data-theme="light"] .tabbar button.active {
  background: rgba(0, 0, 0, 0.05);
}

/* ---------- Cards / panels ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; color: var(--text-dim); font-weight: 600; }

/* Hero / Balance Card */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-card); padding: 32px 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  color: var(--text);
  backdrop-filter: blur(20px);
}
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(196, 113, 237, 0.2) 0%, rgba(18, 194, 233, 0.1) 100%);
  z-index: -1;
}
[data-theme="light"] .hero::before {
  background: linear-gradient(135deg, rgba(196, 113, 237, 0.15) 0%, rgba(18, 194, 233, 0.05) 100%);
}
.hero .eyebrow { font-size: 14px; color: rgba(255, 255, 255, 0.7); display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
[data-theme="light"] .hero .eyebrow { color: var(--muted); }
.hero h2 {
  font-size: clamp(32px, 8.5vw, 42px); font-weight: 700; letter-spacing: -1px;
  margin-bottom: 16px;
  background: linear-gradient(to right, #fff, #e0e0e0);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .hero h2 {
  background: linear-gradient(to right, #000, #333);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.hero-stats > div {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
[data-theme="light"] .hero-stats > div {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.hero-stats span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.hero-stats strong { font-size: 14px; font-weight: 600; }

/* KPI bento */
.kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 14px;
}
.kpi-card {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
}
.kpi-card .icon {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  margin-bottom: 10px;
}
.kpi-card .icon svg { width: 16px; height: 16px; stroke-width: 2; fill: none; }
.kpi-card.income .icon { background: rgba(74, 222, 128, 0.14); color: var(--green); }
.kpi-card.expense .icon { background: rgba(248, 113, 113, 0.14); color: var(--red); }
.kpi-card.neutral .icon { background: rgba(94, 234, 212, 0.14); color: var(--mint); }
.kpi-card.violet .icon { background: rgba(167, 139, 250, 0.14); color: var(--violet); }
.kpi-card span.label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-card strong { display: block; font-size: 20px; margin-top: 4px; font-weight: 700; letter-spacing: -0.01em; }
.kpi-card.income strong { color: var(--green); }
.kpi-card.expense strong { color: var(--red); }

/* ---------- Dashboard greeting header ---------- */
.dash-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 16px;
}
.dash-user { display: flex; align-items: center; gap: 12px; }
.dash-avatar {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  padding: 2px;
}
.dash-avatar-inner {
  width: 100%; height: 100%; background: var(--bg-0); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.dash-greet p { font-size: 12px; color: var(--muted); margin-bottom: 1px; }
.dash-greet h2 { font-size: 17px; font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer; transition: background 0.2s;
  backdrop-filter: blur(10px);
}
.icon-btn:hover { background: var(--surface-hover); }

/* ---------- Balance card (concept style) ---------- */
.balance-card {
  position: relative; overflow: hidden;
  border-radius: 28px; padding: 28px 24px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  margin-bottom: 20px;
  backdrop-filter: blur(20px);
}
.balance-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(196,113,237,0.2) 0%, rgba(18,194,233,0.1) 100%);
  z-index: 0; pointer-events: none;
}
.balance-card > * { position: relative; z-index: 1; }
.balance-label {
  font-size: 14px; color: rgba(255,255,255,0.7);
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
}
[data-theme="light"] .balance-label { color: var(--muted); }
.balance-amount {
  font-size: clamp(32px, 9vw, 44px); font-weight: 700; letter-spacing: -1.5px;
  margin-bottom: 16px;
  background: linear-gradient(to right, #fff, #d0d0d0);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .balance-amount {
  background: linear-gradient(to right, #111, #444);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.balance-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.balance-stats .stat {
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.06);
  padding: 7px 12px; border-radius: 12px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
[data-theme="light"] .balance-stats .stat { background: rgba(255,255,255,0.5); border-color: rgba(0,0,0,0.06); }
.balance-stats .stat.positive { color: var(--green); }
.balance-stats .stat.negative { color: var(--red); }
.balance-stats .stat.neutral { color: var(--muted); }

/* ---------- Section header (like concept) ---------- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 12px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }
.btn-link {
  background: none; border: none; padding: 0;
  color: var(--cyan); font-size: 14px; font-weight: 500; cursor: pointer;
  font-family: inherit;
}
.tx-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }

/* ---------- Quick Actions ---------- */
.quick-actions {
  display: flex; justify-content: space-between; gap: 10px; margin-bottom: 24px;
}
.action-btn {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 14px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--text); font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background 0.2s, transform 0.2s; backdrop-filter: blur(10px);
  font-family: inherit;
}
.action-btn:active { transform: scale(0.95); background: var(--surface-hover); }
.action-icon {
  width: 46px; height: 46px; border-radius: 15px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}

/* List items */
.list { display: grid; gap: 8px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.list-item:hover { background: var(--surface-hover); }
.list-item:active { opacity: 0.75; }
@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.l-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.l-icon {
  width: 42px; height: 42px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
[data-theme="light"] .l-icon { background: rgba(0, 0, 0, 0.05); }
.l-icon svg { width: 20px; height: 20px; stroke-width: 1.8; fill: none; }
.l-icon.income { background: rgba(46, 204, 113, 0.15); color: var(--green); }
.l-icon.expense { background: rgba(255, 71, 87, 0.15); color: var(--red); }
.l-icon.violet { background: rgba(167, 139, 250, 0.15); color: var(--violet); }
.l-icon.mint { background: rgba(46, 204, 113, 0.12); color: var(--mint); }
.l-text { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.l-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-meta { color: var(--muted); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-right { text-align: right; flex-shrink: 0; }
.l-amount { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.l-amount.income { color: var(--green); }
.l-amount.expense { color: var(--text); }
.l-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.amount-pos { color: var(--green); }
.amount-neg { color: var(--text); }

/* Category icon used in transaction cards */
.cat-ico {
  width: 42px; height: 42px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cat-ico svg { width: 20px; height: 20px; stroke-width: 1.8; fill: none; }
.cat-ico-sm { width: 28px; height: 28px; border-radius: 9px; }
.cat-ico-sm svg { width: 15px; height: 15px; }

.empty {
  padding: 28px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.empty-rich {
  padding: 32px 20px; text-align: center; color: var(--text-dim);
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-art {
  width: 64px; height: 64px;
  color: var(--muted);
  margin-bottom: 8px;
}
.empty-art svg { width: 100%; height: 100%; }
.empty-rich h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.empty-rich p { margin: 0; }
.empty-rich .empty-cta { margin-top: 12px; }

/* Category breakdown rows */
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .name { font-weight: 600; font-size: 14px; }
.cat-row .val { font-weight: 700; }
.cat-row .bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.cat-row .bar span { display: block; height: 100%; border-radius: inherit; background: var(--gradient-primary); }

/* Progress */
.progress {
  height: 8px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.progress span {
  display: block; height: 100%;
  background: var(--gradient-primary);
  border-radius: inherit;
  transition: width 0.5s var(--ease);
}
.progress.violet span { background: var(--gradient-violet); }
.progress.danger span { background: linear-gradient(135deg, #f87171, #fb923c); }

/* Goal item style */
.goal-card { padding: 14px; }
.goal-card .goal-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.goal-card .goal-name { font-weight: 700; font-size: 15px; }
.goal-card .goal-pct { font-weight: 800; background: var(--gradient-primary); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.goal-card .goal-meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 12px; }
.form label { display: flex; flex-direction: column; justify-content: flex-start; gap: 6px; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.form input, .form select, .form textarea {
  height: 46px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text); padding: 0 14px;
  font: inherit; font-size: 15px; letter-spacing: -0.005em;
  transition: border-color 0.22s var(--ease), background 0.22s var(--ease);
}
[data-theme="light"] .form input, [data-theme="light"] .form select, [data-theme="light"] .form textarea {
  background: rgba(15, 23, 42, 0.04);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--mint);
  background: rgba(94, 234, 212, 0.06);
}
.form textarea { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; }
.form .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }

.segmented {
  display: inline-flex; padding: 4px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.segmented button {
  padding: 9px 16px; border: 0; background: transparent;
  color: var(--muted); border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 13px;
  transition: background 0.22s var(--ease), color 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.segmented button.active {
  background: var(--gradient-primary);
  color: #052e2a;
  box-shadow: 0 4px 14px rgba(94, 234, 212, 0.35);
}

.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  height: 46px; border: 0; border-radius: 12px;
  cursor: pointer; font: inherit; font-weight: 700; font-size: 14px;
  padding: 0 18px;
  transition: transform 0.18s var(--ease), opacity 0.22s var(--ease), box-shadow 0.22s var(--ease);
}
.btn-primary {
  background: var(--gradient-primary); color: #052e2a;
  box-shadow: 0 6px 18px rgba(94, 234, 212, 0.32);
}
.btn-primary:hover { box-shadow: 0 10px 24px rgba(94, 234, 212, 0.4); }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-secondary:active { transform: scale(0.97); }
.btn-danger {
  background: rgba(248, 113, 113, 0.12); color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.32);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 600; padding: 0 8px; }

/* Floating action button */
.fab {
  position: fixed; right: 20px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 26px);
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--gradient-primary);
  color: #052e2a;
  box-shadow: 0 14px 36px rgba(94, 234, 212, 0.4), 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 15;
  display: grid; place-items: center;
  transition: transform 0.18s var(--ease), box-shadow 0.22s var(--ease);
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(94, 234, 212, 0.5), 0 4px 10px rgba(0, 0, 0, 0.2); }
.fab:active { transform: scale(0.93); }
.fab svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2.4; fill: none; }

/* Filters */
.filters {
  display: grid; gap: 8px; grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}
.filters .full { grid-column: 1 / -1; }
.filters select, .filters input {
  height: 40px; border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text); padding: 0 12px;
  font: inherit; font-size: 13px;
}
[data-theme="light"] .filters select, [data-theme="light"] .filters input {
  background: rgba(15, 23, 42, 0.04);
}

.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 16px; color: var(--muted); font-size: 13px;
}
.pager button {
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  cursor: pointer; font: inherit; font-weight: 600;
  transition: opacity 0.22s var(--ease);
}
.pager button:disabled { opacity: 0.32; cursor: default; }

/* ---------- Onboarding ---------- */
.onboarding {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center;
  padding: 18px;
  background: var(--bg-0);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ob-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.ob-orb {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.55;
  animation: obFloat 18s ease-in-out infinite;
}
.ob-orb-1 { width: 380px; height: 380px; left: -120px; top: -100px; background: radial-gradient(circle, #5eead4, transparent 70%); }
.ob-orb-2 { width: 420px; height: 420px; right: -140px; bottom: -120px; background: radial-gradient(circle, #a78bfa, transparent 70%); animation-delay: -6s; }
.ob-orb-3 { width: 320px; height: 320px; left: 40%; top: 30%; background: radial-gradient(circle, #38bdf8, transparent 70%); animation-delay: -12s; opacity: 0.35; }
@keyframes obFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 40px) scale(0.95); }
}

.onboarding-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 6vh auto 40px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  padding: 22px 22px 20px;
  display: grid; gap: 14px;
  box-shadow: var(--shadow-elev);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  animation: obCardIn 0.5s var(--ease);
}
@keyframes obCardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ob-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.ob-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ob-brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--gradient-primary);
  color: #06222a;
  box-shadow: 0 10px 24px rgba(94, 234, 212, 0.4);
  flex-shrink: 0;
}
.ob-brand-mark svg { width: 20px; height: 20px; }
.ob-brand-text { display: grid; line-height: 1.15; min-width: 0; }
.ob-brand-text strong { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-brand-text span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-step-counter {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  padding: 6px 10px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.ob-step-counter i { font-style: normal; color: var(--muted); margin: 0 2px; }

.onboarding-progress { display: flex; gap: 6px; }
.onboarding-progress i {
  flex: 1; height: 5px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.4s var(--ease), transform 0.4s var(--ease);
  position: relative; overflow: hidden;
}
.onboarding-progress i.done { background: var(--mint); }
.onboarding-progress i.on { background: var(--gradient-primary); transform: scaleY(1.15); }
.onboarding-progress i.on::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: obShimmer 1.6s linear infinite;
}
@keyframes obShimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.ob-hero {
  height: 110px; display: grid; place-items: center;
  color: var(--mint);
  background:
    radial-gradient(circle at 50% 50%, rgba(94, 234, 212, 0.18), transparent 65%);
  border-radius: 18px;
  position: relative;
  animation: obHeroIn 0.5s var(--ease);
}
.ob-hero[data-step="1"] { color: var(--cyan); background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.18), transparent 65%); }
.ob-hero[data-step="2"] { color: var(--violet); background: radial-gradient(circle at 50% 50%, rgba(167, 139, 250, 0.18), transparent 65%); }
.ob-hero svg { width: 88px; height: 88px; animation: obHeroFloat 4s ease-in-out infinite; }
@keyframes obHeroIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes obHeroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.onboarding-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.onboarding-card > .muted { font-size: 13.5px; line-height: 1.45; }

.ob-body { display: grid; gap: 12px; animation: obBodyIn 0.4s var(--ease); min-width: 0; }
@keyframes obBodyIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.ob-chip {
  display: inline-flex; align-self: flex-start;
  padding: 5px 11px; border-radius: var(--radius-pill);
  background: rgba(94, 234, 212, 0.12);
  border: 1px solid rgba(94, 234, 212, 0.25);
  color: var(--mint);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
}

.ob-cur-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 0;
}
.ob-cur {
  appearance: none; cursor: pointer; font: inherit;
  padding: 14px 6px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--line);
  color: var(--text);
  font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  transition: all 0.22s var(--ease);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ob-cur:hover { background: rgba(255, 255, 255, 0.07); }
.ob-cur.active {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.18), rgba(56, 189, 248, 0.12));
  border-color: var(--mint);
  color: var(--mint);
  box-shadow: 0 6px 18px rgba(94, 234, 212, 0.25);
  transform: translateY(-1px);
}

.ob-amount {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid var(--line-strong);
  border-radius: 16px;
  transition: border-color 0.22s var(--ease);
  min-width: 0;
}
.ob-amount:focus-within { border-color: var(--mint); box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.12); }
.ob-amount-cur {
  font-size: 13px; font-weight: 700; color: var(--muted);
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.ob-amount input {
  flex: 1; min-width: 0; width: 100%;
  background: transparent; border: none; outline: none;
  color: var(--text);
  font: inherit; font-size: 22px; font-weight: 700; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.ob-amount input::placeholder { color: var(--muted); font-weight: 500; }

.ob-hint {
  margin: 0; padding: 10px 12px;
  background: rgba(94, 234, 212, 0.06);
  border: 1px dashed rgba(94, 234, 212, 0.22);
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 12.5px; line-height: 1.45;
}

.ob-quick-label {
  font-size: 11.5px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: 2px;
}

.ob-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-quick-btn {
  appearance: none; cursor: pointer; font: inherit;
  padding: 8px 14px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: all 0.2s var(--ease);
}
.ob-quick-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); }
.ob-quick-btn.ghost { background: transparent; color: var(--muted); }

.ob-preset {
  appearance: none; cursor: pointer; font: inherit;
  flex: 1; min-width: 96px;
  display: grid; gap: 2px; padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px; font-weight: 600; text-align: left;
  transition: all 0.22s var(--ease);
}
.ob-preset small { font-size: 11px; color: var(--muted); font-weight: 500; }
.ob-preset:hover {
  background: rgba(94, 234, 212, 0.08);
  border-color: rgba(94, 234, 212, 0.3);
  transform: translateY(-1px);
}

.ob-form label { gap: 6px; }

.onboarding-nav { display: flex; gap: 10px; margin-top: 6px; min-width: 0; }
.onboarding-nav .btn-primary { flex: 1; padding-block: 14px; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.onboarding-nav .btn-secondary { min-width: 104px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 32px);
  transform: translateX(-50%);
  background: rgba(15, 18, 28, 0.95);
  border: 1px solid var(--line-strong);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600;
  z-index: 60; max-width: 90vw;
  box-shadow: var(--shadow-elev);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: toastIn 0.32s var(--ease);
  display: inline-flex; align-items: center; gap: 12px;
}
.toast button {
  appearance: none; cursor: pointer; border: 0;
  background: rgba(94, 234, 212, 0.14);
  color: var(--mint);
  border-radius: var(--radius-pill);
  padding: 7px 10px;
  font: inherit; font-size: 12px; font-weight: 800;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Inline actions in form */
.actions { display: flex; gap: 10px; margin-top: 6px; }
.actions .btn-primary, .actions .btn-secondary, .actions .btn-danger { flex: 1; }
/* Hide submit buttons when Telegram MainButton is shown to avoid duplicates */
body.tg-main-btn .actions .btn-primary { display: none; }

/* Confirm modal */
.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(5, 8, 14, 0.65); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px;
  animation: modalIn 0.22s var(--ease);
}
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(380px, 100%);
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 20px;
  display: grid; gap: 14px;
  box-shadow: var(--shadow-elev);
  animation: viewIn 0.28s var(--ease);
}

/* Chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-pill);
  background: rgba(94, 234, 212, 0.12);
  color: var(--mint);
  font-size: 12px; font-weight: 600;
  border: 1px solid rgba(94, 234, 212, 0.22);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.mini-grid > div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.mini-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}
.mini-grid strong { font-size: 16px; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.calendar-cell {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  font: inherit;
  cursor: pointer;
  line-height: 1.2;
}
.calendar-cell span { color: var(--muted); font-size: 11px; font-weight: 700; }
.calendar-cell b { font-size: 9px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.calendar-cell.pos { background: rgba(74, 222, 128, 0.11); border-color: rgba(74, 222, 128, 0.25); }
.calendar-cell.neg { background: rgba(248, 113, 113, 0.11); border-color: rgba(248, 113, 113, 0.25); }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.tool-grid .btn-secondary { width: 100%; padding: 0 10px; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 32px; height: 32px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
}
.swatch.active {
  border-color: var(--text);
  transform: scale(1.08);
}

/* ---------- FX: currency switcher + live rates ---------- */
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cur-switch {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
  padding: 4px; border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}
.cur-pill {
  appearance: none; cursor: pointer; font: inherit;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: transparent; border: none;
  color: var(--muted); font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em;
  transition: all 0.22s var(--ease);
}
.cur-pill:hover { color: var(--text-dim); }
.cur-pill.active {
  background: var(--gradient-primary);
  color: #06222a;
  box-shadow: 0 4px 14px rgba(94, 234, 212, 0.35);
}

.fx-strip { padding: 16px 16px 14px; margin-bottom: 14px; }
.fx-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.fx-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.fx-grid-extra { margin-top: 8px; }
.fx-toggle {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; margin-top: 10px; padding: 7px;
  background: none; border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background 0.15s, color 0.15s;
}
.fx-toggle:hover { background: var(--surface-hover); color: var(--text); }
.fx-toggle svg { transition: transform 0.25s var(--ease); flex-shrink: 0; }
.fx-tile {
  display: grid; gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease);
}
.fx-tile:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.fx-code { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; }
.fx-rate { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.fx-rate small { font-size: 11px; color: var(--muted); margin-left: 4px; font-weight: 500; }
.fx-chg { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.fx-chg.up { color: var(--green); }
.fx-chg.down { color: var(--red); }
.fx-chg.flat { color: var(--muted); }

.fx-hint { display: block; margin-top: 4px; font-size: 11px; line-height: 1.4; }
.fx-hint b { color: var(--text); font-variant-numeric: tabular-nums; }
.fx-convert {
  padding: 10px 12px; border-radius: 12px;
  background: rgba(94, 234, 212, 0.06);
  border: 1px dashed rgba(94, 234, 212, 0.25);
  font-size: 12.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.fx-convert b { color: var(--mint); font-weight: 700; }
.fx-convert[hidden] { display: none; }

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: max-content; margin: 0 auto; }
  .fx-grid { grid-template-columns: repeat(5, 1fr); }
  .mini-grid { grid-template-columns: repeat(4, 1fr); }
  .tool-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Charts */
.donut-wrap { position: relative; width: 100%; max-width: 220px; margin: 0 auto 20px; }
.donut-wrap svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1)); }
.donut-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.donut-center span { display: block; font-size: 12px; color: var(--muted); }
.donut-center strong { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; }
.donut-legend { list-style: none; padding: 0; margin: 20px 0 0; font-size: 13px; }
.donut-legend li { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.donut-legend .dot {
  width: 10px; height: 10px; border-radius: 50%; margin-right: 8px;
  flex-shrink: 0; position: relative;
}
.donut-legend .dot::after {
  content: ""; position: absolute; top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%; border: 2px solid currentColor;
  animation: pulseDot 1.5s infinite ease-out;
}
@keyframes pulseDot {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
.donut-legend .leg-label { flex: 1; color: var(--muted); }

.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset-chip {
  background: var(--surface); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 12px; font-size: 12px;
  color: var(--text-dim); cursor: pointer; transition: all 0.2s;
}
.preset-chip:hover { color: var(--text); border-color: var(--text-dim); background: rgba(255,255,255,0.05); }

/* Calendar Grid */
.heatmap { width: 100%; max-width: 320px; margin: 0 auto; display: block; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.2)); }
.heat-d { font-size: 10px; fill: var(--text); font-weight: 500; }

/* Transaction search row */
.tx-search-row {
  display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px;
}
.tx-search {
  flex: 1; position: relative; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 0 10px 0 36px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.tx-search:focus-within {
  border-color: var(--mint, #5eead4);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.15);
}
.tx-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted, #94a3b8);
  display: inline-flex; align-items: center; justify-content: center; pointer-events: none;
}
.tx-search-icon svg { width: 18px; height: 18px; }
.tx-search input {
  flex: 1; background: transparent; border: 0; outline: none;
  padding: 10px 0; color: var(--text); font-size: 14px;
  -webkit-appearance: none;
}
.tx-search input::-webkit-search-cancel-button { display: none; }
.tx-search-clear {
  background: transparent; border: 0; color: var(--muted); font-size: 18px;
  padding: 0 4px; cursor: pointer; line-height: 1;
}
.tx-search-clear:hover { color: var(--text); }
.btn-icon {
  background: var(--surface); border: 1px solid var(--line);
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer; transition: all 0.2s; padding: 0;
}
.btn-icon:hover { border-color: var(--mint, #5eead4); transform: translateY(-1px); }
.btn-icon:active { transform: translateY(0); }
.btn-icon svg { width: 18px; height: 18px; }

/* Sankey */
.sankey-box { margin-top: 14px; }
.sankey-wrap { display: flex; flex-direction: column; gap: 12px; }
.sankey { width: 100%; max-width: 420px; margin: 0 auto; display: block; filter: drop-shadow(0 4px 16px rgba(0,0,0,0.25)); }
.sankey-legends { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sankey-legends h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.sankey-legends .donut-legend { list-style: none; padding: 0; margin: 0; }
.sankey-legends .donut-legend li { font-size: 13px; padding: 3px 0; }
@media (max-width: 480px) {
  .sankey-legends { grid-template-columns: 1fr; }
  .tx-search-row { flex-wrap: wrap; }
  .tx-search { min-width: 100%; order: -1; }
}

/* AI receipt preview modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: modalFadeIn 0.2s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--bg, #0f172a); border: 1px solid var(--line);
  border-radius: 20px; padding: 18px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.25s ease-out;
}
@keyframes modalSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-card h2 { margin: 0; font-size: 17px; display: inline-flex; align-items: center; }
.modal-card h2 svg { width: 18px; height: 18px; color: var(--mint, #5eead4); }
.modal-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;
}
.modal-actions button {
  padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line);
  font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.modal-actions .btn-secondary { background: transparent; color: var(--text); }
.modal-actions .btn-secondary:hover { background: var(--surface); }
.modal-actions .btn-primary {
  background: linear-gradient(135deg, #5eead4, #38bdf8); color: #0a0f1a; border-color: transparent;
}
.modal-actions .btn-primary:hover { transform: translateY(-1px); }

.receipt-preview .receipt-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.receipt-preview .receipt-items { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow-y: auto; }
.receipt-preview .receipt-items li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.receipt-row { display: grid; grid-template-columns: 24px 1fr 90px 110px; gap: 8px; align-items: center; }
.receipt-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--mint, #5eead4); }
.receipt-row .receipt-title, .receipt-row .receipt-amount, .receipt-row .receipt-cat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; color: var(--text); font-size: 13px; min-width: 0;
}
.receipt-row .receipt-amount { text-align: right; }
.receipt-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
}
.receipt-foot .receipt-total strong { font-size: 17px; color: var(--mint, #5eead4); }
@media (max-width: 480px) {
  .receipt-row { grid-template-columns: 20px 1fr 70px; }
  .receipt-row .receipt-cat { grid-column: 2 / 4; margin-top: 4px; }
}

/* ======== Capital page ======== */
.capital-total-card {
  margin: 8px 16px 0;
  padding: 20px;
  background: linear-gradient(135deg, rgba(94,234,212,.12), rgba(56,189,248,.08));
  border: 1px solid rgba(94,234,212,.2);
  border-radius: 18px;
  text-align: center;
}
.ct-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.ct-amount { font-size: 28px; font-weight: 700; color: var(--text); }
.ct-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ======== Menu launcher (Ещё) ======== */
.menu-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 18px 20px 6px; font-weight: 600;
}
.menu-list { background: var(--surface); border-radius: 16px; margin: 0 12px; overflow: hidden; }
.menu-row {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px 16px;
  background: transparent; border: none; color: var(--text);
  cursor: pointer; text-align: left; border-bottom: 1px solid var(--line);
  font-family: inherit; font-size: 15px; transition: background .15s;
}
.menu-row:last-child { border-bottom: none; }
.menu-row:active { background: rgba(255,255,255,.04); }
.menu-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.menu-icon svg { width: 18px; height: 18px; }
.menu-icon.mint { background: rgba(94,234,212,.15); color: #5eead4; }
.menu-icon.violet { background: rgba(167,139,250,.15); color: #a78bfa; }
.menu-text { flex: 1; }
.menu-text strong { display: block; font-size: 15px; font-weight: 500; }
.menu-text small { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.menu-chevron { color: var(--muted); font-size: 20px; line-height: 1; }
.segmented-sm button { padding: 4px 8px; font-size: 12px; }

/* ======== Goal tiles grid ======== */
.goals-grid { padding: 12px 12px 80px; display: flex; flex-direction: column; gap: 12px; }
.goal-tile {
  background: var(--surface); border-radius: 16px;
  border: 1px solid var(--line); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  animation: fadeUp .3s ease both;
}
.goal-tile.goal-done { opacity: .65; }
.goal-ring-wrap { flex-shrink: 0; }
.goal-ring { width: 72px; height: 72px; }
.ring-track { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 7; }
.ring-fill { fill: none; stroke: url(#tabGrad); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.ring-pct { fill: var(--text); font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; font-family: inherit; }
.goal-tile-body { flex: 1; min-width: 0; }
.goal-tile-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.goal-tile-nums { font-size: 14px; }
.goal-tile-deadline, .goal-tile-left { font-size: 12px; margin-top: 3px; }
.goal-tile-done { font-size: 12px; color: #5eead4; margin-top: 3px; }
.goal-tile-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }

/* ======== Debt summary ======== */
.debt-summary {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; padding: 12px 16px 4px;
}
.debt-sum-item {
  background: var(--surface); border-radius: 12px; border: 1px solid var(--line);
  padding: 10px 12px; text-align: center;
}
.debt-sum-item span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.debt-sum-item strong { display: block; font-size: 14px; font-weight: 700; }

/* ---------- Sparklines & price badges ---------- */
.sparkline { display: block; }
.sparkline-wrap { margin-top: 4px; }
.price-change { font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 6px; }
.price-change.up { color: var(--green); background: rgba(46,204,113,0.12); }
.price-change.down { color: var(--red); background: rgba(255,71,87,0.12); }
.yield-badge { color: var(--mint); font-size: 11px; font-weight: 600; }

/* ---------- Goals grid (new design) ---------- */
.goals-grid { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 0 0 8px; }
.goal-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-row); padding: 14px 16px;
  cursor: pointer; transition: background 0.15s;
}
.goal-card:active { background: var(--surface-hover); }
.goal-ring { flex-shrink: 0; }
.goal-ring-svg { display: block; }
.goal-info { flex: 1; min-width: 0; }
.goal-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-amounts { font-size: 14px; }
.goal-remaining { margin-top: 2px; }
.goal-remaining.done { color: var(--green); font-size: 12px; }
.goal-deadline { margin-top: 2px; }
.overdue { color: var(--red); }
.due-today { color: var(--amber); }
.goal-topup {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong);
  color: var(--mint); font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ---------- Debts (new design) ---------- */
.debts-summary { margin-bottom: 12px; }
.debts-total-row { display: flex; gap: 10px; margin-bottom: 8px; }
.debt-total-card {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-row); padding: 12px 14px;
}
.debt-total-card.owes-me { border-color: rgba(46,204,113,0.25); }
.debt-total-card.i-owe { border-color: rgba(255,71,87,0.25); }
.dt-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.dt-amount { font-size: 18px; font-weight: 700; }
.debt-total-card.owes-me .dt-amount { color: var(--green); }
.debt-total-card.i-owe .dt-amount { color: var(--red); }
.debt-net { text-align: center; font-size: 13px; font-weight: 600; padding: 6px; border-radius: 10px; background: var(--surface); }
.debt-net.positive { color: var(--green); }
.debt-net.negative { color: var(--red); }
.l-icon.red { background: rgba(255,71,87,0.12); color: var(--red); border-color: rgba(255,71,87,0.25); }

/* ---------- Chart cards (Analytics) ---------- */
.chart-card { overflow: hidden; }
.bars-wrap { width: 100%; overflow: hidden; margin-bottom: 4px; }
.bars-wrap svg.stacked-bars { display: block; width: 100%; }
.bars-legend {
  display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted);
}
.bars-legend span { display: flex; align-items: center; gap: 5px; }
.bars-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.bar-x { font-size: 10px; fill: var(--muted); font-family: inherit; }
.mini-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px;
}
.mini-grid > div {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
}
.mini-grid span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.mini-grid strong { display: block; font-size: 16px; font-weight: 700; }

/* ---------- Debt payment ---------- */
.btn-pay-debt {
  width: 100%; padding: 14px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(46,204,113,0.15), rgba(46,204,113,0.08));
  border: 1px solid rgba(46,204,113,0.35); color: var(--green);
  font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.btn-pay-debt:active { opacity: 0.75; }
.debt-progress { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.debt-progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--mint)); border-radius: 3px; transition: width 0.4s ease; }
.debt-pay-card { margin: 16px; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; }
.dp-person { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.dp-remaining { font-size: 14px; color: var(--muted); }
.dp-pct { font-size: 12px; color: var(--mint); margin-top: 4px; }
.quick-pay-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.qa-chip {
  padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.qa-chip:active { background: var(--mint); color: #000; border-color: var(--mint); }

/* ---------- Investment price badge ---------- */
.inv-price-badge { padding: 8px 0 4px; font-size: 13px; color: var(--muted); }
.inv-price-badge .price-found { color: var(--mint); }
.inv-price-badge .price-found strong { font-weight: 700; }

/* ---------- Deposit section ---------- */
.deposit-card {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: var(--radius-row);
  background: var(--surface-2); border: 1px solid var(--line);
  cursor: pointer; transition: background 0.15s;
}
.deposit-card:active { background: var(--surface-hover); }
.deposit-icon {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  background: rgba(94,234,212,0.12); border: 1px solid rgba(94,234,212,0.25);
  color: var(--mint); display: flex; align-items: center; justify-content: center;
}
.deposit-info { flex: 1; min-width: 0; }
.deposit-name { font-weight: 600; font-size: 15px; }
.deposit-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.deposit-right { text-align: right; }
.deposit-amount { font-size: 15px; font-weight: 700; }
.deposit-yield { font-size: 12px; color: var(--mint); margin-top: 1px; }

/* ---------- Custom Date Picker ---------- */
.date-field { display: contents; }
.date-field-btn {
  width: 100%; text-align: left; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; color: var(--text); font-size: 15px;
  cursor: pointer; transition: border-color 0.15s;
  display: flex; align-items: center; gap: 8px;
}
.date-field-btn::before { content: "📅"; font-size: 16px; }
.date-field-btn:focus, .date-field-btn:active { border-color: var(--mint); outline: none; }
.date-field-btn .muted { color: var(--muted); }

.dp-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.25s;
  pointer-events: none;
}
.dp-overlay.open { opacity: 1; pointer-events: all; }
.dp-sheet {
  width: 100%; max-width: 480px; background: var(--bg-1, #13141e);
  border-radius: 24px 24px 0 0; padding: 8px 16px 32px;
  transform: translateY(60px); transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
  border: 1px solid var(--line);
}
.dp-overlay.open .dp-sheet { transform: translateY(0); }
.dp-handle { width: 36px; height: 4px; background: var(--line-strong); border-radius: 2px; margin: 8px auto 16px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dp-month-label { font-size: 16px; font-weight: 700; }
.dp-nav {
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface);
  border: 1px solid var(--line); color: var(--text); font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.dp-nav:active { background: var(--mint); color: #000; }
.dp-weekdays { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 6px; }
.dp-weekdays span { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.dp-days { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.dp-day {
  aspect-ratio: 1; border-radius: 50%; background: none; border: none;
  color: var(--text); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.dp-day:hover { background: var(--surface); }
.dp-day.today { border: 1.5px solid var(--mint); color: var(--mint); font-weight: 600; }
.dp-day.selected { background: var(--mint); color: #000; font-weight: 700; }
.dp-footer { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.dp-btn-ghost { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 8px 4px; }
.dp-btn-ghost:active { color: var(--text); }

/* ---------- CoinMarketCap import ---------- */
.cmc-import-area {
  background: var(--surface); border: 1.5px dashed var(--line-strong);
  border-radius: 16px; padding: 16px; font-size: 13px;
  color: var(--muted); font-family: monospace; min-height: 120px;
  width: 100%; box-sizing: border-box; resize: vertical; margin-top: 4px;
}

/* ========== CRYPTO PORTFOLIO PAGE ========== */

/* Hero header */
.pf-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f2027 100%);
  border-radius: 0 0 24px 24px; padding: 20px 20px 24px; margin-bottom: 0;
  cursor: pointer; user-select: none;
}
.pf-hero-glow {
  position: absolute; top: -60px; right: -40px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(94,234,212,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.pf-hero-inner { position: relative; z-index: 1; }
.pf-name { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.55); margin-bottom: 8px; letter-spacing: 0.3px; }
.pf-total-usd { font-size: 36px; font-weight: 700; color: #fff; letter-spacing: -0.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pf-total-rub { font-size: 16px; color: rgba(255,255,255,0.55); margin-top: 2px; font-variant-numeric: tabular-nums; }
.pf-change { margin-top: 10px; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pf-change .pf-chg-label { color: rgba(255,255,255,0.38); font-size: 12px; }
.pf-pos { color: #4ade80; font-weight: 600; }
.pf-neg { color: #f87171; font-weight: 600; }
.pf-flat { color: rgba(255,255,255,0.45); }
.pf-airdrop { color: #fbbf24; font-size: 11px; font-weight: 600; }
.skeleton { opacity: 0.35; }

/* Allocation bar */
.pf-alloc-wrap { padding: 16px 16px 8px; background: var(--bg); }
.pf-alloc-bar { display: flex; border-radius: 6px; overflow: hidden; height: 8px; gap: 2px; }
.pf-alloc-seg { height: 100%; border-radius: 3px; transition: width 0.4s ease; min-width: 2px; }
.pf-alloc-legend { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.pf-leg-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.pf-leg-item i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.pf-leg-item span { font-weight: 600; color: var(--text); font-size: 12px; }

/* Sort row */
.pf-list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 6px; font-size: 13px; color: var(--muted);
}
.pf-sort-row { display: flex; gap: 4px; }
.pf-sort {
  background: var(--surface); border: none; border-radius: 20px;
  padding: 4px 10px; font-size: 11px; font-weight: 500; color: var(--muted);
  cursor: pointer; transition: all 0.15s;
}
.pf-sort.active { background: var(--mint); color: #000; }

/* Asset list loading */
.pf-loading { display: flex; justify-content: center; padding: 40px; }

/* Asset row */
.pf-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background 0.1s; -webkit-tap-highlight-color: transparent;
}
.pf-row:last-child { border-bottom: none; }
.pf-row:active { background: var(--surface); }

/* Avatar circle */
.pf-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--ac, #334155); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: -0.5px;
}

/* Asset info (left) */
.pf-info { flex: 1; min-width: 0; }
.pf-aname { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-ameta { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Metrics (right) */
.pf-metrics { text-align: right; flex-shrink: 0; }
.pf-avalue { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pf-asub { font-size: 12px; margin-top: 2px; display: flex; align-items: center; justify-content: flex-end; gap: 4px; flex-wrap: nowrap; }

/* 5-tab tabbar tweak */
.tabbar button { min-width: 0; flex: 1; }

/* Coin icon inside avatar */
.pf-avatar { position: relative; overflow: hidden; }
.pf-coin-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover; z-index: 1;
}
.pf-coin-fb {
  position: relative; z-index: 0;
}

/* Donut chart */
.pf-donut-row { display: flex; align-items: center; gap: 16px; padding: 14px 16px 12px; }
.pf-donut-svg { flex-shrink: 0; }
.pf-donut-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pf-leg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pf-leg-row i { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.pf-leg-name { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.pf-leg-pct { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; flex-shrink: 0; }

/* Dashboard ≈$ sub */
.balance-usd-sub { font-size: 14px; color: rgba(255,255,255,0.45); margin-top: -2px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }

/* ============================================================
   iOS Drum Date Picker
   ============================================================ */
.dp-drum-sheet { padding: 0 0 env(safe-area-inset-bottom); border-radius: 20px 20px 0 0; }
.dp-drum-title { text-align:center; font-size:12px; font-weight:600; color:rgba(255,255,255,.35); letter-spacing:.08em; text-transform:uppercase; padding:14px 20px 8px; }
.dp-drum-wrap {
  position:relative; display:flex; height:220px; overflow:hidden;
  user-select:none; -webkit-user-select:none;
}
.dp-drum-selector {
  position:absolute; left:8px; right:8px;
  top:calc(50% - 22px); height:44px;
  background:rgba(255,255,255,.07);
  border-top:1px solid rgba(255,255,255,.12);
  border-bottom:1px solid rgba(255,255,255,.12);
  border-radius:10px; pointer-events:none; z-index:2;
}
.dp-drum-col {
  flex:1; overflow:visible; position:relative;
  touch-action:none; cursor:ns-resize;
}
.dp-drum-col-wide { flex:2; }
.drum-item {
  height:44px; display:flex; align-items:center; justify-content:center;
  font-size:17px; font-family:var(--font); white-space:nowrap;
  transition:color .08s;
  color:rgba(255,255,255,.35);
  transform-origin:center;
}
.drum-item.drum-sel { color:#fff; font-weight:600; }
.dp-drum-fade-top,.dp-drum-fade-bot {
  position:absolute; left:0; right:0; height:90px; pointer-events:none; z-index:3;
}
.dp-drum-fade-top { top:0; background:linear-gradient(to bottom,#131622 5%,transparent 100%); }
.dp-drum-fade-bot { bottom:0; background:linear-gradient(to top,#131622 5%,transparent 100%); }
.dp-btn-confirm {
  flex:1.4; height:48px; border-radius:12px;
  background:linear-gradient(135deg,#5eead4,#38bdf8);
  color:#0a0a14; font-weight:700; font-size:15px;
  border:none; cursor:pointer; font-family:var(--font);
}
.dp-btn-confirm:active { opacity:.85; }
.dp-footer { display:flex; gap:8px; padding:14px 16px 20px; }
.dp-btn-ghost { flex:1; height:48px; border-radius:12px; background:rgba(255,255,255,.07); color:rgba(255,255,255,.6); font-weight:500; font-size:15px; border:none; cursor:pointer; font-family:var(--font); }
.dp-btn-ghost:active { background:rgba(255,255,255,.13); }

/* ============================================================
   Portfolio sub-tabs (Крипто / Акции)
   ============================================================ */
.pf-tab-bar {
  display:flex; gap:6px; padding:14px 16px 0;
  position:sticky; top:0; background:var(--bg); z-index:10;
}
.pf-tab-btn {
  flex:1; height:38px; border-radius:10px;
  background:rgba(255,255,255,.07);
  border:none; color:rgba(255,255,255,.5); font-size:13px;
  font-weight:600; cursor:pointer; font-family:var(--font);
  display:flex; align-items:center; justify-content:center; gap:6px;
  transition:background .15s,color .15s;
}
.pf-tab-btn svg { width:16px; height:16px; }
.pf-tab-btn.active {
  background:rgba(94,234,212,.15);
  color:#5eead4;
  border:1px solid rgba(94,234,212,.3);
}

/* ============================================================
   Show more / collapse button
   ============================================================ */
.pf-show-more {
  width:100%; padding:13px 16px; margin-top:2px;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px; color:rgba(255,255,255,.5);
  font-size:13px; font-weight:600; font-family:var(--font);
  cursor:pointer; display:flex; align-items:center; justify-content:center; gap:6px;
  transition:background .15s;
}
.pf-show-more svg { width:16px; height:16px; flex-shrink:0; }
.pf-show-more:active { background:rgba(255,255,255,.09); }

/* ============================================================
   AI Analyst Chat
   ============================================================ */
.pf-tab-ai.active { background: rgba(168,85,247,.15); color:#c084fc; border-color: rgba(168,85,247,.35) !important; }
.pf-tab-ai svg { stroke: currentColor; }

.ai-chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 400px;
}
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.ai-welcome {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 28px 16px 12px; gap: 8px;
}
.ai-welcome-icon { font-size: 44px; line-height: 1; }
.ai-welcome-title { font-size: 18px; font-weight: 700; color: var(--text); }
.ai-welcome-sub { font-size: 13px; color: var(--muted); line-height: 1.5; max-width: 280px; }
.ai-quick-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.ai-quick-btn {
  padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  color: var(--text); cursor: pointer; font-family: var(--font);
  transition: background .15s;
}
.ai-quick-btn:active { background: rgba(255,255,255,.15); }

.ai-msg { display: flex; max-width: 88%; }
.ai-msg-user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg-assistant { align-self: flex-start; }
.ai-bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.55; word-break: break-word;
}
.ai-msg-user .ai-bubble {
  background: linear-gradient(135deg, #5eead4, #38bdf8);
  color: #0a0a14; border-bottom-right-radius: 4px;
  font-weight: 500;
}
.ai-msg-assistant .ai-bubble {
  background: rgba(255,255,255,.08);
  color: var(--text); border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,.08);
}

/* Typing dots animation */
.ai-dots { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.ai-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,.4);
  animation: aiDot 1.2s infinite ease-in-out;
}
.ai-dots span:nth-child(2) { animation-delay: .2s; }
.ai-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aiDot { 0%,80%,100% { transform: scale(0.7); opacity:.4 } 40% { transform: scale(1); opacity:1 } }

/* Mode bar */
.ai-mode-row {
  display: flex; gap: 6px; padding: 6px 14px 2px;
  overflow-x: auto; scrollbar-width: none;
}
.ai-mode-row::-webkit-scrollbar { display: none; }
.ai-mode-btn {
  flex-shrink: 0; padding: 5px 14px; border-radius: 20px; font-size: 12px;
  font-weight: 600; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.5);
  cursor: pointer; font-family: var(--font); transition: background .15s, color .15s;
}
.ai-mode-btn.active { background: rgba(168,85,247,.18); color: #c084fc; border-color: rgba(168,85,247,.3); }

/* Input row */
.ai-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
  background: var(--bg);
}
.ai-input {
  flex: 1; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px; padding: 10px 14px; color: var(--text);
  font-size: 14px; font-family: var(--font); resize: none; line-height: 1.4;
  outline: none; max-height: 120px; overflow-y: auto;
}
.ai-input:focus { border-color: rgba(168,85,247,.5); }
.ai-input::placeholder { color: rgba(255,255,255,.3); }
.ai-send-btn {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.ai-send-btn svg { width: 18px; height: 18px; stroke: #fff; }
.ai-send-btn:disabled { opacity: .45; cursor: default; }
.ai-send-btn:not(:disabled):active { opacity: .8; }
