/* ╔══════════════════════════════════════════════════════════════╗
   ║  Checko · Boutique SaaS theme · v2026-05-22h            ║
   ║  Tokens → Reset → Layout → Components → Views → Responsive   ║
   ╚══════════════════════════════════════════════════════════════╝ */

/* ── 1. Design tokens ───────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f6f7fb;
  --bg-tint: radial-gradient(140% 80% at 10% -10%, rgba(255, 87, 34, 0.08), transparent 60%),
             radial-gradient(120% 70% at 110% 10%, rgba(17, 17, 17, 0.06), transparent 55%),
             linear-gradient(180deg, #fafaf8 0%, #f0eeea 100%);
  --card: #ffffff;
  --card-elev: #ffffff;
  --soft: #f1f4fa;
  --hover: #eef2f9;

  /* text */
  --ink: #0f172a;
  --ink-strong: #050a1a;
  --muted: #64748b;
  --muted-strong: #475569;

  /* borders */
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* brand — Checko: rich black + orange accent */
  --brand: #111111;           /* rich black, primary */
  --brand-2: #ff5722;         /* orange accent */
  --brand-soft: rgba(255, 87, 34, 0.10);
  --brand-ring: rgba(255, 87, 34, 0.34);
  --brand-grad: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 45%, #ff5722 100%);

  /* hero (dark with warm glow toward orange) */
  --hero-bg: linear-gradient(140deg, #0b0b0e 0%, #16161c 50%, #1d1d26 100%);
  --hero-ink: #f8fafc;
  --hero-muted: rgba(248, 250, 252, 0.7);
  --hero-soft: rgba(255, 255, 255, 0.12);
  --hero-line: rgba(255, 255, 255, 0.18);

  /* semantic */
  --ok: #059669;
  --ok-2: #34d399;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --ok-grad: linear-gradient(135deg, #059669, #34d399);
  --warn: #d97706;
  --warn-soft: rgba(245, 158, 11, 0.16);
  --warn-grad: linear-gradient(135deg, #d97706, #fbbf24);
  --danger: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --danger-grad: linear-gradient(135deg, #dc2626, #f87171);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.14);

  /* category colors */
  --cat-food: #f97316;        /* orange */
  --cat-food-soft: rgba(249, 115, 22, 0.14);
  --cat-transport: #06b6d4;   /* cyan */
  --cat-transport-soft: rgba(6, 182, 212, 0.14);
  --cat-shopping: #ec4899;    /* pink */
  --cat-shopping-soft: rgba(236, 72, 153, 0.14);
  --cat-fun: #a855f7;         /* purple */
  --cat-fun-soft: rgba(168, 85, 247, 0.14);
  --cat-bills: #eab308;       /* amber */
  --cat-bills-soft: rgba(234, 179, 8, 0.14);
  --cat-saving: #10b981;      /* emerald */
  --cat-saving-soft: rgba(16, 185, 129, 0.14);
  --cat-debt: #ef4444;        /* red */
  --cat-debt-soft: rgba(239, 68, 68, 0.14);
  --cat-other: #64748b;       /* slate */
  --cat-other-soft: rgba(100, 116, 139, 0.14);
  --cat-reimbursement: #14b8a6; --cat-reimbursement-soft: rgba(20, 184, 166, 0.14);
  --cat-income: #22c55e;      /* green */
  --cat-income-soft: rgba(34, 197, 94, 0.14);
  --cat-travel: #0ea5e9;        --cat-travel-soft: rgba(14, 165, 233, 0.14);
  --cat-medical: #ef4444;       --cat-medical-soft: rgba(239, 68, 68, 0.14);
  --cat-education: #6366f1;     --cat-education-soft: rgba(99, 102, 241, 0.14);
  --cat-entertainment: #a855f7; --cat-entertainment-soft: rgba(168, 85, 247, 0.14);
  --cat-insurance: #3b82f6;     --cat-insurance-soft: rgba(59, 130, 246, 0.14);
  --cat-maintenance: #b45309;   --cat-maintenance-soft: rgba(180, 83, 9, 0.14);
  --cat-rent: #d97706;          --cat-rent-soft: rgba(217, 119, 6, 0.14);
  --cat-telecom: #14b8a6;       --cat-telecom-soft: rgba(20, 184, 166, 0.14);
  --cat-utilities: #eab308;     --cat-utilities-soft: rgba(234, 179, 8, 0.14);
  --cat-tax: #78716c;           --cat-tax-soft: rgba(120, 113, 108, 0.14);
  --cat-gift: #f43f5e;          --cat-gift-soft: rgba(244, 63, 94, 0.14);
  --cat-pet: #84cc16;           --cat-pet-soft: rgba(132, 204, 22, 0.14);
  --cat-fitness: #22d3ee;       --cat-fitness-soft: rgba(34, 211, 238, 0.14);

  /* legacy color aliases used by JS (group/chart colors) */
  --green: #10b981;
  --blue: #0ea5e9;
  --yellow: #eab308;
  --red: #ef4444;
  --purple: #a855f7;
  --orange: #f97316;
  --pink: #ec4899;

  /* effects */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-md: 18px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 6px 18px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 12px 30px rgba(255, 87, 34, 0.28);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 200ms;

  /* type */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-family: var(--font-sans);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b16;
  --bg-tint: radial-gradient(140% 80% at 10% -10%, rgba(77, 124, 255, 0.18), transparent 60%),
             radial-gradient(120% 70% at 110% 10%, rgba(125, 163, 255, 0.10), transparent 55%),
             linear-gradient(180deg, #0a1024 0%, #050813 100%);
  --card: #111a2e;
  --card-elev: #1a2440;
  --soft: #182240;
  --hover: #1d2849;

  --ink: #e8edf7;
  --ink-strong: #ffffff;
  --muted: #93a0bd;
  --muted-strong: #b9c3da;

  --line: #1f2a48;
  --line-strong: #2a3865;

  --brand: #ff5722;
  --brand-2: #ff8a65;
  --brand-soft: rgba(255, 87, 34, 0.20);
  --brand-ring: rgba(255, 87, 34, 0.48);
  --brand-grad: linear-gradient(135deg, #ff5722 0%, #ff8a65 100%);

  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.18);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.18);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.18);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 20px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.7), 0 6px 14px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 14px 36px rgba(77, 124, 255, 0.45);
}

/* ── 2. Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--bg-tint);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* iOS / Android — kill the tap blue flash + don't zoom on double-tap */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* Stop body rubber-banding past phone-app on iOS */
  overscroll-behavior-y: contain;
}
/* Inputs ≥16px font-size to prevent iOS focus auto-zoom */
@media (max-width: 559px) {
  input[type="text"], input[type="tel"], input[type="number"],
  input[type="search"], input[type="email"], input[type="password"],
  input[type="date"], textarea, select {
    font-size: 16px;
  }
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; color: var(--ink-strong); letter-spacing: -0.02em; }
h1 { font-size: 17px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.025em; }
h3 { font-size: 15px; font-weight: 700; }
h4 { font-size: 13px; font-weight: 700; }
p { margin: 0; color: var(--muted-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
/* ── Accent palettes (orthogonal to light/dark). data-palette swaps brand vars,
   so every accent (buttons, active tabs, logo check, rings) re-tints at once. ── */
:root[data-palette="ocean"]  { --brand-2:#0ea5e9; --brand-soft:rgba(14,165,233,.10);  --brand-ring:rgba(14,165,233,.45); --brand-grad:linear-gradient(135deg,#1a1a1a 0%,#2a2a2a 45%,#0ea5e9 100%); }
:root[data-palette="violet"] { --brand-2:#8b5cf6; --brand-soft:rgba(139,92,246,.10);  --brand-ring:rgba(139,92,246,.45); --brand-grad:linear-gradient(135deg,#1a1a1a 0%,#2a2a2a 45%,#8b5cf6 100%); }
:root[data-palette="rose"]   { --brand-2:#ec4899; --brand-soft:rgba(236,72,153,.10);  --brand-ring:rgba(236,72,153,.45); --brand-grad:linear-gradient(135deg,#1a1a1a 0%,#2a2a2a 45%,#ec4899 100%); }
:root[data-palette="ocean"][data-theme="dark"]  { --brand:#0ea5e9; --brand-2:#38bdf8; --brand-soft:rgba(14,165,233,.20);  --brand-ring:rgba(14,165,233,.48); --brand-grad:linear-gradient(135deg,#0ea5e9 0%,#38bdf8 100%); }
:root[data-palette="violet"][data-theme="dark"] { --brand:#8b5cf6; --brand-2:#a78bfa; --brand-soft:rgba(139,92,246,.20);  --brand-ring:rgba(139,92,246,.48); --brand-grad:linear-gradient(135deg,#8b5cf6 0%,#a78bfa 100%); }
:root[data-palette="rose"][data-theme="dark"]   { --brand:#ec4899; --brand-2:#f472b6; --brand-soft:rgba(236,72,153,.20);  --brand-ring:rgba(236,72,153,.48); --brand-grad:linear-gradient(135deg,#ec4899 0%,#f472b6 100%); }
/* RGB 三元组(给 rgba() 辉光用),与上面 --brand-2 同层叠 → 报表辉光跟随主题 */
:root { --brand-2-rgb: 255,87,34; }
:root[data-theme="dark"] { --brand-2-rgb: 255,138,101; }
:root[data-palette="ocean"]  { --brand-2-rgb: 14,165,233; }
:root[data-palette="violet"] { --brand-2-rgb: 139,92,246; }
:root[data-palette="rose"]   { --brand-2-rgb: 236,72,153; }
:root[data-palette="ocean"][data-theme="dark"]  { --brand-2-rgb: 56,189,248; }
:root[data-palette="violet"][data-theme="dark"] { --brand-2-rgb: 167,139,250; }
:root[data-palette="rose"][data-theme="dark"]   { --brand-2-rgb: 244,114,182; }

/* Palette picker swatches */
.palette-swatches { display: flex; gap: 10px; }
.palette-swatch {
  width: 26px; height: 26px; padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--sw);
  cursor: pointer;
  transition: transform 0.12s var(--ease);
}
.palette-swatch:active { transform: scale(0.92); }
.palette-swatch.active { border-color: var(--card); box-shadow: 0 0 0 2px var(--sw); }
/* Logo check mark follows the palette accent (CSS beats the inline stroke attr) */
.brand-mark svg path:nth-child(2) { stroke: var(--brand-2); }

/* ── Hard login gate ─────────────────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}
.auth-gate[hidden] { display: none; }
body.gate-open { overflow: hidden; }

/* Biometric privacy lock — sits above everything (incl. the auth gate) until
   Face ID / fingerprint clears it. */
.biometric-lock {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--bg);
  background-image: var(--bg-tint);
}
.biometric-lock[hidden] { display: none; }
.biometric-lock-inner {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  max-width: 320px;
  width: 100%;
}
.biometric-lock-icon {
  width: 72px; height: 72px;
  display: grid; place-items: center;
  border-radius: 24px;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 4px;
}
.biometric-lock-icon svg { width: 38px; height: 38px; }
.biometric-lock-inner h2 { font-size: 22px; }
.biometric-lock-inner p { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
#bioUnlockBtn {
  width: 100%; height: 50px;
  border: 0; border-radius: var(--radius-md);
  background: var(--brand-grad); color: #fff;
  font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 20px -8px var(--brand);
}
#bioUnlockBtn:active { transform: scale(0.98); }
#bioSignOutBtn { width: 100%; }
body.bio-locked { overflow: hidden; }
.auth-gate-card {
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 14px;
  padding: 28px 22px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
}
.auth-gate-brand { display: flex; align-items: center; gap: 10px; }
.auth-gate-brand .brand-mark { width: 36px; height: 36px; color: var(--ink-strong); }
.auth-gate-brand .brand-mark svg { width: 100%; height: 100%; }
.auth-gate-brand strong { font-size: 18px; letter-spacing: 0.06em; }
.auth-gate-card h2 { font-size: 22px; margin: 2px 0 0; }
.auth-gate-copy { font-size: 13px; color: var(--muted); margin: 0; }
.auth-gate-form { display: grid; gap: 12px; }
.auth-gate-form input[type="email"],
.auth-gate-form input[type="password"],
.auth-gate-form input#gateCode {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--ink-strong);
  font-size: 15px;
}
.auth-gate-hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; text-align: center; }
.auth-gate-form input#gateCode { letter-spacing: 0.28em; text-align: center; font-size: 21px; font-weight: 700; }
.auth-gate-form button[type="submit"] {
  padding: 13px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.auth-gate-form .secondary-button { padding: 11px; }
.auth-gate-resend {
  border: 0;
  background: none;
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}
.auth-gate-resend:disabled { color: var(--muted); cursor: default; }
.auth-gate .auth-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted); }
.auth-gate .auth-consent a { color: var(--brand-2); }
.auth-gate #gateStatus { font-size: 13px; text-align: center; margin: 0; }
/* Auth validation/error feedback: shake the card + turn the status line red so a
   blocked submit (e.g. consent unchecked) can't be mistaken for "nothing happened". */
@keyframes authShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.auth-shake { animation: authShake 0.5s cubic-bezier(.36, .07, .19, .97); }
@media (prefers-reduced-motion: reduce) { .auth-shake { animation: none; } }
.auth-gate #gateStatus.is-error,
#authStatus.is-error { color: var(--danger); font-weight: 600; background: var(--danger-soft); }

::selection { background: var(--brand-soft); color: var(--ink-strong); }
[hidden] { display: none !important; }

/* "Rp" currency prefix — muted small label so the number is the focus.
   Wrapped by formatRpHtml(); see app.js. */
/* Atomic money block: prefix + digits never split across lines */
.rp-line {
  display: inline-block;
  white-space: nowrap;
}
.rp-prefix {
  font-size: 0.62em;
  font-weight: 600;
  opacity: 0.55;
  margin-right: 0.18em;
  letter-spacing: 0.02em;
  vertical-align: 0.1em;
  font-feature-settings: normal;
  white-space: nowrap;
  /* Force solid color even when the parent uses background-clip:text
     gradients (e.g. #todaySpendable's white→orange headline) — those
     set -webkit-text-fill-color:transparent which would inherit and
     make the Rp invisible. */
  -webkit-text-fill-color: currentColor;
  color: inherit;
}
/* On the dark hero specifically, ensure Rp reads as faded white */
.overview-hero .rp-prefix {
  color: rgba(255, 255, 255, 0.65);
  -webkit-text-fill-color: rgba(255, 255, 255, 0.65);
  opacity: 0.85;
}

/* mono utility — auto-apply to currency/number heavy elements */
.tx-meta, .paylater-meta,
#safeBalance, #safeReservedCost, #safeTotalBalance,
#overviewExpectedIncome, #overviewBudgetUsed, #balanceSummary,
#incomeSummary, #dailySafe, #todaySpendable, #todaySpendableRatio {
  font-feature-settings: "tnum", "lnum";
}

/* ── 3. App shell + phone frame ────────────────────────────────── */
.app-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: stretch;
  padding: clamp(0px, 2vw, 24px);
}

/* When previewing as mobile on a wider window, frame the phone */
body[data-preview-device="mobile"] .app-shell {
  place-items: center;
  padding: clamp(0px, 3vw, 32px);
}

.phone-app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  isolation: isolate;
}

/* Mobile preview frame: fixed phone width on desktop windows */
@media (min-width: 560px) {
  body[data-preview-device="mobile"] .phone-app {
    width: 414px;
    max-width: 100%;
    height: min(880px, calc(100vh - 48px));
    box-shadow: var(--shadow-lg);
  }
}

/* ── 4. Header ─────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  /* iOS Safari often reports inset-top = 0 even on notched phones (only PWA
     mode fills in the real value), so guarantee a minimum 18px gap so the
     brand row never kisses the status bar / Dynamic Island. */
  padding: calc(14px + max(env(safe-area-inset-top), 18px)) 16px 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.82));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
:root[data-theme="dark"] .app-header {
  background: linear-gradient(180deg, rgba(17,26,46,0.95), rgba(17,26,46,0.78));
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand h1 {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.08em;
}
.brand p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #ffffff;
  color: #111111; /* C is black */
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.18), 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(17, 17, 17, 0.08);
}
.brand-mark svg {
  width: 26px;
  height: 26px;
}
:root[data-theme="dark"] .brand-mark {
  background: #1a1a1a;
  color: #f5f5f5;
  border-color: rgba(255, 255, 255, 0.08);
}
.language-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  border: 1px solid var(--line);
}
.language-switch button {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-strong);
}
.language-switch button.active {
  background: var(--card-elev);
  color: var(--ink-strong);
  box-shadow: var(--shadow-sm);
}

/* ── Simple mode ──────────────────────────────────────────────
   Conversational variant: bottom nav drops Mutasi + Bills tabs,
   Profile side-menu hides per-entity CRUD panels (those are reached
   through chat: catat / 改 / 删). Detailed views still exist in code
   so chat-driven actions can render them, just not in chrome. */
.phone-app[data-ui-mode="simple"] .bottom-nav {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.phone-app[data-ui-mode="simple"] .bottom-nav button[data-view="transactions"],
.phone-app[data-ui-mode="simple"] .bottom-nav button[data-view="debt"] {
  display: none;
}
/* In simple mode, surface Mutasi + Bills inside Profile's side menu
   (they're not in the bottom nav). All other Profile menu items stay
   visible so users keep full access via Profile.
   Use .side-menu .side-menu-nav so we beat the .side-menu button rule. */
.side-menu .side-menu-nav { display: none !important; }
.phone-app[data-ui-mode="simple"] .side-menu .side-menu-nav {
  display: grid !important;
}

/* Header budget shortcut (replaces former language slot) */
.header-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 6px 0 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--brand-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.005em;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.32);
  transition: transform var(--dur) var(--ease);
  white-space: nowrap;
}
.header-shortcut:hover { transform: translateY(-1px); }
.header-shortcut svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.header-shortcut > strong {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.015em;
  font-feature-settings: "tnum", "lnum";
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.25);
  min-width: 44px;
  text-align: center;
}

/* Language card inside Profile → Settings */
.language-card { display: grid; gap: 12px; }
.language-card .settings-language {
  justify-self: start;
  background: var(--soft);
}
.language-card .settings-language button {
  min-width: 44px;
  height: 32px;
  font-size: 13px;
}

/* Account card (Profile → Settings) */
.account-card { display: grid; gap: 12px; }
.account-status {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.account-status-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-strong);
  word-break: break-all;
}
.account-quota {
  font-size: 12px;
  color: var(--muted);
  font-feature-settings: "tnum", "lnum";
}
.account-card .form-actions.single {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Export choices modal */
.export-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 12px;
}
/* Use a unique class + selector to avoid .form-actions button gradient
   from cascading onto these. */
button.export-choice {
  display: grid;
  gap: 6px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  box-shadow: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
button.export-choice:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
  box-shadow: none;
}
button.export-choice .export-choice-tag {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
}
button.export-choice .export-choice-copy {
  font-size: 11px;
  color: var(--muted-strong);
  font-weight: 600;
}

/* ── Export panel (资料 → 下载明细) ───────────────────────────── */
.export-panel { display: grid; gap: 14px; }
.export-format {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--soft);
}
.export-format button {
  border: 0;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.export-format button.active {
  background: var(--card);
  color: var(--ink-strong);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.export-filename { display: grid; gap: 6px; }
.export-filename > span { font-size: 12px; color: var(--muted); font-weight: 600; }
.export-filename-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  padding: 0 12px;
}
.export-filename-row:focus-within { border-color: var(--brand); background: var(--card); }
.export-filename-row input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}
.export-filename-row input:focus { outline: none; }
.export-ext { flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--muted); }
.export-preview { display: grid; gap: 8px; }
.export-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.export-preview-head > span:first-child { font-size: 12px; color: var(--muted); font-weight: 600; }
.export-count { font-size: 12px; font-weight: 700; color: var(--brand); }
.export-table {
  display: grid;
  gap: 2px;
  max-height: 230px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.export-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 0 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.export-row-name {
  grid-column: 1; grid-row: 1;
  font-size: 13px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.export-row-meta {
  grid-column: 1; grid-row: 2;
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.export-row-amt {
  grid-column: 2; grid-row: 1 / span 2;
  align-self: center;
  font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.export-row-amt.out { color: var(--danger); }
.export-row-amt.in { color: var(--success, #16a34a); }
.export-more { font-size: 12px; color: var(--muted); text-align: center; padding: 4px 0; }
.export-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--brand-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px -8px var(--brand);
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.export-download:active { transform: scale(0.98); }
.export-download:disabled { opacity: 0.55; cursor: default; }
.export-status { font-size: 13px; font-weight: 700; text-align: center; margin: 0; }
.export-status.busy { color: var(--muted-strong); }
.export-status.done { color: var(--success, #16a34a); }
.export-status.fail { color: var(--danger); }

/* Generate modal: transaction count under the filename */
.export-gen-count { font-size: 12px; font-weight: 700; color: var(--brand); margin: 0; }

/* Download list (资料 → 下载明细): one row per generated file */
.export-records { display: grid; gap: 8px; }
.export-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
}
.export-record-main { min-width: 0; display: grid; gap: 3px; }
.export-record-name {
  font-size: 14px; font-weight: 700; color: var(--ink-strong);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.export-record-meta { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.export-record-tag {
  display: inline-grid; place-items: center;
  padding: 1px 6px; border-radius: var(--radius-pill);
  background: var(--brand-soft); color: var(--brand);
  font-size: 10px; font-weight: 800;
}
.export-record-dl {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--brand-grad); color: #fff;
  cursor: pointer;
}
.export-record-dl svg { width: 19px; height: 19px; }
.export-record-dl:active { transform: scale(0.94); }
.export-record-del {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: var(--soft); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}

/* Admin badge on subscription panel (when /api/me returns isAdmin) */
#profileSubscription[data-admin="1"]::before {
  content: "Admin · 可随时切换套餐，无广告";
  display: block;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-ring);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Spending stats range chooser (chip row inside an AI message card) */
.stats-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
/* Chooser card has no header above the chips → no extra top gap. */
.stats-range-card .stats-range-row { margin-top: 0; }
.stats-range-chip {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.stats-range-chip:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}
.stats-range-chip.selected {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.stats-range-chip:disabled { opacity: 0.65; cursor: not-allowed; }

/* Inline action confirm card (edit/delete in chat) */
.action-confirm-card { transition: opacity 200ms var(--ease); }
.action-confirm-card.expired,
.action-confirm-card.applied,
.action-confirm-card.cancelled,
.action-confirm-card.failed { opacity: 0.65; }
.action-card-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.action-confirm-btn,
.action-cancel-btn {
  height: 36px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.action-confirm-btn {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.32);
}
.action-confirm-btn:hover:not(:disabled) { transform: translateY(-1px); }
.action-cancel-btn {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
}
.action-cancel-btn:hover:not(:disabled) { background: var(--hover); }
.action-confirm-btn:disabled,
.action-cancel-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.action-state-label {
  display: block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
}
.expired-label   { background: var(--soft);        color: var(--muted); }
.applied-label   { background: var(--ok-soft);     color: var(--ok); }
.cancelled-label { background: var(--soft);        color: var(--muted-strong); }
.failed-label    { background: var(--danger-soft); color: var(--danger); }

/* Ad modal — free-user gate */
.ad-modal-backdrop {
  /* same as .modal-backdrop but darker + uninteractable backdrop */
  background: rgba(5, 8, 20, 0.86);
}
.ad-modal-card {
  position: relative;
  width: min(92%, 360px);
  max-height: 88vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.ad-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.ad-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid currentColor;
}
.ad-reason {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.ad-modal-body {
  padding: 24px 18px;
  display: grid;
  place-items: center;
  min-height: 220px;
}
.ad-placeholder {
  display: grid;
  gap: 10px;
  text-align: center;
  justify-items: center;
}
.ad-placeholder-art {
  font-size: 64px;
  line-height: 1;
}
.ad-placeholder h3 {
  font-size: 18px;
  font-weight: 800;
}
.ad-placeholder p {
  font-size: 13px;
  color: var(--muted-strong);
  max-width: 240px;
}
.ad-modal-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--soft);
}
.ad-modal-footer button {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 13px;
}
.ad-modal-footer button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Auth modal status text */
.auth-status {
  font-size: 12px;
  color: var(--muted-strong);
  padding: 8px 12px;
  background: var(--soft);
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

/* ── 5. View shell ─────────────────────────────────────────────── */
.app-view {
  display: none;
  padding: 14px 16px 24px;
  gap: 12px;
  min-height: 0;
}
.app-view.active {
  display: grid;
  grid-auto-rows: min-content;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: viewIn 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* Lightweight one-shot enter animation for view / panel switches.
   GPU-only (opacity + transform), no reflow, no JS, no extra assets;
   prefers-reduced-motion already neutralizes it globally (see §reduced-motion). */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#chatView.active {
  padding: 12px 0 0;
  grid-template-rows: 1fr;
  overflow: hidden;
}
#chatView .messages { overflow-y: auto; overscroll-behavior: contain; }

.view-heading {
  display: grid;
  gap: 2px;
}
.drillable-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
}
.drillable-heading > div:first-child { display: grid; gap: 2px; min-width: 0; }
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
}
.view-heading h2 { font-size: 24px; color: var(--brand-2); }
/* Drop the orange eyebrow above each view title (redundant with the big title).
   Card-level eyebrows (e.g. "Left today", "Risk") live outside .view-heading and stay. */
.view-heading .eyebrow { display: none; }

.view-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.view-back,
.view-add {
  display: none;
  align-items: center;
  gap: 4px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.view-back { padding: 0 12px 0 8px; }
.view-add {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: var(--brand-grad);
  color: #fff;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.32);
}
.view-back svg,
.view-add svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.view-add svg { width: 16px; height: 16px; }
.view-back:hover { background: var(--soft); border-color: var(--line-strong); }
.view-add:hover { transform: translateY(-1px); }
/* Show back button when drilled into any sub-panel */
.app-view:has(.split-workspace.drill-open) .view-back { display: inline-flex; }
/* Show add button only when drilled into a panel that has an add-target */
.app-view:has(.split-workspace.drill-open .content-panel.active[data-add-target]) .view-add { display: inline-flex; }
/* Form panels (those with data-back-target but no data-add-target) get a Save button */
/* Top-right Save removed for form panels — the bottom submit button is
   the single save action now. */
.view-save {
  display: none;
  align-items: center;
  gap: 4px;
  height: 32px;
  width: auto;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--brand-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.32);
  transition: transform var(--dur) var(--ease);
}
.view-save:hover { transform: translateY(-1px); }
.view-save svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Form panels: one save button at the bottom only. Hide the secondary
   "新增/Reset" button (users can go back + tap + to start a new entry)
   and hide the redundant top-right Save (.view-save). */
.content-panel.active[data-back-target]:not([data-add-target]) .form-actions:not(.form-actions--edit) {
  margin-top: 14px;
  grid-template-columns: 1fr;
}
.content-panel.active[data-back-target]:not([data-add-target]) .form-actions:not(.form-actions--edit) .secondary-button {
  display: none;
}
/* --edit 布局:编辑/新增态都显示 取消(左) + 保存(右) */
.content-panel.active[data-back-target]:not([data-add-target]) .form-actions--edit { margin-top: 14px; }

/* Hide the inline drill-toolbar entirely — replaced by .view-actions in heading */
.content-panel > .drill-toolbar { display: none !important; }
.transaction-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}
.section-heading {
  display: grid;
  gap: 4px;
  margin: 4px 0 4px;
}
.section-heading p { font-size: 13px; color: var(--muted); }
.section-heading.compact { margin: 0; }
/* 标题右上角动作按钮(如固定费用"提前结束") */
.section-heading:has(.header-action) { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.header-action {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.header-action:hover { background: var(--hover); }

/* ── 6. Cards (base) ───────────────────────────────────────────── */
.overview-hero,
.saving-hero,
.overview-panel,
.settings-card,
.tool-card,
.radar-card,
.transaction-cashflow-card,
.bill-card,
.budget-item,
.account-item,
.paylater-item,
.fixed-cost-item,
.transaction-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ── 7. Overview view (Bento) ──────────────────────────────────── */
#overviewView { gap: 14px; }

.overview-hero {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 18px 18px 16px;
  color: var(--hero-ink);
  background: var(--hero-bg);
  border: 0;
  box-shadow: 0 14px 38px rgba(10, 8, 4, 0.42);
  overflow: hidden;
}
.overview-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -30%;
  width: 80%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--brand-ring), transparent 70%);
  pointer-events: none;
}
.overview-hero::after {
  content: "";
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(34, 211, 238, 0.28), transparent 70%);
  pointer-events: none;
}
.overview-greeting { display: grid; gap: 8px; min-width: 0; position: relative; z-index: 1; }
.overview-greeting > span:first-child {
  font-size: 12px;
  color: var(--hero-muted);
  font-weight: 600;
}
.overview-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
#overviewMotivation {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--hero-ink);
}
#overviewDailyStory { font-size: 12px; color: var(--hero-muted); line-height: 1.5; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--hero-ink);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.overview-safe {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.overview-safe > div:first-child .eyebrow {
  color: var(--hero-muted);
  letter-spacing: 0.12em;
}
#todaySpendable {
  display: block;
  font-family: var(--font-sans);
  font-size: clamp(36px, 10vw, 48px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
  margin-top: 4px;
  background: linear-gradient(120deg, #ffffff 0%, var(--brand-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-feature-settings: "tnum", "lnum";
}
.daily-allowance-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.daily-allowance-row > span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--hero-soft);
  border: 1px solid var(--hero-line);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
}
.daily-allowance-row small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--hero-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.daily-allowance-row b {
  font-feature-settings: "tnum", "lnum";
  font-weight: 800;
  font-size: 16px;
  color: var(--hero-ink);
  letter-spacing: -0.02em;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  position: relative;
  z-index: 1;
}
.overview-metrics > span {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: var(--hero-soft);
  border: 1px solid var(--hero-line);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
}
.overview-metrics small,
.overview-extra small,
.saving-stats small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.overview-metrics small {
  color: var(--hero-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
  font-weight: 700;
}
.overview-metrics b {
  font-feature-settings: "tnum", "lnum";
  font-weight: 800;
  font-size: 15px;
  color: var(--hero-ink);
  letter-spacing: -0.02em;
}
.overview-extra b,
.saving-stats b {
  font-feature-settings: "tnum", "lnum";
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-strong);
}

.meter {
  position: relative;
  height: 6px;
  background: var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 35%, #34d399 75%, #10b981 100%);
  border-radius: inherit;
  transition: width 380ms var(--ease);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.6);
}
.overview-meter { z-index: 1; background: rgba(255, 255, 255, 0.18); }
#healthCopy { font-size: 13px; font-weight: 700; color: var(--hero-muted); position: relative; z-index: 1; }
#healthCopy { display: inline-flex; align-items: center; gap: 7px; }
#healthCopy.risk-low { color: var(--green); }
#healthCopy.risk-medium { color: var(--yellow); }
#healthCopy.risk-high { color: var(--red); }
#healthCopy .risk-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 currentColor;
  animation: riskPulse 1.4s ease-in-out infinite;
}
@keyframes riskPulse {
  0%   { opacity: 1;   box-shadow: 0 0 0 0 currentColor; }
  70%  { opacity: 0.4; box-shadow: 0 0 0 6px transparent; }
  100% { opacity: 1;   box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { #healthCopy .risk-dot { animation: none; } }

/* saving hero */
.saving-hero {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  background:
    radial-gradient(140% 70% at 100% 0%, rgba(16, 185, 129, 0.32), transparent 55%),
    linear-gradient(135deg, var(--card) 0%, #ecfdf5 60%, #d1fae5 100%);
  border-color: rgba(16, 185, 129, 0.35);
  overflow: hidden;
}
.saving-hero::after {
  content: "";
  position: absolute;
  bottom: -30%;
  right: -10%;
  width: 50%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(52, 211, 153, 0.35), transparent 70%);
  pointer-events: none;
}
.saving-hero > * { position: relative; z-index: 1; }
.saving-hero > div:first-child { display: grid; gap: 4px; }
.saving-hero .eyebrow {
  color: var(--ok);
  letter-spacing: 0.12em;
}
#overviewSavedAmount {
  display: block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ok);
  font-feature-settings: "tnum", "lnum";
}
#overviewSavedMessage { font-size: 12px; color: var(--muted-strong); line-height: 1.45; }
.saving-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.saving-stats > span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: var(--radius-sm);
}
.saving-stats b {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ok);
}
/* Saver rank stat: title is a chip-like badge, percentile fits in small */
.saving-stats .saver-rank b {
  font-size: 16px;
  line-height: 1.2;
}

/* Dark mode: rework saving hero so the green text is readable on a
   dark card instead of being lost in a washed-out gradient. */
:root[data-theme="dark"] .saving-hero {
  background:
    radial-gradient(140% 70% at 100% 0%, rgba(16, 185, 129, 0.20), transparent 55%),
    linear-gradient(135deg, #0a2018 0%, #0d2a1c 60%, #0f3424 100%);
  border-color: rgba(52, 211, 153, 0.32);
}
:root[data-theme="dark"] .saving-hero .eyebrow,
:root[data-theme="dark"] #overviewSavedAmount,
:root[data-theme="dark"] .saving-stats b {
  color: #34d399;
}
:root[data-theme="dark"] #overviewSavedMessage {
  color: rgba(226, 245, 234, 0.78);
}
:root[data-theme="dark"] .saving-stats > span {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(52, 211, 153, 0.22);
}
:root[data-theme="dark"] .saving-stats small {
  color: rgba(167, 212, 191, 0.80);
  font-feature-settings: "tnum", "lnum";
}

/* Bento grid */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.overview-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
}
.overview-panel > span:first-child {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.focus-list { display: grid; gap: 8px; }
.focus-list span {
  position: relative;
  padding: 10px 12px 10px 30px;
  background: var(--soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.focus-list span::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-grad);
  transform: translateY(-50%);
}

.safe-extra,
.overview-extra {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.overview-extra > span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: var(--radius-sm);
}

/* ── 8. Transactions view ─────────────────────────────────────── */
.cashflow-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1.5px solid var(--brand-2);
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 6px var(--brand-soft);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 0.1s var(--ease);
}
/* Trend-line icon (i18n replaces textContent, so draw it via ::before mask) */
.cashflow-chip::before {
  content: "";
  width: 17px; height: 17px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17l5-5 4 3 7-8'/%3E%3Cpath d='M17 4h4v4'/%3E%3C/svg%3E");
  mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17l5-5 4 3 7-8'/%3E%3Cpath d='M17 4h4v4'/%3E%3C/svg%3E");
}
.cashflow-chip:active { transform: scale(0.97); }
.cashflow-chip[aria-expanded="true"],
.cashflow-chip:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}

.transaction-cashflow-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  margin-bottom: 4px;
}
.transaction-tools-row {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.filter-tabs,
.range-tabs {
  display: inline-flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: var(--radius-pill);
}
.filter-tabs::-webkit-scrollbar,
.range-tabs::-webkit-scrollbar { display: none; }
.filter-tabs button,
.range-tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  white-space: nowrap;
}
.filter-tabs button.active,
.range-tabs button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15,23,42,0.18);
}
:root[data-theme="dark"] .filter-tabs button.active,
:root[data-theme="dark"] .range-tabs button.active {
  background: var(--brand-grad);
}

/* ── Tab unification ──────────────────────────────────────────────────────
   Every segmented control (money/bills, reimburse, referral) uses the same
   active pill as the transactions (流水) filter-tabs — dark "ink" in light mode,
   brand gradient in dark mode — so tab colors are consistent across screens.
   These come after the per-control rules above, so they win on source order. */
.money-tabs button.active,
.reimburse-tabs button.active,
.referral-tabs button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}
:root[data-theme="dark"] .money-tabs button.active,
:root[data-theme="dark"] .reimburse-tabs button.active,
:root[data-theme="dark"] .referral-tabs button.active {
  background: var(--brand-grad);
  color: #fff;
}

/* Segmented control: fixed-column grid that fills width.
   Number of columns is determined by the tab's specific class. */
.filter-tabs.transaction-type-tabs,
[role="tablist"].filter-tabs.transaction-type-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.filter-tabs.account-filter-tabs,
[role="tablist"].filter-tabs.account-filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.filter-tabs.transaction-type-tabs button,
.filter-tabs.account-filter-tabs button { width: 100%; }

/* Default fallback for any other tablist filter-tabs (2 columns) */
[role="tablist"].filter-tabs:not(.transaction-type-tabs):not(.account-filter-tabs) {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
[role="tablist"].filter-tabs:not(.transaction-type-tabs):not(.account-filter-tabs) button {
  width: 100%;
}

.transaction-ranges { width: 100%; }

.custom-date-range {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.custom-date-range label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.custom-date-range input[type="date"] {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
}
.custom-date-range button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-grad);
  color: #fff;
  font-weight: 700;
  align-self: end;
}

.transaction-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 4px 0;
}
.transaction-search input {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.transaction-search input::placeholder { color: var(--muted); }
.transaction-search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.transaction-search button {
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.transaction-list {
  display: grid;
  gap: 8px;
}

/* Pre-accounting (预记账): pending income/bills awaiting confirmation. */
.pending-ledger {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--brand-ring, var(--line));
  border-radius: var(--radius-md);
  background: var(--brand-soft);
}
.pending-ledger[hidden] { display: none; }
.pending-head { font-size: 12px; font-weight: 800; color: var(--brand); text-transform: uppercase; letter-spacing: 0.04em; }
.pending-toggle { width: 100%; margin-top: 2px; border: 0; background: transparent; color: var(--brand); font-size: 12.5px; font-weight: 700; padding: 6px; cursor: pointer; border-radius: 8px; }
.pending-toggle:active { background: var(--brand-soft); }
.pending-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--line);
}
.pending-info { min-width: 0; display: grid; gap: 2px; }
.pending-name { font-size: 14px; font-weight: 700; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-meta { font-size: 11px; color: var(--muted); }
.pending-amt { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pending-amt.in { color: var(--success, #16a34a); }
.pending-amt.out { color: var(--danger); }
.pending-confirm {
  flex: 0 0 auto;
  height: 32px; padding: 0 14px;
  border: 0; border-radius: var(--radius-pill);
  background: var(--brand-grad); color: #fff;
  font-size: 12px; font-weight: 800; cursor: pointer;
}
.pending-dismiss {
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: var(--soft); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}

.transaction-item,
.paylater-item,
.fixed-cost-item {
  position: relative;
  display: grid;
  gap: 10px;
}
/* Whole-card tap target (e.g. expected-income / account rows open the editor). */
.fixed-cost-item.is-tappable,
.account-item.is-tappable { cursor: pointer; }
.app-header .brand.is-tappable { cursor: pointer; }
.fixed-cost-item.is-tappable:active,
.account-item.is-tappable:active { background: var(--hover); border-radius: var(--radius-sm); }
.swipe-row > .swipe-content > .row,
.fixed-cost-item:not(.swipe-row) > .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.swipe-row > .swipe-content > .row > div,
.fixed-cost-item:not(.swipe-row) > .row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.tx-name,
.paylater-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-meta,
.paylater-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-code {
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.transaction-item .swipe-content { -webkit-user-select: none; user-select: none; }

.tx-reimburse-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.tx-reimburse-badge.pending {
  background: rgba(255, 87, 34, 0.14);
  color: var(--brand);
}
.tx-reimburse-badge.received {
  background: rgba(16, 185, 129, 0.16);
  color: #059669;
}

/* Loan / fixed-cost lifecycle badge ("已还清" / "已结束") */
.lifecycle-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.lifecycle-badge.done {
  background: rgba(100, 116, 139, 0.18);
  color: var(--muted);
}
.paylater-item.is-done,
.fixed-cost-item.is-done {
  opacity: 0.55;
}
.paylater-item.is-done strong,
.fixed-cost-item.is-done strong {
  text-decoration: line-through;
  text-decoration-color: rgba(100, 116, 139, 0.5);
}
.paylater-item.is-done .paylater-progress span,
.fixed-cost-item.is-done .paylater-progress span {
  background: var(--muted);
}

.transaction-item.expense strong { color: var(--danger); }
.transaction-item.income strong { color: var(--ok); }
.transaction-item strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

/* category color rail on transaction items */
.transaction-item.swipe-row { position: relative; }
.transaction-item.swipe-row > .swipe-content { padding-left: 16px; }
.transaction-item.swipe-row > .swipe-content::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 999px;
  background: var(--cat-other);
}
.transaction-item.cat-food > .swipe-content::before { background: var(--cat-food); }
.transaction-item.cat-transport > .swipe-content::before { background: var(--cat-transport); }
.transaction-item.cat-shopping > .swipe-content::before { background: var(--cat-shopping); }
.transaction-item.cat-fun > .swipe-content::before { background: var(--cat-fun); }
.transaction-item.cat-bills > .swipe-content::before { background: var(--cat-bills); }
.transaction-item.cat-saving > .swipe-content::before { background: var(--cat-saving); }
.transaction-item.cat-debt > .swipe-content::before { background: var(--cat-debt); }
.transaction-item.cat-income > .swipe-content::before { background: var(--cat-income); }
.transaction-item.cat-travel > .swipe-content::before { background: var(--cat-travel); }
.transaction-item.cat-medical > .swipe-content::before { background: var(--cat-medical); }
.transaction-item.cat-education > .swipe-content::before { background: var(--cat-education); }
.transaction-item.cat-entertainment > .swipe-content::before { background: var(--cat-entertainment); }
.transaction-item.cat-insurance > .swipe-content::before { background: var(--cat-insurance); }
.transaction-item.cat-maintenance > .swipe-content::before { background: var(--cat-maintenance); }
.transaction-item.cat-rent > .swipe-content::before { background: var(--cat-rent); }
.transaction-item.cat-telecom > .swipe-content::before { background: var(--cat-telecom); }
.transaction-item.cat-utilities > .swipe-content::before { background: var(--cat-utilities); }
.transaction-item.cat-tax > .swipe-content::before { background: var(--cat-tax); }
.transaction-item.cat-gift > .swipe-content::before { background: var(--cat-gift); }
.transaction-item.cat-pet > .swipe-content::before { background: var(--cat-pet); }
.transaction-item.cat-fitness > .swipe-content::before { background: var(--cat-fitness); }

.paylater-item strong,
.fixed-cost-item strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.detail-grid > span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.detail-grid b {
  font-feature-settings: "tnum", "lnum";
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-strong);
}

.paylater-progress {
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  overflow: hidden;
}
.paylater-progress > span {
  display: block;
  height: 100%;
  background: var(--brand-grad);
  transition: width 380ms var(--ease);
}
.paylater-progress.warn > span { background: var(--warn-grad); }
.paylater-progress.danger > span { background: var(--danger-grad); }
/* Progress bar + percentage label on one row. */
.progress-row { display: flex; align-items: center; gap: 8px; }
.progress-row .paylater-progress { flex: 1; }
.progress-pct {
  font-feature-settings: "tnum", "lnum";
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-strong);
  min-width: 34px;
  text-align: right;
}

/* Card footer: snooze ("remind next month") on the left, Edit on the right. */
.card-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-snooze {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card-snooze.is-snoozed {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand);
}
.card-action {
  align-self: start;
  justify-self: start;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}
.card-action:hover { background: var(--hover); }
/* Chevron affordance on whole-card-tappable rows (income / account / reimburse).
   Replaces the old "Edit" pill now that the entire card opens the editor. */
.card-chevron {
  align-self: center;
  justify-self: end;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  flex: 0 0 auto;
}
.save-action {
  border: 0;
  background: var(--ok-soft);
  color: var(--ok);
}

/* swipe-to-delete */
.swipe-row {
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
}
.swipe-row > .swipe-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--card);
  transition: transform 220ms var(--ease);
}
.swipe-row .swipe-delete {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 0;
  display: grid;
  place-items: center;
  min-width: 86px;
  padding: 0 18px;
  border: 0;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.swipe-row.open > .swipe-content { transform: translateX(-86px); }

.empty-copy {
  padding: 22px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

/* ── 9. Cashflow chart ────────────────────────────────────────── */
.cashflow-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.cashflow-dimension {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: var(--soft);
  border-radius: var(--radius-sm);
}
.cashflow-dimension > span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cashflow-dimension > strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-strong);
}
.cashflow-dimension > small { font-size: 11px; color: var(--muted); }
.cashflow-dimension > strong.cashflow-in { color: var(--success, #16a34a); }
.cashflow-dimension > strong.cashflow-out { color: var(--danger); }

.cashflow-chart {
  display: grid;
  align-items: stretch;
  gap: 4px;
  height: 188px;
  padding: 10px 8px 8px;
  background: var(--soft);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  scrollbar-width: thin;
}
.cashflow-day {
  display: grid;
  grid-template-rows: 1fr auto auto;
  justify-items: center;
  align-items: end;
  gap: 4px;
  min-width: 46px;
  height: 100%;
}
.cashflow-bar {
  width: 70%;
  align-self: end;
  border-radius: 6px 6px 2px 2px;
  background: var(--brand-grad);
  transition: height 380ms var(--ease);
}
.cashflow-bar.warn { background: linear-gradient(180deg, #f59e0b, #d97706); }
.cashflow-bar.danger { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.cashflow-label {
  font-feature-settings: "tnum", "lnum";
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.cashflow-value {
  font-feature-settings: "tnum", "lnum";
  font-size: 9px;
  color: var(--ink);
  white-space: nowrap;
}

.radar-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}
.radar-card .eyebrow { color: var(--muted); }
.radar-risk { display: inline-flex; align-items: center; gap: 8px; }
/* 现金流卡片底部"收起"按钮(Keluar 上方),点了收起整个 cashflow 卡片 */
/* 收起:极简箭头,无框无底色 */
.cashflow-collapse { display: flex; align-items: center; justify-content: center; width: 100%; margin-top: 2px; height: 30px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.cashflow-collapse svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cashflow-collapse:hover { color: var(--ink); }
#riskBadge,
.risk-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--info-soft);
  color: var(--info);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-top: 4px;
  border: 1px solid currentColor;
}
.risk-value::before,
#riskBadge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.risk-value.safe { background: var(--ok-soft); color: var(--ok); border-color: rgba(5, 150, 105, 0.4); }
.risk-value.warning { background: var(--warn-soft); color: var(--warn); border-color: rgba(217, 119, 6, 0.4); }
.risk-value.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.4);
  animation: dangerPulse 1.6s ease-in-out infinite;
}
@keyframes dangerPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.radar-card p { font-size: 12px; color: var(--muted); }

/* ── 10. Bills view (split workspace) ─────────────────────────── */
/* Default: mobile drill pattern (one column, menu OR content) */
.split-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  position: relative;
}
.side-menu {
  display: grid;
  align-content: start;
  gap: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.side-menu button {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 14px;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  letter-spacing: -0.005em;
  transition: background var(--dur) var(--ease);
}
.side-menu button + button { border-top: 1px solid var(--line); border-radius: 0; }
/* The first VISIBLE row must not show a divider: hidden leading buttons (the
   desktop nav, or the money/bills section toggled off) would otherwise leave an
   orphan top line that doubles with the card border ("2 lines at the top").
   JS (normalizeSideMenuDividers) tags the first visible button. */
.side-menu button.is-first-visible { border-top: 0; }
/* Selected/hover highlight: a rounded pill inset evenly inside the row (4px all
   around), consistent on every row — not a flush, square, edge-touching block.
   The button is its own stacking context (z-index:0) and the ::before sits at
   z-index:-1, so it paints above the transparent button bg but BEHIND the label
   (works even for buttons whose label is a bare text node). */
.side-menu button { z-index: 0; }
.side-menu button::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: background var(--dur) var(--ease);
  z-index: -1;
}
.side-menu button:hover::before,
.side-menu button:active::before,
.side-menu button.active::before { background: var(--soft); }
.side-menu button > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-menu button strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--muted-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.side-menu button::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-top: 2px solid var(--muted);
  transform: rotate(45deg);
  /* Always sit in column 3 of the grid so items without a strong value
     (汇总报表 / 设置) still align with items that have one. */
  grid-column: 3;
  justify-self: end;
}
.side-menu button.active strong { color: var(--brand); }
/* Subscription row: AI quota pill sits left of the plan name (both in grid col 2). */
.side-menu button > span.menu-value-group {
  grid-column: 2;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}
.menu-quota-pill {
  font-feature-settings: "tnum", "lnum";
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-2);
  background: var(--brand-soft);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Mobile drill: menu visible by default, content panels hidden until drill-open */
.side-content {
  display: grid;
  gap: 12px;
  min-width: 0;
  align-content: start;
}
.content-panel { display: none; gap: 12px; }
.content-panel.active {
  display: grid;
  grid-auto-rows: min-content;
  align-content: start;
  animation: viewIn 0.18s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Default (mobile-first): hide side-content when not drilled-in */
.split-workspace:not(.drill-open) .side-content { display: none; }
.split-workspace.drill-open .side-menu { display: none; }

/* Add a soft slide-in animation when drilling */
.split-workspace.drill-open .side-content { animation: drillIn 220ms var(--ease); }
@keyframes drillIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Drill pattern: always menu-OR-content, regardless of viewport.
   Focuses attention on one task at a time on every screen. */

.drill-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin: -4px 0 4px;
}
.drill-toolbar:empty { display: none; }
.drill-back,
.drill-add {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted-strong);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.drill-back::before {
  content: "‹ ";
  margin-right: 2px;
  font-weight: 800;
}
.drill-add::before {
  content: "+ ";
  margin-right: 2px;
  font-weight: 800;
}
.drill-add {
  background: var(--brand-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.32);
}
.drill-add:hover { transform: translateY(-1px); }
.drill-back:hover { background: var(--hover); color: var(--ink); }
/* Hide add button on panels without add-target */
.content-panel:not([data-add-target]) > .drill-toolbar > .drill-add { display: none; }
/* Inline drill-back chip is replaced by top-right .view-back button */
.content-panel > .drill-toolbar > .drill-back { display: none; }

.bill-summary-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.bill-summary-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  min-width: 0;
}
.bill-summary-card > strong { grid-row: 1 / 3; grid-column: 2; align-self: center; }
.bill-summary-card > small { grid-column: 1; }
.bill-summary-card > span:first-child {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}
.bill-summary-card > strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bill-summary-card > small { font-size: 11px; color: var(--muted); }

.bill-table { display: grid; gap: 4px; }
.bill-table-head { display: none; }
.bill-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 12px;
}
.bill-table-row--link { cursor: pointer; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.bill-table-row--link:hover { border-color: var(--brand); }
.bill-table-row--link:active { background: var(--soft); }
.bill-table-row > span:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bill-table-row > span:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bill-table-row > span:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.bill-table-row > strong {
  grid-column: 2;
  grid-row: 1;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink-strong);
  font-feature-settings: "tnum", "lnum";
  white-space: nowrap;
}
.bill-table-row > span { min-width: 0; }
.bill-table-row > span > b {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bill-table-row > span > small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.bill-table-row strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 13px;
  color: var(--ink-strong);
  text-align: right;
}

.paylater-list,
.fixed-cost-list,
.income-list {
  display: grid;
  gap: 8px;
}

/* Compact list cards: hide redundant detail-grid; collapse edit button into
   a chevron-style chip at top-right corner inline with the amount. */
.income-item .detail-grid {
  display: none;
}
/* Paylater + fixed-cost detail grids stay visible — they show contract
   info (months / payment day / end date) the user explicitly asked for. */
.income-item,
.fixed-cost-item:not(.income-item),
.paylater-item,
.account-item,
.transaction-item {
  position: relative;
}
/* Tap-anywhere list cards: name+meta+amount inline, chevron at far right,
   the whole card is clickable. The original "编辑" button collapses into a
   decorative chevron icon for cleaner look + bigger tap target.
   NOTE: must NOT apply to .swipe-row — that pattern needs the article to
   stay padding:0 + overflow:hidden so the absolutely-positioned
   .swipe-delete sits beneath .swipe-content cleanly. */
.income-item,
.fixed-cost-item.income-item,
.account-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 16px;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.income-item:hover,
.account-item:hover { background: var(--soft); }

/* Edit pill on bill swipe rows (fixed costs + loans share the same style).
   Self-contained so it isn't squashed by .fixed-cost-item .card-action's
   font-size:0 / width:20px chevron rule defined earlier. */
.fixed-cost-item.swipe-row > .swipe-content > .card-action,
.paylater-item.swipe-row > .swipe-content > .card-action {
  position: static;
  align-self: end;
  justify-self: end;
  width: auto;
  min-width: 60px;
  height: 30px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 700;
  line-height: 28px;
  white-space: nowrap;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-ring);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.fixed-cost-item.swipe-row > .swipe-content > .card-action:hover,
.paylater-item.swipe-row > .swipe-content > .card-action:hover {
  background: var(--brand);
  color: #fff;
}
.fixed-cost-item.swipe-row > .swipe-content > .card-action::after,
.paylater-item.swipe-row > .swipe-content > .card-action::after { content: none; }
.income-item .card-action,
.account-item .card-action {
  position: static;
  margin: 0;
  height: 28px;
  width: 20px;
  padding: 0;
  font-size: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
/* 编辑按钮统一成与预算卡(图1)一致的描边胶囊,替掉原来的弱灰"编辑 ›"文字链 */
.paylater-item .card-action,
.fixed-cost-item .card-action {
  position: static;
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--ink);
  justify-self: end;
  margin-left: auto; /* snooze 隐藏时 Edit 仍靠右 */
}
.income-item .card-action::after,
.account-item .card-action::after {
  content: "›";
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}
.paylater-item .card-action::after,
.fixed-cost-item .card-action::after { content: none; }
.income-item:hover .card-action,
.account-item:hover .card-action {
  color: var(--brand);
}
.paylater-item .card-action:hover,
.fixed-cost-item .card-action:hover {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: var(--brand);
}

/* Income card: two-line layout with prominent amount + recurring badge.
   Override the .income-item grid (1fr+20px) defined earlier — for this
   variant the chevron lives inside line-1 next to the amount so the
   arrow visually aligns with the number instead of floating at the
   vertical middle of the whole card. */
.income-item {
  grid-template-columns: 1fr !important;
  align-items: stretch;
  gap: 8px;
  padding: 16px 14px 16px 18px;
}
/* Stacked income card: name / type·due / date stacked on the left, amount
   vertically centered on the right (so the amount isn't pinned to the top row). */
.income-item.income-item--stacked {
  display: flex;
  align-items: center;
  gap: 12px;
}
.income-item--stacked .income-stack-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.income-item--stacked .paylater-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.income-item--stacked .paylater-meta,
.income-item--stacked .paylater-date {
  font-size: 12px;
  color: var(--muted);
}
/* Amount + chevron travel together as one vertically-centered group on the
   right, so the number and the › always sit on the same line (parallel). */
.income-item--stacked .income-stack-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  align-self: center;
}
.income-item--stacked .income-stack-amount {
  font-feature-settings: "tnum", "lnum";
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cat-income);
  white-space: nowrap;
}
.income-item--stacked .income-stack-right .card-chevron { align-self: center; }
/* Amount on top, the 每月固定 badge directly under it, both right-aligned. */
.income-item--stacked .income-amount-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
}
.income-item--stacked .income-amount-col .income-badge { margin: 0; }

.income-item .income-line-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
}
.income-item .income-line-1 .paylater-name {
  align-self: center;
}
.income-item .income-line-1 > strong {
  align-self: center;
}
.income-item .income-line-1 .card-action {
  align-self: center;
  margin-left: 2px;
}
.income-item .income-line-1 .paylater-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.income-item .income-line-1 > strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cat-income);
  white-space: nowrap;
}
.income-item .income-line-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.income-item .income-line-2 .paylater-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}
.income-badge {
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--cat-income-soft);
  color: var(--cat-income);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid rgba(34, 197, 94, 0.28);
}
.income-badge.inline {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10px;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ── 11. Profile view ──────────────────────────────────────────── */
.profile-workspace { gap: 14px; }
.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.report-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  min-width: 0;
}
.report-card--link {
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.1s var(--ease);
}
.report-card--link:hover { border-color: var(--brand); background: var(--soft); }
.report-card--link:active { transform: scale(0.985); }
.report-card--link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ov-jump { cursor: pointer; }
.ov-jump:hover b, .ov-jump:hover strong { color: var(--brand-2); }
.report-card > span {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-card > strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-strong);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.report-charts { display: grid; gap: 10px; }
.report-chart {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.report-chart > span:first-child {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.report-chart .chart-copy { font-size: 12px; color: var(--muted); }
.mini-bars { display: grid; gap: 8px; }
.mini-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 4px 10px;
  align-items: center;
}
.mini-bar > b {
  grid-column: 1;
  grid-row: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-strong);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-bar > small {
  grid-column: 2;
  grid-row: 1;
  font-feature-settings: "tnum", "lnum";
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.mini-bar > .mini-track {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 6px;
  background: var(--soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.mini-bar > .mini-track > span {
  display: block;
  height: 100%;
  background: var(--brand-grad);
  border-radius: inherit;
  transition: width 380ms var(--ease);
}
/* 余额为负(透支)的账户:占比标红,条清空 */
.mini-bar.is-negative > small { color: var(--danger); }
.mini-bar.is-negative > .mini-track > span { background: var(--danger); }

.balance-overview { display: grid; gap: 0; }
.balance-overview-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 87, 34, 0.07), transparent 60%),
    var(--card);
}
.balance-overview-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.balance-overview-top > div:first-child { display: grid; gap: 4px; min-width: 0; }
.balance-overview-top .eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.balance-overview-top strong {
  font-size: clamp(15px, 4.8vw, 20px);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink-strong);
  font-feature-settings: "tnum", "lnum";
  line-height: 1.1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-ring {
  display: none; /* replaced by collapse button + filter dropdown */
}
.balance-overview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.balance-filter {
  height: 30px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><path d='M6 9l6 6 6-6' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 10px center;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}
.balance-collapse-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted-strong);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.balance-collapse-btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-ring);
}
.balance-collapse-btn svg { width: 16px; height: 16px; }
.balance-overview-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.balance-overview-stats > span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--soft);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 0;
}
.balance-overview-stats > span > b {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink-strong);
  text-transform: none;
  font-feature-settings: "tnum", "lnum";
  white-space: nowrap;
  text-align: right;
}
.balance-overview-card > p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.account-mix {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.account-mix > small {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.account-mix > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.account-mix span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap;
}
.account-mix span > i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}
.account-mix span > b {
  margin-left: auto;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
  font-feature-settings: "tnum", "lnum";
  white-space: nowrap;
}

/* Savings goal card (Profile → 余额) */
.savings-goal-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 20px 20px 18px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  color: var(--ink);
  background:
    radial-gradient(120% 70% at 0% 0%, rgba(16, 185, 129, 0.22), transparent 55%),
    radial-gradient(120% 70% at 100% 100%, rgba(34, 211, 238, 0.14), transparent 55%),
    linear-gradient(140deg, #f0fdf4 0%, #ecfdf5 55%, #d1fae5 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.10);
  overflow: hidden;
}
.savings-goal-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 60%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(52, 211, 153, 0.35), transparent 70%);
  pointer-events: none;
}
.savings-goal-card > * { position: relative; z-index: 1; }

.savings-goal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.savings-goal-head > div { min-width: 0; }
.savings-goal-head .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #047857;
  margin-bottom: 6px;
}
.savings-goal-icon { font-size: 14px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18)); }
.savings-goal-head strong {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #064e3b;
  font-feature-settings: "tnum", "lnum";
  line-height: 1.1;
}
.savings-goal-edit {
  flex-shrink: 0;
  height: 34px;
  padding: 0 18px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  background: #047857;
  color: #fff;
  border: 0;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.34);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.savings-goal-edit:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(5, 150, 105, 0.42); }

.savings-goal-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.savings-goal-stats > span {
  display: grid;
  gap: 4px;
  padding: 12px 12px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(6px);
}
.savings-goal-stats small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #047857;
}
.savings-goal-stats b {
  font-size: 13px;
  font-weight: 800;
  color: #064e3b;
  letter-spacing: -0.015em;
  font-feature-settings: "tnum", "lnum";
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Make Rp prefix inside the goal-stat tiles use the emerald accent so
   it doesn't disappear into the gradient surface. */
.savings-goal-stats b .rp-prefix {
  color: #047857;
  -webkit-text-fill-color: #047857;
  opacity: 0.75;
}
/* Spacing inside the progress block: stats grid → bar → note */
.savings-goal-progress {
  display: grid;
  gap: 14px;
}
/* Tall progress bar with overlaid percentage label */
.savings-goal-bar {
  position: relative;
  height: 32px;
  margin-top: 4px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(16, 185, 129, 0.18);
  overflow: hidden;
}
.savings-goal-bar-fill {
  display: block;
  height: 100%;
  min-width: 10px;
  background: linear-gradient(90deg, #34d399, #059669);
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.55);
  border-radius: inherit;
  transition: width 380ms var(--ease);
}
.savings-goal-bar-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #064e3b;
  font-feature-settings: "tnum", "lnum";
  /* tiny white halo so the % is legible on both filled + empty halves */
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.85), 0 0 2px rgba(255, 255, 255, 0.85);
  pointer-events: none;
}
.savings-goal-note {
  font-size: 12px;
  font-weight: 600;
  color: #047857;
}

/* Dark mode: rich emerald surface, mint highlights, glow */
:root[data-theme="dark"] .savings-goal-card {
  background:
    radial-gradient(120% 70% at 0% 0%, rgba(52, 211, 153, 0.18), transparent 55%),
    radial-gradient(120% 70% at 100% 100%, rgba(34, 211, 238, 0.10), transparent 55%),
    linear-gradient(140deg, #0a2018 0%, #0c2a1e 55%, #103325 100%);
  border-color: rgba(52, 211, 153, 0.32);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}
:root[data-theme="dark"] .savings-goal-card::after {
  background: radial-gradient(closest-side, rgba(52, 211, 153, 0.28), transparent 70%);
}
:root[data-theme="dark"] .savings-goal-head .eyebrow,
:root[data-theme="dark"] .savings-goal-stats small,
:root[data-theme="dark"] .savings-goal-note {
  color: #6ee7b7;
}
:root[data-theme="dark"] .savings-goal-head strong,
:root[data-theme="dark"] .savings-goal-stats b {
  color: #ecfdf5;
}
:root[data-theme="dark"] .savings-goal-edit {
  /* brighter mint so it reads as a solid CTA against the deep card */
  background: #34d399;
  color: #04201a;
  box-shadow: 0 4px 14px rgba(52, 211, 153, 0.45);
}
:root[data-theme="dark"] .savings-goal-edit:hover {
  background: #6ee7b7;
  box-shadow: 0 6px 18px rgba(110, 231, 183, 0.5);
}
:root[data-theme="dark"] .savings-goal-stats b .rp-prefix {
  color: #6ee7b7;
  -webkit-text-fill-color: #6ee7b7;
  opacity: 0.85;
}
:root[data-theme="dark"] .savings-goal-stats > span {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(52, 211, 153, 0.24);
}
:root[data-theme="dark"] .savings-goal-card .budget-bar {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(52, 211, 153, 0.20);
}
:root[data-theme="dark"] .savings-goal-bar {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(52, 211, 153, 0.22);
}
:root[data-theme="dark"] .savings-goal-bar-label {
  color: #ecfdf5;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.6), 0 0 2px rgba(0, 0, 0, 0.6);
}

.account-list { display: grid; gap: 8px; }
.account-item {
  display: grid;
  gap: 10px;
  padding: 14px;
}
.account-item .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.account-item .row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.account-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-item .account-type {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.account-item strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink-strong);
  white-space: nowrap;
}

.budget-grid { display: grid; gap: 8px; }
.budget-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  position: relative;
  --cat-color: var(--cat-other);
  --cat-color-soft: var(--cat-other-soft);
}
.budget-item.cat-food { --cat-color: var(--cat-food); --cat-color-soft: var(--cat-food-soft); }
.budget-item.cat-transport { --cat-color: var(--cat-transport); --cat-color-soft: var(--cat-transport-soft); }
.budget-item.cat-shopping { --cat-color: var(--cat-shopping); --cat-color-soft: var(--cat-shopping-soft); }
.budget-item.cat-fun { --cat-color: var(--cat-fun); --cat-color-soft: var(--cat-fun-soft); }
.budget-item.cat-bills { --cat-color: var(--cat-bills); --cat-color-soft: var(--cat-bills-soft); }
.budget-item.cat-saving { --cat-color: var(--cat-saving); --cat-color-soft: var(--cat-saving-soft); }
.budget-item.cat-debt { --cat-color: var(--cat-debt); --cat-color-soft: var(--cat-debt-soft); }
.budget-item.cat-travel { --cat-color: var(--cat-travel); --cat-color-soft: var(--cat-travel-soft); }
.budget-item.cat-medical { --cat-color: var(--cat-medical); --cat-color-soft: var(--cat-medical-soft); }
.budget-item.cat-education { --cat-color: var(--cat-education); --cat-color-soft: var(--cat-education-soft); }
.budget-item.cat-entertainment { --cat-color: var(--cat-entertainment); --cat-color-soft: var(--cat-entertainment-soft); }
.budget-item.cat-insurance { --cat-color: var(--cat-insurance); --cat-color-soft: var(--cat-insurance-soft); }
.budget-item.cat-maintenance { --cat-color: var(--cat-maintenance); --cat-color-soft: var(--cat-maintenance-soft); }
.budget-item.cat-rent { --cat-color: var(--cat-rent); --cat-color-soft: var(--cat-rent-soft); }
.budget-item.cat-telecom { --cat-color: var(--cat-telecom); --cat-color-soft: var(--cat-telecom-soft); }
.budget-item.cat-utilities { --cat-color: var(--cat-utilities); --cat-color-soft: var(--cat-utilities-soft); }
.budget-item.cat-tax { --cat-color: var(--cat-tax); --cat-color-soft: var(--cat-tax-soft); }
.budget-item.cat-gift { --cat-color: var(--cat-gift); --cat-color-soft: var(--cat-gift-soft); }
.budget-item.cat-pet { --cat-color: var(--cat-pet); --cat-color-soft: var(--cat-pet-soft); }
.budget-item.cat-fitness { --cat-color: var(--cat-fitness); --cat-color-soft: var(--cat-fitness-soft); }
.budget-item.cat-income { --cat-color: var(--cat-income); --cat-color-soft: var(--cat-income-soft); }
.budget-item.cat-reimbursement { --cat-color: var(--cat-reimbursement); --cat-color-soft: var(--cat-reimbursement-soft); }
.budget-item[data-budget-details] { cursor: pointer; }
.budget-item[data-budget-details]:hover { box-shadow: 0 8px 22px rgba(15, 23, 42, 0.10); }
.budget-item .row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.budget-item .row > .cat-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--cat-color-soft);
  border: 1px solid var(--cat-color);
  color: var(--cat-color);
  display: grid;
  place-items: center;
}
.cat-icon svg { width: 16px; height: 16px; display: block; }
.budget-item .row > div { min-width: 0; }
.budget-item h3 { font-size: 14px; }
.budget-item .account-type {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.budget-metrics {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.budget-metrics > span {
  font-feature-settings: "tnum", "lnum";
}
.budget-metrics > strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cat-color);
}
.budget-percent-row {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}
.budget-percent-row > strong {
  font-feature-settings: "tnum", "lnum";
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cat-color);
}
.budget-item.warn .budget-percent-row > strong { color: var(--warn); }
.budget-item.over .budget-percent-row > strong { color: var(--danger); }

.budget-bar {
  position: relative;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--soft);
  overflow: hidden;
}
.budget-bar > span {
  display: block;
  height: 100%;
  background: var(--cat-color);
  border-radius: inherit;
  transition: width 380ms var(--ease);
}
.budget-item.warn {
  border-color: rgba(217, 119, 6, 0.4);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), transparent 60%), var(--card);
}
.budget-item.warn .budget-bar > span { background: var(--warn-grad); }
.budget-item.warn .budget-metrics > strong { color: var(--warn); }
.budget-item.over {
  border-color: rgba(220, 38, 38, 0.42);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), transparent 60%), var(--card);
}
.budget-item.over .budget-bar > span { background: var(--danger-grad); }
.budget-item.over .budget-metrics > strong { color: var(--danger); }

/* Monthly / yearly billing toggle above the plan cards */
.billing-cycle {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 12px;
  background: var(--soft);
  border-radius: var(--radius-sm);
}
.billing-cycle button {
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: calc(var(--radius-sm) - 3px);
  background: transparent;
  color: var(--muted-strong);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.billing-cycle button.active {
  background: var(--bg);
  color: var(--ink-strong);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}
.billing-save {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-2);
  background: var(--brand-soft);
  padding: 1px 6px;
  border-radius: 999px;
}
.plan-grid {
  display: grid;
  gap: 10px;
}
.plan-card {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  color: var(--ink);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* Left metallic accent bar, tinted per tier */
.plan-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--tier-grad, var(--line));
}
.plan-badge {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tier-grad, linear-gradient(135deg, #d6dae0, #a9aeb7));
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.7),
    inset 0 -2px 3px rgba(0,0,0,0.18),
    0 1px 2px rgba(0,0,0,0.15);
}
.plan-badge svg { width: 20px; height: 20px; fill: rgba(0,0,0,0.52); }
.plan-info { display: grid; gap: 3px; min-width: 0; }
.plan-name {
  font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.plan-price {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.02em; font-feature-settings: "tnum", "lnum";
}
.plan-info small { font-size: 12px; color: var(--muted); }
.plan-per { font-size: 13px; font-weight: 600; color: var(--muted); }
.plan-expiry { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.plan-name-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-current {
  display: none;
  align-self: center;
  font-size: 10px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  background: var(--brand); color: #fff;
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
.plan-card.active {
  border-color: var(--brand-2);
  background:
    linear-gradient(135deg, var(--brand-soft), transparent 60%),
    var(--card);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.plan-card.active .plan-current { display: none; } /* active card already highlighted; AKTIF badge removed for a cleaner look */

/* Tier metals — deliberately spread across lightness AND hue so free / silver
   / platinum no longer read as the same grey. */
.plan-card--free     { --tier-grad: linear-gradient(135deg, #ff8a5c, #ff5722 55%, #e8430a); }
.plan-card--silver   { --tier-grad: linear-gradient(135deg, #ffffff 0%, #c4c9d2 34%, #eef1f5 50%, #9098a3 72%, #dfe3e9 100%); }
.plan-card--gold     { --tier-grad: linear-gradient(135deg, #fff4cc 0%, #e3b53c 40%, #fff7d6 54%, #c5901a 80%, #f1c84e 100%); }
.plan-card--platinum { --tier-grad: linear-gradient(135deg, #4a4e5a, #0d0e13 45%, #5a5f6e 60%, #15161c); }

/* Free uses the brand blue (glossy like the metal tiers), white icon on top */
.plan-card--free .plan-badge svg { fill: rgba(255,255,255,0.92); }

/* Platinum = black diamond: dark facets + iridescent sheen, lifted off the
   dark card with a bright rim + faint colored glow so it never melts in. */
.plan-card--platinum .plan-badge {
  background:
    radial-gradient(circle at 30% 25%, rgba(120,200,255,0.40), transparent 46%),
    radial-gradient(circle at 72% 72%, rgba(200,140,255,0.34), transparent 52%),
    linear-gradient(135deg, #3a3d47, #0d0e13 45%, #4a4e5a 60%, #15161c);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.28),
    inset 0 -2px 3px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,255,255,0.16),
    0 0 12px rgba(150,170,255,0.28);
}
.plan-card--platinum .plan-badge svg { fill: #eef2ff; }

.option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--soft);
}
.option-grid button {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0 4px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--muted-strong);
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.option-grid button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}
:root[data-theme="dark"] .option-grid button.active {
  background: var(--brand-grad);
  color: #fff;
}

.avatar-card { display: grid; gap: 12px; padding: 16px; min-width: 0; }
.avatar-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}
.avatar-row > div { min-width: 0; }
.avatar-row strong { font-size: 14px; }
.avatar-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.chat-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--soft);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
}
.chat-avatar .avatar-emoji,
.chat-avatar .avatar-twemoji {
  width: 36px;
  height: 36px;
  display: block;
  /* Soft drop shadow makes the character feel like it floats above the chip */
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}
.chat-avatar .avatar-emoji {
  font-size: 32px;
  line-height: 1;
  width: auto;
  height: auto;
}
.chat-avatar.custom {
  background: var(--card);
}
.chat-avatar.custom img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* Bundled persona×tone portrait fills the whole circle (overrides the 36px emoji
   sizing of .avatar-twemoji); top crop keeps the head in frame. When the asset is
   missing, __avatarFallback strips this class and restores the emoji styling. */
.chat-avatar .avatar-portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  border-radius: inherit;
  filter: none;
  /* Settings preview: scale the whole portrait DOWN a touch so the full head
     (incl. hair) always shows and the rounded corners never bite the top. */
  transform: scale(0.95);
}
/* Chat chip should look FULL. The portraits are square with studio padding above
   the head, so cover (square→square) renders that empty space and the subject
   looks small. Zoom in on the face/upper-body (focal point ~30% down) so the
   padding is cropped away while the hairline stays just inside the frame. */
.message .chat-avatar .avatar-portrait {
  /* Show the WHOLE portrait (full body), not a zoomed-in crop. */
  object-fit: contain;
  transform: none;
}
.chat-avatar .avatar-face {
  display: block;
  width: 100%;
  height: 100%;
}
.chat-avatar .avatar-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.avatar-upload {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  text-align: center;
  overflow: hidden;
}
.avatar-upload input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.switch-row:first-child,
.input-row:first-child { border-top: 0; padding-top: 0; }
.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.input-row strong { display: block; font-size: 14px; }
.input-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
/* The "current time in {tz}" line is a 3rd grid child — left as-is it gets jammed
   into the 1fr label column and clips against the select. Span both columns so the
   localized "{tz} · {date} {time}" string (length varies a lot by language) has the
   full row width to sit on, with breathing room above. */
.input-row .emergency-fund-hint {
  grid-column: 1 / -1;
  margin-top: 8px;
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.input-row .emergency-fund-hint > span:last-child { color: var(--muted-strong); white-space: nowrap; }
.input-row input {
  width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.input-row select {
  width: 100%;
  min-width: 168px;
  max-width: 210px;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background-color: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  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='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 15px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-row select:hover { border-color: var(--brand); }
.input-row select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Brief fade across amount displays right after a currency switch, so the
   whole sheet visibly "re-renders" instead of numbers snapping silently. */
@keyframes currencyFlash {
  from { opacity: .5; }
  to   { opacity: 1; }
}
.currency-flash .rp-line,
.currency-flash [id$="Money"],
.currency-flash [id$="Amount"],
.currency-flash [id$="Total"],
.currency-flash .amount,
.currency-flash .transaction-item small {
  animation: currencyFlash .38s ease;
}
.switch-row strong { display: block; font-size: 14px; }
.switch-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch-row input[type="checkbox"] {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.switch-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform var(--dur) var(--ease);
}
.switch-row input[type="checkbox"]:checked { background: var(--brand-grad); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(18px); }

.privacy-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 87, 34, 0.25);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 87, 34, 0.08), rgba(59, 130, 246, 0.05)),
    var(--card);
}
.privacy-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--brand-grad);
  color: #fff;
  flex-shrink: 0;
}
.privacy-icon svg { width: 20px; height: 20px; }
.privacy-card strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.privacy-card p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.reset-button {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--danger);
  font-weight: 700;
}
.reset-button:hover { background: var(--danger-soft); }

.usage-copy { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── 12. Forms ─────────────────────────────────────────────────── */
.finance-form { display: grid; gap: 10px; }
/* Two fields side by side (e.g. payment day + contract length). */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.form-row-2 > label { display: grid; gap: 6px; min-width: 0; }
#fixedCostEndDateRow[hidden] { display: none; }

/* Income: 每月固定 toggle on the left, Save on the right. */
.income-save-row { display: flex; align-items: flex-end; gap: 12px; margin-top: 2px; }
.income-monthly-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
}
.income-monthly-switch input[type="checkbox"],
input.pill-switch[type="checkbox"],
.default-check input[type="checkbox"] {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.income-monthly-switch input[type="checkbox"]::after,
input.pill-switch[type="checkbox"]::after,
.default-check input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform var(--dur) var(--ease);
}
.income-monthly-switch input[type="checkbox"]:checked,
input.pill-switch[type="checkbox"]:checked,
.default-check input[type="checkbox"]:checked { background: var(--brand-grad); }
.income-monthly-switch input[type="checkbox"]:checked::after,
input.pill-switch[type="checkbox"]:checked::after,
.default-check input[type="checkbox"]:checked::after { transform: translateX(18px); }
/* toggle 单元格:标题与左侧对齐(顶部),开关推到底部与数字输入底边对齐 */
.form-row-2 > label.toggle-cell { align-self: stretch; }
.form-row-2 > label.toggle-cell > .pill-switch { margin-top: auto; margin-bottom: 9px; }
.income-save-btn {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 28px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--brand-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.income-save-btn:active { transform: scale(0.98); }
/* 取消按钮在收入保存行里与保存等高 */
.income-save-row .secondary-button { flex: 0 0 auto; height: 46px; padding: 0 22px; border-radius: var(--radius-md); font-size: 15px; font-weight: 700; cursor: pointer; }
.finance-form label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.finance-form input,
.finance-form select {
  height: 42px;
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.finance-form input:focus,
.finance-form select:focus,
.finance-form textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.finance-form .check-row {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  display: flex;
  gap: 8px;
  font-size: 12px;
}
.finance-form .check-row { font-size: 13px; }
.finance-form .check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  position: relative;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.finance-form .check-row input[type="checkbox"]:checked {
  background: var(--brand-2);
  border-color: var(--brand-2);
}
.finance-form .check-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.income-date-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.income-date-row > label { min-width: 0; }
.income-date-row > label > input[type="date"] { width: 100%; min-width: 0; box-sizing: border-box; }
.income-date-row .check-row { padding-bottom: 12px; }
.readonly-field input[readonly] {
  background: rgba(127, 127, 127, 0.07);
  color: var(--muted-strong);
  -webkit-text-fill-color: var(--muted-strong);
  cursor: default;
  pointer-events: none;
}
.field-hint { display: block; margin-top: 5px; font-size: 11px; color: var(--muted); }
.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 4px;
}
.form-actions.single { grid-template-columns: 1fr; }
/* 实体编辑表单:取消(次要)在左窄,保存(主)在右宽 */
/* 弹窗内(如流水详情)form-actions--edit:次要(删除)左窄 + 主按钮(关闭)右宽 */
.form-actions--edit { grid-template-columns: auto 1fr; }
/* 实体编辑表单(在 <form> 内):保存在左且宽,取消在右且窄(用 order 调位,不动 DOM) */
form .form-actions--edit { display: flex; gap: 8px; grid-template-columns: none; }
form .form-actions--edit > button[type="submit"] { order: -1; flex: 1 1 auto; }
form .form-actions--edit > .secondary-button { flex: 0 0 auto; }
/* form-actions 外的整行次要动作(已还清/提前结束) */
.form-block-btn { width: 100%; height: 44px; margin-top: 8px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; cursor: pointer; }
/* 报销勾选与 保存/取消 同排(保存不再占满) */
.form-actions--reimburse { display: flex; align-items: center; gap: 8px; grid-template-columns: none; }
.form-actions--reimburse .reimburse-inline { display: flex; align-items: center; gap: 6px; margin-right: auto; font-size: 12px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.form-actions--reimburse .reimburse-inline input[type="checkbox"] { accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.form-actions--reimburse button { flex: 0 0 auto; padding: 0 22px; }
/* 想买判断弹窗:分期勾选 + 展开的期数/月供 */
#affordModalForm .checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; margin: 2px 0; }
#affordModalForm .checkbox-row input[type="checkbox"] { accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.installment-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2, rgba(0,0,0,0.03)); }
.installment-fields[hidden] { display: none; }
.ai-consent-actions {
  grid-template-columns: 1fr;
  gap: 8px;
}
.ai-consent-actions button { width: 100%; }
.form-actions button {
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-grad);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.form-actions button:active { transform: scale(0.97); }
.form-actions button:hover { box-shadow: var(--shadow-glow); }
.secondary-button {
  background: var(--card) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}

.settings-card { display: grid; gap: 12px; padding: 16px; }
.flat-card { box-shadow: none; }

/* ── 13. Chat view ─────────────────────────────────────────────── */
#chatView { gap: 0; }
.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px 18px;
  overflow-y: auto;
  min-height: 0;
}
/* Bottom-align messages when few (chat feel) but stay scrollable when many:
   the auto top-margin collapses once content overflows, so the top is reachable.
   (The old `display:grid; align-content:end` clipped the top un-scrollably.) */
.messages > :first-child { margin-top: auto; }
.message {
  display: grid;
  gap: 6px;
}
.message.ai {
  /* avatar + bubble, hugging the LEFT. align-self:start + width:max-content stop
     the flex parent from stretching/centering the row; margin-right:auto throws all
     leftover space to the right so the block can never drift right. Center the
     avatar against the bubble so a tall reply doesn't leave a big empty block. */
  grid-template-columns: 70px auto;
  align-items: center;
  gap: 8px;
  justify-content: start;
  align-self: start;
  justify-self: start;
  width: max-content;
  max-width: 100%;
  margin-right: auto;
}
.message.user {
  justify-items: end;
}
.message .chat-avatar {
  width: 70px;
  height: 70px;
  font-size: 13px;
  align-self: end;
  box-shadow: none;
  /* Portraits ship on a white studio backdrop — match the chip to white (both
     themes) and drop the border so the subject reads as edge-to-edge. */
  background: #fff;
  border-color: transparent;
}
/* The chat chip is only 32px, but the base emoji/twemoji are sized for the 48px
   settings avatar (32px glyph / 36px image) — bigger than this container, so the
   round mask was clipping the top of the character. Shrink them to fit here. */
.message .chat-avatar .avatar-emoji { font-size: 28px; }
/* The portrait <img> carries BOTH avatar-twemoji (for emoji fallback) and
   avatar-portrait. This 30px shrink is only for a real emoji fallback — exclude
   portraits, or the photo gets squashed to 30px inside the 96px chip. */
.message .chat-avatar .avatar-twemoji:not(.avatar-portrait) { width: 30px; height: 30px; }
.message-body { display: grid; gap: 4px; min-width: 0; }
.bubble {
  max-width: 280px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: var(--shadow-sm);
  word-wrap: break-word;
  white-space: pre-line; /* honor \n in multi-line replies (e.g. spending stats) */
}
.chat-retry-btn {
  align-self: start;
  margin-top: 6px;
  height: 30px;
  padding: 0 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.message.user .bubble {
  background: var(--brand-grad);
  color: #fff;
  border: 0;
  border-bottom-right-radius: 6px;
}
.message.ai .bubble { border-bottom-left-radius: 6px; }
.message-meta {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* "AI" tag + credits-spent badge on server-AI replies */
.ai-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.ai-cost {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  vertical-align: middle;
}
.media-bubble { padding: 6px; }
.media-bubble img { border-radius: 12px; max-width: 220px; }

.insight-card {
  margin-top: 6px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow);
}
.insight-card.go { border-color: var(--ok); background: var(--ok-soft); }
.insight-card.hold { border-color: var(--warn); background: var(--warn-soft); }
.insight-card.stop { border-color: var(--danger); background: var(--danger-soft); }
.insight-card .eyebrow { color: inherit; opacity: 0.7; }
.insight-card strong {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum", "lnum";
}
.reason-list { display: grid; gap: 4px; font-size: 13px; color: var(--ink); }
.reason-list li { padding-left: 14px; position: relative; }
.reason-list li::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  padding: 8px 12px 6px;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.quick-actions button {
  display: grid;
  gap: 4px;
  padding: 9px 4px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.quick-actions button span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border-radius: 50%;
  color: #fff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
}
.quick-actions button span svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.quick-actions button:nth-child(1) span { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.quick-actions button:nth-child(2) span { background: linear-gradient(135deg, #f97316, #fb923c); }
.quick-actions button:nth-child(3) span { background: linear-gradient(135deg, #eab308, #f59e0b); }
.quick-actions button:nth-child(4) span { background: linear-gradient(135deg, #06b6d4, #0ea5e9); }
.quick-actions button:nth-child(5) span { background: linear-gradient(135deg, #10b981, #059669); }
.quick-actions button b {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-align: center;
  white-space: normal;       /* 允许换行:两词的标签(Catat Pemasukan)上下排,不再溢出 */
  word-break: keep-all;      /* 不在词内断开,只在词间换行 */
  min-height: 2.2em;         /* 1行/2行标签按钮高度对齐 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.quick-actions button:hover,
.quick-actions button:active {
  transform: translateY(-1px);
  border-color: var(--brand);
  box-shadow: 0 6px 14px rgba(255, 87, 34, 0.18);
}

/* ── 14. Composer (chat input) ────────────────────────────────── */
.composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  /* center the camera / input / send in the row (was defaulting to stretch) and
     trim vertical padding so the bar isn't taller than it needs to be */
  align-items: center;
  gap: 8px;
  padding: 6px 14px 2px;
  background: var(--card);
  border-top: 1px solid var(--line);
}
.phone-app:not([data-active-view="chat"]) .composer { display: none; }
/* Attached-photo preview row in the composer (image compose flow). */
.receipt-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.receipt-preview[hidden] { display: none; }
.receipt-preview img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.receipt-preview-hint { flex: 1 1 auto; font-size: 12px; color: var(--muted); line-height: 1.3; }
.receipt-preview-remove {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border: 0; border-radius: 50%;
  background: var(--card); color: var(--ink);
  font-size: 18px; line-height: 1; cursor: pointer;
}

.input-wrap { position: relative; min-width: 0; }
.composer input[type="text"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--soft);
  color: var(--ink);
  padding: 0 46px 0 16px;
  font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.composer input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--card);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.icon-button,
.send-button,
.input-voice {
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
}
.icon-button:hover { background: var(--brand-soft); color: var(--brand); }
.icon-button.listening { background: var(--warn-soft); color: var(--warn); }

.send-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.send-button:active { transform: scale(0.94); }

.input-voice {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.input-voice:hover { color: var(--brand); background: var(--brand-soft); }
.input-voice.listening { background: var(--warn-soft); color: var(--warn); }

.icon-button svg,
.send-button svg,
.input-voice svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── 15. Bottom nav ────────────────────────────────────────────── */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  /* Sit just above the home indicator / gesture bar. env() already gives the
     exact clearance; we add a small base only (no extra +10 / min-14 padding,
     which made the bar look too tall once the WebView went edge-to-edge). */
  padding: 0 12px calc(4px + env(safe-area-inset-bottom, 10px));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
:root[data-theme="dark"] .bottom-nav {
  background: rgba(17, 26, 46, 0.96);
}
.bottom-nav button {
  position: relative;
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 46px;
  border: 0;
  background: transparent;
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
  transition: color var(--dur) var(--ease);
}
.bottom-nav span {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  transition: background var(--dur) var(--ease);
}
.bottom-nav svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bottom-nav button.active { color: var(--brand); }
.bottom-nav .nav-money { display: none; } /* desktop sidebar only */
.header-budget-chat { display: flex; align-items: center; gap: 8px; }
.header-chat-d { display: none; } /* desktop only */
.bottom-nav button.active span { background: var(--brand-soft); }
.bottom-nav button.active::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 22px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--brand-grad);
  transform: translateX(-50%);
}
.bottom-nav .center-tab { font-size: 12px; font-weight: 800; }
.bottom-nav .center-tab svg { width: 26px; height: 26px; }
.bottom-nav .center-tab span {
  background: var(--brand-grad);
  color: #fff;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow);
}
.bottom-nav .center-tab.active span { background: var(--brand-grad); }
.bottom-nav .center-tab.active::after { display: none; }

.nav-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  padding: 0 5px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
}

/* ── 16. Device float (preview switch) ────────────────────────── */
.device-float {
  position: fixed;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  touch-action: none; /* let pointer events drive the drag, not scroll */
  user-select: none;
}
.device-float[hidden] { display: none; }
.device-float-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  cursor: grab;
}
.device-float-head:active { cursor: grabbing; }
.device-float-collapse {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.device-float-collapse:hover { background: var(--line-strong); }
.device-float-tab {
  position: fixed;
  right: 16px;
  bottom: calc(100px + env(safe-area-inset-bottom));
  z-index: 40;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted-strong);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.device-float-tab[hidden] { display: none; }

/* Pull-to-refresh indicator — floats above app-view while user drags down */
.pull-refresh {
  position: fixed;
  left: 50%;
  top: 0;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: calc(env(safe-area-inset-top) + 4px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow-md);
  color: var(--brand-2);
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-100%) scale(.6) rotate(0deg);
  transition: opacity 200ms var(--ease), transform 280ms cubic-bezier(.2,.8,.2,1);
}
.pull-refresh.ready { color: var(--brand-2); }
/* Reusable three-dot loader — used app-wide for loading states. */
.dot-loader { display: inline-flex; gap: 5px; align-items: center; color: var(--brand-2); }
.dot-loader i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: dot-pulse 1.1s ease-in-out infinite;
}
.dot-loader i:nth-child(2) { animation-delay: 0.16s; }
.dot-loader i:nth-child(3) { animation-delay: 0.32s; }
@keyframes dot-pulse {
  0%, 70%, 100% { opacity: 0.3; transform: scale(0.82); }
  35% { opacity: 1; transform: scale(1); }
}
@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.device-float-tab svg { width: 18px; height: 18px; }
.device-float-tab:hover { color: var(--brand); }
.device-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.device-switch button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}
.device-switch button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.device-switch button b { font-size: 13px; line-height: 1; }

/* ── 17. Modals ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  animation: fadeIn 200ms var(--ease);
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  animation: slideUp 240ms var(--ease);
}
.modal-heading { display: grid; gap: 4px; }
.modal-heading p { font-size: 13px; color: var(--muted); }

/* ── 流水导入审核 ───────────────────────────────────────────── */
.import-first-hint { font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand-ring); border-radius: var(--radius-sm); padding: 8px 10px; margin: 0; }
.import-card { width: min(560px, 100%); max-height: 88vh; }
.import-mapping { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.import-mapping label { display: grid; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.import-mapping select { width: 100%; min-width: 0; }
.import-dupmode { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-size: 12px; color: var(--ink); padding: 8px 0; border-top: 1px solid var(--line); }
.import-dupmode > span { font-weight: 700; }
.import-dupmode label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.import-dupmode input { accent-color: var(--brand); }
.import-rows { display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; padding-right: 2px; }
.import-row {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.import-row.is-dup { border-color: var(--brand-ring); background: var(--brand-soft); }
.import-name { width: 100%; height: 32px; font-size: 13px; font-weight: 700; }
.import-row-meta { display: flex; align-items: center; gap: 8px; }
.import-row-meta small { font-size: 11px; color: var(--muted); margin-right: auto; }
.import-row-meta em { color: var(--brand); font-style: normal; font-weight: 700; }
.import-date { height: 28px; font-size: 12px; padding: 0 6px; margin-right: auto; }
.import-date.is-bad { border-color: var(--danger); background: var(--danger-soft, rgba(220,38,38,.08)); }
.import-dup-tag { color: var(--brand); font-style: normal; font-weight: 700; font-size: 11px; }
.import-type { height: 26px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--card); font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; flex: 0 0 auto; }
.import-type.income { color: var(--ok); border-color: var(--ok); }
.import-type.expense { color: var(--danger); border-color: var(--danger); }
.import-amt { font-size: 13px; font-weight: 800; font-feature-settings: "tnum","lnum"; white-space: nowrap; flex: 0 0 auto; }
.import-amt.inc { color: var(--ok); }
.import-amt.exp { color: var(--ink); }
.import-cat { width: 100%; height: 30px; font-size: 12px; }
.import-source { display: grid; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 600; }
.import-source select { width: 100%; }
.import-ai-btn { width: 100%; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--brand-ring); background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 700; cursor: pointer; }
.import-ai-btn:disabled { opacity: 0.6; cursor: default; }

/* 流水详情弹窗 */
.tx-detail-body { display: grid; gap: 2px; }
.txd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.txd-row:last-child { border-bottom: 0; }
.txd-row > span { color: var(--muted); }
.txd-row > b { font-weight: 700; color: var(--ink); text-align: right; }
.txd-row > b.txd-inc { color: var(--ok); }
.txd-row > b.txd-exp { color: var(--danger); }
/* 删除按钮:白底红字,与关闭等高对齐(secondary-button 已给白底+边框+44h) */
.txd-delete-btn { color: var(--danger) !important; border-color: var(--danger) !important; }

/* ── 过往预算:月份列表 + 月明细弹窗 ── */
.budget-past-list { display: grid; gap: 8px; }
.budget-past-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); cursor: pointer; }
.budget-past-item > div { display: grid; gap: 2px; }
.budget-past-month { font-size: 15px; font-weight: 700; color: var(--ink); }
.budget-past-sub { font-size: 12px; color: var(--muted); }
.budget-month-analysis { margin-bottom: 4px; }
.bm-ana-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.bm-ana-grid > span { display: grid; gap: 2px; padding: 8px 10px; background: var(--soft); border-radius: var(--radius-sm); }
.bm-ana-grid small { font-size: 11px; color: var(--muted); }
.bm-ana-grid b { font-size: 14px; font-weight: 800; color: var(--ink); }
.bm-ana-grid b.bm-pos { color: var(--ok); }
.bm-ana-grid b.bm-neg { color: var(--danger); }
.budget-month-list { display: grid; gap: 8px; }
.bm-row { display: grid; gap: 5px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bm-row.is-over { border-color: var(--danger); }
.bm-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.bm-row-top b { font-weight: 700; color: var(--ink); }
.bm-row-top span { color: var(--muted); font-feature-settings: "tnum","lnum"; }
.bm-row.is-over .bm-row-top span { color: var(--danger); font-weight: 700; }
.confirm-preview {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  border-left: 3px solid var(--brand);
  font-size: 13px;
  color: var(--ink);
  display: grid;
  gap: 6px;
}
.confirm-preview-text { color: var(--ink); }
.confirm-preview-action {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.02em;
}

/* Reimbursement */
.reimburse-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.reimburse-check input[type="checkbox"] {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
}
.income-badge.reimburse {
  background: rgba(255, 87, 34, 0.12);
  color: var(--brand);
}
.income-item.is-reimburse {
  border-left: 3px solid var(--brand);
}
.card-action.received {
  background: var(--brand);
  color: #fff;
}
.reimburse-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
}
.reimburse-summary > div {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--soft);
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
}
/* Pending = brand tint, Received = green tint */
.reimburse-summary > div:first-child {
  background: var(--brand-soft);
  border-color: var(--brand-ring);
}
.reimburse-summary > div:last-child {
  background: var(--ok-soft);
  border-color: rgba(16, 185, 129, 0.28);
}
/* Only the label span is uppercased — NOT the Rp prefix inside <strong> */
.reimburse-summary > div > span {
  font-size: 11px;
  color: var(--muted-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.reimburse-summary strong {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.reimburse-summary > div:first-child strong { color: var(--brand-2); }
.reimburse-summary > div:last-child strong { color: var(--ok); }
.reimburse-section-title {
  margin: 16px 0 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.reimburse-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 4px 0 14px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--soft);
}
.reimburse-tabs button {
  border: 0;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.reimburse-tabs button.active {
  background: var(--card);
  color: var(--ink-strong);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.reimburse-tab-page[hidden] { display: none; }

/* Referral panel */
.referral-card { display: grid; gap: 16px; }
.referral-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255,87,34,0.12), rgba(17,17,17,0.06));
  border: 1px solid var(--line);
}
.referral-hero-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.referral-hero-info > span {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.referral-hero strong {
  font-size: 36px;
  font-weight: 900;
  color: var(--brand-2);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.referral-hero small {
  font-size: 12px;
  color: var(--muted-strong);
}
.referral-rules {
  display: grid;
  /* 4 tiers (signup / silver / gold / platinum) — 2×2 so the longer tier labels
     don't get crushed into 4 narrow columns on phones. */
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.referral-rules > div {
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  text-align: center;
  display: grid;
  gap: 2px;
}
.referral-rules span { font-size: 11px; color: var(--muted); }
.referral-rules b {
  font-size: 16px;
  font-weight: 800;
  color: var(--brand-2);
}
.referral-code-box {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--soft);
  border: 1px dashed var(--brand-ring);
}
.referral-code-box > span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.referral-code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}
.referral-code-row strong {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--brand-2);
  font-variant-numeric: tabular-nums;
  user-select: all;
}
.referral-code-row button {
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--brand-grad);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.referral-code-box small {
  font-size: 12px;
  color: var(--muted-strong);
}

.referral-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 4px 0 14px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--soft);
}
.referral-tabs button {
  border: 0;
  padding: 10px 8px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.referral-tabs button.active {
  background: var(--card);
  color: var(--ink-strong);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.referral-tab-page[hidden] { display: none; }

.referral-rules-extra {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 0;
}

.referral-section-title {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.referral-friends-list,
.referral-ledger-list {
  display: grid;
  gap: 8px;
}
.referral-friend,
.referral-ledger-row {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.referral-friend-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.referral-friend-head strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.referral-friend-plan {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.referral-friend-plan.plan-free { background: rgba(100,116,139,0.18); color: var(--muted); }
.referral-friend-plan.plan-silver { background: var(--brand-soft); color: var(--brand-2); }
.referral-friend-plan.plan-gold { background: rgba(124,58,237,0.16); color: #7c3aed; }
.referral-friend-plan.plan-platinum { background: rgba(234,179,8,0.16); color: #a16207; }
.referral-friend-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.referral-ledger-line-1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.referral-ledger-line-1 strong {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.referral-ledger-line-1 strong.in { color: var(--ok); }
.referral-ledger-line-1 strong.out { color: var(--muted); }
.referral-ledger-row small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

/* Link sits on its own full-width row; Copy + Share share the row below. */
.referral-link { display: grid; gap: 10px; }
.referral-link > span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.referral-link > input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font-mono, monospace);
  min-width: 0;
  text-overflow: ellipsis;
}
.referral-link-actions { display: flex; gap: 10px; }
.referral-action {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.referral-action svg { width: 18px; height: 18px; flex: 0 0 auto; }
.referral-action:active { transform: scale(0.98); }
.referral-action--copy {
  background: var(--soft);
  color: var(--ink-strong);
  border: 1px solid var(--line-strong, var(--line));
}
.referral-action--copy:hover { background: var(--hover, var(--soft)); border-color: var(--brand); }
.referral-action--share {
  background: var(--brand-grad);
  color: #fff;
  border: 0;
  box-shadow: 0 8px 20px -8px var(--brand);
}
.referral-action--share:hover { box-shadow: 0 10px 24px -8px var(--brand); }
.reimburse-list {
  display: grid;
  gap: 8px;
}
.reimburse-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--line);
}
.reimburse-row strong { font-size: 14px; display: block; }
.reimburse-row small { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }
.reimburse-row button {
  padding: 7px 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.reimburse-row.received {
  background: var(--soft);
  opacity: 0.9;
}
.reimburse-row .reimburse-amount {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.reimburse-row.received .reimburse-amount { color: var(--ok); }

/* Auth modal — referral code disclosure */
.auth-ref-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  background: var(--soft);
}
.auth-ref-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-2);
  padding: 8px 0;
  list-style: none;
}
.auth-ref-details summary::-webkit-details-marker { display: none; }
.auth-ref-details summary::before {
  content: "+ ";
  font-weight: 800;
}
.auth-ref-details[open] summary::before { content: "− "; }
.auth-ref-details .auth-ref-label {
  display: grid;
  gap: 6px;
  padding: 4px 0 10px;
}
.auth-ref-details .auth-ref-label input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

/* Money / Bills top toggle inside debt view */
.money-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 4px 0 10px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--soft);
}
/* Hidden while drilled into a level-3 panel (see toggleMoneyTabsForDrill). */
.money-tabs.drill-hidden { display: none; }

/* Amount field with an Aa/123 keyboard toggle (see setupAmountKeyboardToggles). */
.amount-field { position: relative; display: block; }
.amount-mode-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 38px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.amount-mode-toggle:active { background: var(--hover); }
.money-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
/* Count pill on a tab / side-menu row (overdue loans & fixed costs). Mirrors
   .nav-badge styling but flows inline rather than floating in a corner. */
/* Greyed AI entry points for free plan — kept clickable so the tap can surface
   the upgrade nudge (see syncAiLockUi / promptAiUpgrade). */
.is-locked {
  opacity: 0.4;
  filter: grayscale(0.6);
}
.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
}
.money-tabs button.active {
  background: var(--card);
  color: var(--ink-strong);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
/* Side-menu buttons hidden based on active money sub-tab */
[data-panel-scope="debt"][data-money-tab-active="money"] [data-money-section="bills"] { display: none; }
[data-panel-scope="debt"][data-money-tab-active="bills"] [data-money-section="money"] { display: none; }
/* Profile (我) view: 资料/设置 sub-tab toggles which side-menu section shows */
[data-panel-scope="profile"][data-profile-tab-active="info"] [data-profile-section="settings"] { display: none; }
[data-panel-scope="profile"][data-profile-tab-active="settings"] [data-profile-section="info"] { display: none; }
/* The Mutasi/Bills nav shortcuts use display:grid !important in simple mode, which
   would otherwise leak into the 设置 tab — keep them to the 资料 tab only. */
[data-panel-scope="profile"][data-profile-tab-active="settings"] .side-menu-nav { display: none !important; }

/* AI parse-tx modal */
.parse-tx-list {
  display: grid;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  margin: 0 0 12px;
}
.parse-tx-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--soft);
  cursor: pointer;
}
.parse-tx-row input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--brand);
}
.parse-tx-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  font-size: 14px;
}
.parse-tx-row-body small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}
.parse-tx-row-head { cursor: pointer; }
.parse-tx-row-fields { display: flex; gap: 8px; margin-top: 8px; }
.parse-tx-row-fields input {
  flex: 1 1 0; min-width: 0; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink); font-size: 13px;
}
.parse-tx-amount.in { color: var(--success, #16a34a); }
.parse-tx-amount.out { color: var(--ink); }
.parse-tx-account {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  font-size: 13px;
}
.parse-tx-account select {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  background: var(--surface, #fff);
  color: var(--ink);
  font: inherit;
}

/* ── 18. Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 90;
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 14px;
  max-width: min(420px, calc(100vw - 24px));
  transform: translateX(-50%) translateY(20px);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  /* Fixed dark surface so text is always readable in both light + dark
     themes. Previously used var(--ink-strong) which inverts in dark mode
     and made the toast white-on-white. */
  background: #1a1a1a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast button {
  border: 0;
  background: transparent;
  color: var(--brand-2);
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  text-transform: uppercase;
}

/* ── 19. Animations ───────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── 20. Focus ─────────────────────────────────────────────────── */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.composer input:focus-visible,
.transaction-search input:focus-visible {
  outline: none;
}

/* ── 21. Responsive ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .app-shell { padding: 0; }
  .phone-app { border-radius: 0; border: 0; min-height: 100vh; }
}

/* ── Native app (Capacitor): true full-bleed, no document rubber-band ──────────
   The shell was built as a desktop "phone mockup" (framed, centered, padded). In
   the native shell we instead pin the document to the screen so the background
   reaches every edge (incl. under the Dynamic Island / home indicator) and the
   whole page can't be dragged. Only the inner .app-view scrolls. Safe-area insets
   are honored by the header / bottom-nav padding (they already use env()). */
body.native-app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.native-app .app-shell {
  min-height: 0;
  height: 100%;
  padding: 0;
}
body.native-app .phone-app {
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 380px) {
  .app-view { padding: 14px 14px 24px; }
  .option-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Desktop preview (toggle via [data-preview-device]) */
@media (min-width: 760px) {
  body:not([data-preview-device="mobile"]) .app-shell { padding: 24px; }
  body:not([data-preview-device="mobile"]) .phone-app {
    width: min(1180px, calc(100vw - 36px));
    min-height: min(820px, calc(100vh - 36px));
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
  }
  body:not([data-preview-device="mobile"]) .app-header {
    grid-column: 1;
    grid-row: 1 / 2;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 22px;
    display: grid;
    align-content: start;
    gap: 18px;
  }
  body:not([data-preview-device="mobile"]) .top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  body:not([data-preview-device="mobile"]) .app-view {
    grid-column: 2;
    grid-row: 1 / 3;
    padding: 24px 28px 24px;
  }
  body:not([data-preview-device="mobile"]) #chatView.active {
    padding: 0;
  }
  body:not([data-preview-device="mobile"]) .composer {
    grid-column: 2;
    grid-row: 3;
  }
  body:not([data-preview-device="mobile"]) .bottom-nav {
    grid-column: 1;
    grid-row: 2 / -1;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    border-top: 0;
    gap: 4px;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  }
  /* Desktop: chat sits to the right of the budget % shortcut; center-tab hidden. */
  body:not([data-preview-device="mobile"]) .bottom-nav > .center-tab { display: none; }
  body:not([data-preview-device="mobile"]) .header-budget-chat { width: 100%; }
  body:not([data-preview-device="mobile"]) .header-chat-d {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding: 9px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--brand-grad);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    cursor: pointer;
  }
  body:not([data-preview-device="mobile"]) .header-chat-d svg {
    width: 18px; height: 18px;
    fill: none; stroke: currentColor; stroke-width: 2.2;
    stroke-linecap: round; stroke-linejoin: round;
  }
  body:not([data-preview-device="mobile"]) .header-chat-d:hover { filter: brightness(1.06); transform: translateY(-1px); }
  body:not([data-preview-device="mobile"]) .bottom-nav .nav-money { display: grid; }
  body:not([data-preview-device="mobile"]) .bottom-nav button:not(.nav-money) + .nav-money,
  body:not([data-preview-device="mobile"]) .bottom-nav .nav-settings {
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }
  body:not([data-preview-device="mobile"]) .bottom-nav button {
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
    min-height: 0;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
  }
  body:not([data-preview-device="mobile"]) .bottom-nav button.active::after { display: none; }
  body:not([data-preview-device="mobile"]) .bottom-nav button.active {
    background: var(--brand-soft);
  }
  body:not([data-preview-device="mobile"]) .overview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Overview = 2-col dashboard: hero | saving on top, full-width grid below */
  body:not([data-preview-device="mobile"]) #overviewView.active {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
    align-items: start;
  }
  body:not([data-preview-device="mobile"]) #overviewView.active > .view-heading,
  body:not([data-preview-device="mobile"]) #overviewView.active > .overview-grid {
    grid-column: 1 / -1;
  }
  /* Desktop: recent components that were still single-column on wide screens */
  body:not([data-preview-device="mobile"]) .plan-grid,
  body:not([data-preview-device="mobile"]) .budget-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  body:not([data-preview-device="mobile"]) .input-row select {
    max-width: 300px;
  }
  body:not([data-preview-device="mobile"]) .plan-card { cursor: pointer; }
  body:not([data-preview-device="mobile"]) .plan-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-md);
  }
  /* Desktop: drop only the pull-to-refresh affordance (touch-only gesture).
     The device floatie stays — it's the mobile/desktop preview switcher. */
  body:not([data-preview-device="mobile"]) .pull-refresh {
    display: none !important;
  }
  /* Desktop: reveal row delete on hover instead of swipe gesture */
  body:not([data-preview-device="mobile"]) .swipe-row .swipe-delete {
    z-index: 2;
    inset: 6px 6px 6px auto;
    min-width: 0;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s var(--ease);
  }
  body:not([data-preview-device="mobile"]) .swipe-row:hover .swipe-delete {
    opacity: 1;
    pointer-events: auto;
  }
  /* Desktop: split workspace = full-width content with a horizontal tab bar on
     top (no middle vertical menu). Default-show the first panel until picked. */
  body:not([data-preview-device="mobile"]) .split-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  body:not([data-preview-device="mobile"]) .split-workspace .side-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
  }
  body:not([data-preview-device="mobile"]) .split-workspace .side-menu button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    min-height: 0;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
  }
  body:not([data-preview-device="mobile"]) .split-workspace .side-menu button::after { content: none; }
  body:not([data-preview-device="mobile"]) .split-workspace .side-menu button strong {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
  }
  body:not([data-preview-device="mobile"]) .split-workspace .side-menu button.active {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--ink-strong);
  }
  body:not([data-preview-device="mobile"]) .split-workspace .side-content { display: grid; }
  body:not([data-preview-device="mobile"]) .split-workspace:not(:has(.content-panel.active)) .content-panel:first-child {
    display: grid;
  }
  body:not([data-preview-device="mobile"]) .split-workspace.drill-open .side-content { animation: none; }
  body:not([data-preview-device="mobile"]) .view-back { display: none !important; }
  /* Desktop: keep add/edit forms + settings from stretching the full content
     width (a single text input spanning ~900px reads as "mobile in a big box").
     Lists/cards already scale fine, so only the form/settings inputs are capped. */
  body:not([data-preview-device="mobile"]) .finance-form {
    max-width: 420px;
  }
  body:not([data-preview-device="mobile"]) .settings-card {
    max-width: 560px;
  }
  /* Desktop only: bills page drops the redundant "money" sub-group (余额/收入/报销/
     备用金 already live in the sidebar money shortcuts). Mobile keeps both groups. */
  body:not([data-preview-device="mobile"]) [data-panel-scope="debt"] .money-tabs { display: none; }
  body:not([data-preview-device="mobile"]) [data-panel-scope="debt"] [data-money-section="money"] { display: none !important; }
  body:not([data-preview-device="mobile"]) [data-panel-scope="debt"] [data-money-section="bills"] { display: inline-flex !important; }
}

/* ── Admin dashboard (standalone /admin.html) ────────────────── */
.admin-wrap { max-width: 920px; margin: 0 auto; padding: 24px 18px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.admin-head h1 { font-size: 22px; }
.admin-login { display: grid; gap: 12px; max-width: 380px; }
.admin-login form { display: flex; gap: 8px; }
.admin-login input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }
.admin-login button, .admin-user button, .admin-setplan button, .admin-login + section button { padding: 9px 16px; border: 0; border-radius: var(--radius-sm); background: var(--brand-grad); color: #fff; font-weight: 700; cursor: pointer; }
.admin-msg { font-size: 13px; color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
.admin-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.admin-card h3 { font-size: 14px; margin-bottom: 8px; }
.admin-card.stat { display: grid; gap: 4px; }
.admin-stat-label { font-size: 12px; color: var(--muted); }
.admin-stat-value { font-size: 22px; font-weight: 800; }
.admin-card form { display: flex; gap: 8px; margin-bottom: 8px; }
.admin-card form input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }
.admin-plan-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.admin-plan-bar { display: grid; gap: 2px; padding: 10px; border-radius: var(--radius-sm); background: var(--soft); text-align: center; }
.admin-plan-bar span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.admin-plan-bar strong { font-size: 18px; }
.admin-warn { color: var(--warn); display: block; margin-top: 8px; }
.admin-user { display: grid; gap: 6px; margin-top: 10px; }
.admin-setplan { display: flex; gap: 8px; align-items: center; }
.admin-setplan select { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }
@media (max-width: 560px) { .admin-grid { grid-template-columns: 1fr; } .admin-plan-bars { grid-template-columns: repeat(2, 1fr); } }

/* admin analytics */
.ana-trend { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.ana-bar { display: grid; justify-items: center; gap: 4px; flex: 1; }
.ana-bar span { display: block; width: 100%; background: var(--brand-grad); border-radius: 3px 3px 0 0; }
.ana-bar small { font-size: 10px; color: var(--muted); }
.ana-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.ana-hours i { display: block; height: 22px; border-radius: 2px; background: var(--brand-2); }
.ana-geo { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--soft); margin: 2px; font-size: 13px; }
.ana-miss { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }
.ana-miss li { color: var(--ink); }

/* admin faq */
.admin-faq-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.faq-rule { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; display: grid; gap: 4px; }
.faq-rule p { font-size: 14px; }
.faq-rule-btns { display: flex; gap: 8px; margin-top: 4px; }
.faq-rule-btns button { padding: 6px 12px; border: 0; border-radius: var(--radius-sm); background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 12px; cursor: pointer; }
.faq-rule-btns button.secondary-button { background: var(--soft); color: var(--ink); }

/* admin tabs */
.admin-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; flex-wrap: wrap; }
.admin-tab { padding: 8px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted-strong); font-size: 14px; font-weight: 700; cursor: pointer; transition: all .15s var(--ease); }
.admin-tab:hover { border-color: var(--brand); }
.admin-tab.active { background: var(--brand-grad); color: #fff; border-color: transparent; }
.admin-pane[hidden] { display: none; }

/* admin cost */
.admin-cost-list { margin: 6px 0; padding-left: 18px; font-size: 13px; display: grid; gap: 2px; }
.admin-cost-edit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.admin-cost-edit label { font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.admin-cost-edit input { width: 110px; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); }
.admin-cost-edit button { padding: 8px 14px; border: 0; border-radius: var(--radius-sm); background: var(--brand-grad); color: #fff; font-weight: 700; cursor: pointer; align-self: end; }

/* admin analytics horizontal-bar ranking */
.ana-row { display: grid; grid-template-columns: 80px 1fr 36px; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.ana-row-k { color: var(--muted-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ana-row-bar { background: var(--soft); border-radius: 999px; height: 10px; overflow: hidden; }
.ana-row-bar i { display: block; height: 100%; background: var(--brand-grad); border-radius: 999px; }
.ana-row-n { text-align: right; font-weight: 700; }

/* admin detail drill-down */
.detail-link { cursor: pointer; transition: border-color .15s var(--ease), transform .1s var(--ease); }
.detail-link:hover { border-color: var(--brand-2); }
.detail-link:active { transform: scale(.99); }
.admin-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.admin-modal[hidden] { display: none; }
.admin-modal-card { background: var(--card); border-radius: var(--radius); width: min(560px, 100%); max-height: 80vh; overflow: auto; padding: 18px; }
.admin-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; position: sticky; top: -18px; background: var(--card); padding-top: 4px; }
.admin-modal-head button { border: 0; background: var(--soft); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--ink); font-size: 14px; }
.detail-row { padding: 9px 0; border-bottom: 1px solid var(--line); display: grid; gap: 3px; font-size: 13px; }
.detail-row:last-child { border-bottom: 0; }

/* app version footer label */
.app-version-label { text-align: center; font-size: 11px; color: var(--muted); margin-top: 0; }
.app-version-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

/* admin geo map */
#adminMap { height: 360px; border-radius: var(--radius-sm); overflow: hidden; background: var(--soft); }
.leaflet-popup-content { font-size: 13px; }

/* Auth resolving: hide account buttons + neutralize status to avoid a
   "signed out → signed in" flash on every page load. */
body.auth-pending #accountSignIn,
body.auth-pending #accountSignOut { visibility: hidden; }
body.auth-pending #accountStatus .account-status-label { opacity: 0; }

/* legal docs (terms / privacy) */
.legal-doc { max-width: 720px; margin: 0 auto; padding: 32px 20px 80px; }
.legal-back { display: inline-block; margin-bottom: 16px; color: var(--brand-2); font-weight: 700; }
.legal-updated { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.legal-doc section { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.legal-doc h2 { font-size: 18px; margin-bottom: 12px; color: var(--brand-2); }
.legal-doc h3 { font-size: 15px; margin: 16px 0 4px; }
.legal-doc p { font-size: 14px; line-height: 1.6; color: var(--ink); }
/* 中文段对普通(印尼)用户折叠收起,展开后内部 h3/p 沿用 legal-doc 样式 */
.legal-zh { margin-bottom: 32px; }
.legal-zh > summary { font-size: 18px; font-weight: 700; color: var(--brand-2); cursor: pointer; list-style: revert; }
.legal-zh[open] > summary { margin-bottom: 12px; }
.legal-links { text-align: center; font-size: 12px; margin-top: 12px; }
.legal-links a { color: var(--muted); }

/* auth consent checkbox */
.auth-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--muted-strong); margin: 4px 0 2px; line-height: 1.5; }
.auth-consent input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
  position: relative;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.auth-consent input[type="checkbox"]:checked { background: var(--brand-2); border-color: var(--brand-2); }
.auth-consent input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.auth-consent a { color: var(--brand-2); font-weight: 600; }

/* native (Capacitor) platform adjustments */
body.native-app .device-float,
body.native-app .device-float-tab { display: none !important; }
body.native-app .app-header { padding-top: max(env(safe-area-inset-top), 12px); }
body.native-app .bottom-nav { padding-bottom: max(env(safe-area-inset-bottom), 10px); }
/* The composer sits ABOVE the bottom-nav, not at the screen edge — it must NOT
   add safe-area-inset-bottom (the nav already does). That double-padding left a
   big empty band below the input on devices with a tall gesture area. */
body.native-app .composer { padding-bottom: 8px; }

/* ── Segmented-tab consistency (final overrides) ─────────────────────────────
   money / reimburse / referral tabs share the EXACT look of the transactions
   filter-tabs: same track (border + soft bg + 4px gap), same button height/
   padding/weight, and the same dark-ink active pill (brand gradient in dark).
   Placed last so it wins over the per-control rules defined earlier. */
.money-tabs,
.reimburse-tabs,
.referral-tabs {
  border: 1px solid var(--line);
  gap: 4px;
}
.money-tabs button,
.reimburse-tabs button,
.referral-tabs button {
  min-height: 34px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-strong);
}
.money-tabs button.active,
.reimburse-tabs button.active,
.referral-tabs button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}
:root[data-theme="dark"] .money-tabs button.active,
:root[data-theme="dark"] .reimburse-tabs button.active,
:root[data-theme="dark"] .referral-tabs button.active {
  background: var(--brand-grad);
  color: #fff;
}

/* Modal close (×) button — top-right of a modal card. */
.modal-card { position: relative; }
.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}
.modal-x:active { background: var(--hover); }

/* Loan card footer: due date bottom-left, Edit bottom-right (symmetric). */
.paylater-footer { display: flex; align-items: center; gap: 10px; }
.paylater-due { font-size: 12px; color: var(--muted); }
.paylater-footer .card-action { margin-left: auto; }

/* Avatar reset action — full width, lighter than the upload button. */
.avatar-card #avatarReset { width: 100%; font-size: 13px; padding: 11px; }

/* Custom dropdown chevron with comfortable right spacing (native arrow hugged
   the border). Applies to all app selects. */
.finance-form select,
.input-row select,
.parse-tx-account select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23889099' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

/* Icon + text buttons (share / use-default-avatar) — less plain than bare text. */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-icon svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn-icon-accent {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-2);
  font-weight: 700;
}
.btn-icon-accent:active { background: var(--hover); }

/* Loan card: monthly amount with its label, stacked top-right. */
.paylater-monthly { display: grid; justify-items: end; gap: 2px; text-align: right; }
.paylater-monthly-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Expected-income cards: taller + clearer hierarchy. */
.income-item { padding: 15px 16px; gap: 8px; }
.income-item .income-line-1 .paylater-name { font-size: 15px; }
.income-item .income-line-2 { margin-top: 2px; }

/* Center the checkmark in the custom checkbox (was off). */
.finance-form .check-row input[type="checkbox"]:checked::after {
  left: 6px;
  top: 2px;
  width: 5px;
  height: 9px;
}

/* Referral: points card is tappable (opens the redeem screen); redeem modal. */
.referral-hero.is-tappable { cursor: pointer; }
.referral-hero-cta {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  align-self: center;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  background: var(--brand-grad);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px var(--brand-soft);
}
.redeem-points { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 6px 0 10px; }
.redeem-points span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.redeem-points strong { font-size: 40px; font-weight: 800; line-height: 1; color: var(--brand-2); }
#redeemModal .redeem-option {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand-grad);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
/* Gold tier reads as gold so it's distinct from the Silver (brand) option. */
#redeemModal .redeem-option--gold {
  background: linear-gradient(135deg, #e3b53c 0%, #c5901a 60%, #f1c84e 100%);
  color: #2a2106;
}
#redeemModal .redeem-option:disabled { opacity: 0.5; cursor: default; }

/* "Check for updates" button: refresh icon (::before survives data-i18n text) + accent tint. */
.app-version-row #checkUpdateBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-ring);
  color: var(--brand-2);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.app-version-row #checkUpdateBtn:hover { box-shadow: 0 3px 10px var(--brand-soft); }
.app-version-row #checkUpdateBtn:active { transform: scale(0.96); }
.app-version-row #checkUpdateBtn:disabled { opacity: 0.85; }
.app-version-row #checkUpdateBtn::before {
  content: "";
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-2.6-6.4'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-2.6-6.4'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: transform var(--dur) var(--ease);
}
.app-version-row #checkUpdateBtn.is-checking::before { animation: ptr-spin 700ms linear infinite; }

/* Reset confirmation: shown code + input. */
.reset-code-shown {
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 8px;
  color: #ef4444;
  margin: 2px 0 6px;
  font-family: var(--font-mono, monospace);
}
#resetCodeInput {
  width: 100%;
  height: 46px;
  text-align: center;
  font-size: 20px;
  letter-spacing: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
  color: var(--ink-strong);
}

.report-table-wrap { margin-top: 14px; overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.report-table .rp-prefix { font-size: .85em; margin-right: .1em; }
.report-table td:first-child, .report-table th:first-child { white-space: nowrap; } /* 月份/分类名不换行(如 2026-06) */
.report-table th, .report-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line, #e2e8f0); white-space: normal; word-break: keep-all; }
.report-table th { font-size: 10px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted, #64748b); }
.report-table .num { text-align: right; white-space: nowrap; }
.report-zone-title { margin: 18px 0 6px; font-size: 14px; font-weight: 800; }
.report-zone-title.sub { font-size: 12px; opacity: .8; font-weight: 700; }
.insight-list { display: grid; gap: 6px; }
.insight-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border: 1px solid var(--line, #e2e8f0); border-radius: 10px; }
.insight-row span { color: var(--muted, #64748b); font-size: 12px; }
.delta { font-style: normal; font-weight: 700; }
.delta--up { color: var(--ok, #059669); } .delta--down { color: var(--danger, #dc2626); } .delta--flat { color: var(--muted, #94a3b8); }
.report-chart-card { background: var(--card, #161a24); border: 1px solid var(--line, #e2e8f0); border-radius: 14px; padding: 14px; margin-top: 14px; }
.report-chart-card .chart-title { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.report-chart-card .chart-box { position: relative; height: 200px; }
.report-chart-card .chart-note { margin-top: 10px; font-size: 12px; color: var(--muted, #64748b); }

/* 首页月份标签:放在 payday badge 前,做成品牌橙药丸(与绿点 badge 配对) */
.overview-month { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 28px;
  background: rgba(255,255,255,.08); color: var(--hero-ink); border: 1px solid rgba(255,255,255,.16);
  font-size: 11.5px; font-weight: 700; padding: 0 12px; border-radius: var(--radius-pill);
  white-space: nowrap; letter-spacing: .02em; line-height: 1; backdrop-filter: blur(8px); }
/* hero 永远深色:圆点用亮色 accent(--brand 默认是纯黑#111,在深色 hero 上几乎看不见 → 显得"暗") */
.overview-month::before { content: ""; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--brand-2); box-shadow: 0 0 8px var(--brand-2); }

/* ===== 报表页重设计 v2(精修:层级/间距/配色) ===== */
#profileReport { --rp-soft: #f3f5f9; }
:root[data-theme="dark"] #profileReport { --rp-soft: rgba(255,255,255,.06); }

/* 页头 */
.report-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin:2px 0 2px; }
.report-head .report-title { font-size:23px; font-weight:800; letter-spacing:-.02em; line-height:1.15; margin:0; }
.report-head .report-sub { color:var(--muted); font-size:13px; font-weight:500; margin:4px 0 0; font-variant-numeric:tabular-nums; }
.report-ekspor { display:inline-flex; align-items:center; gap:7px; flex:none; height:38px; padding:0 16px;
  border:0; border-radius:var(--radius-pill); background:var(--ink); color:#fff; font-size:13px; font-weight:700; cursor:pointer;
  transition:opacity .15s; }
.report-ekspor:active { opacity:.85; }
.report-ekspor svg { width:15px; height:15px; }
:root[data-theme="dark"] .report-ekspor { background:var(--brand); }

/* 范围 = 分段控件(iOS 风:轨道 + 白色活动段) */
.report-seg { display:flex; gap:4px; background:var(--rp-soft); border:1px solid var(--line); border-radius:var(--radius-pill); padding:4px; margin:16px 0 4px; }
.report-seg button { flex:1; min-width:0; height:34px; padding:0 6px; border:0; background:transparent; color:var(--muted);
  font-size:13px; font-weight:600; border-radius:var(--radius-pill); cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  transition:background .15s, color .15s; }
.report-seg button.active { background:var(--card); color:var(--ink); font-weight:700; box-shadow:0 1px 3px rgba(16,24,40,.14); }
:root[data-theme="dark"] .report-seg button.active { background:var(--brand); color:#fff; box-shadow:none; }

/* 自定义日期(仅报表,紧凑) */
#reportCustomRange { background:var(--rp-soft); border:0; border-radius:14px; padding:12px; margin-top:8px; }

/* 区块标题 */
#profileReport .report-zone-title { display:flex; align-items:baseline; justify-content:space-between; gap:10px;
  margin:24px 2px 10px; font-size:15px; font-weight:800; letter-spacing:-.01em; }
#profileReport .report-zone-title.sub { font-size:12.5px; font-weight:700; color:var(--muted); margin:0 2px 8px; }
#profileReport .report-zone-title .tag { font-size:12px; font-weight:600; color:var(--muted); font-variant-numeric:tabular-nums; }

/* 本期收支 hero = 高级深色渐变卡(同首页 hero) */
.period-card { position:relative; background:var(--hero-bg); color:var(--hero-ink); border:0; border-radius:20px;
  padding:20px 18px 18px; box-shadow:0 14px 38px rgba(10,8,4,.42); overflow:hidden; }
.period-card::before { content:""; position:absolute; top:-55%; right:-25%; width:75%; aspect-ratio:1; border-radius:50%;
  background:radial-gradient(closest-side, var(--brand-ring), transparent 70%); pointer-events:none; }
.period-card::after { content:""; position:absolute; bottom:-45%; left:-20%; width:65%; aspect-ratio:1; border-radius:50%;
  background:radial-gradient(closest-side, rgba(34,211,238,.22), transparent 70%); pointer-events:none; }
.period-card > * { position:relative; z-index:1; }
.period-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
.period-label { font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--hero-muted); }
.period-net { font-size:34px; font-weight:800; letter-spacing:-.03em; line-height:1.05; font-variant-numeric:tabular-nums; white-space:nowrap; color:#fff; }
.period-net.pos { color:#34d399; } .period-net.neg { color:#f87171; }
.period-card .delta--up { color:#34d399; } .period-card .delta--down { color:#f87171; } .period-card .delta--flat { color:var(--hero-muted); }
.period-split { display:flex; height:7px; border-radius:999px; overflow:hidden; margin:16px 0 14px; background:rgba(255,255,255,.14); }
.period-split .in { background:#34d399; } .period-split .out { background:#f87171; }
.period-io { display:flex; gap:10px; }
.io-pill { flex:1; border-radius:14px; padding:12px 13px; background:rgba(255,255,255,.07); }
.io-pill .io-k { display:flex; align-items:center; gap:6px; font-size:10.5px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; color:var(--hero-muted); }
.io-pill .io-k i { width:8px; height:8px; border-radius:50%; flex:none; }
.io-pill.in .io-k i { background:#34d399; } .io-pill.out .io-k i { background:#f87171; }
.io-pill .io-v { display:block; font-size:16px; font-weight:800; margin-top:4px; font-variant-numeric:tabular-nums; letter-spacing:-.01em; color:#fff; }

/* 底部留白:最后的图表/表不被底部导航切 */
#profileReport { padding-bottom: 80px; }

/* 分析卡 */
.report-insights .insight-list { background:var(--card); border:1px solid var(--line); border-radius:16px; overflow:hidden; gap:0;
  box-shadow:0 1px 2px rgba(16,24,40,.04); }
.report-insights .insight-row { margin:0; padding:13px 14px; border:0; border-radius:0; box-shadow:none;
  border-bottom:1px solid var(--line); }
.report-insights .insight-row:last-child { border-bottom:0; }
.insight-row .ik { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:13px; }
.insight-row .ic { width:28px; height:28px; flex:none; border-radius:9px; display:grid; place-items:center;
  background:var(--brand-soft); color:var(--brand); font-size:14px; font-weight:700; }
.insight-row strong { font-size:14px; font-weight:700; font-variant-numeric:tabular-nums; }
.insight-row .over { color:var(--danger); font-weight:700; }

/* 图表卡 + 表卡:统一,留足内边距 */
#profileReport .report-chart-card { border-radius:16px; padding:16px; box-shadow:0 1px 2px rgba(16,24,40,.04); }
#profileReport .report-chart-card .chart-box { height:220px; }
#profileReport .report-table-wrap { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:6px 6px 8px; margin-top:12px; box-shadow:0 1px 2px rgba(16,24,40,.04); overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch; }
#profileReport .report-table-wrap > .report-zone-title { position:sticky; left:0; } /* 标题不随表横滚 */
#profileReport .report-table-wrap .report-zone-title.sub { margin:8px 10px 6px; }
#profileReport .report-table th { background:var(--rp-soft); }
#profileReport .report-table th:first-child { border-top-left-radius:10px; border-bottom-left-radius:10px; }
#profileReport .report-table th:last-child { border-top-right-radius:10px; border-bottom-right-radius:10px; }
#profileReport .report-table th, #profileReport .report-table td { padding:9px 6px; border-bottom:1px solid var(--line); }
#profileReport .report-table tbody tr:last-child td { border-bottom:0; }

/* 快照卡片 2 列 */
#reportSnapshotCards.report-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
#reportSnapshotCards .report-card { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:13px 14px;
  box-shadow:0 1px 2px rgba(16,24,40,.04); }
#reportSnapshotCards .report-card span { font-size:11px; font-weight:700; letter-spacing:.03em; text-transform:uppercase; color:var(--muted); }
#reportSnapshotCards .report-card strong { display:block; font-size:16px; font-weight:800; margin-top:4px; font-variant-numeric:tabular-nums; letter-spacing:-.01em; }

/* ===== 品牌科技仪表盘:报表强制深色 + 暖橙辉光(有质感但在品牌内) ===== */
#profileReport {
  --rp-rgb: var(--brand-2-rgb, 255,122,69);
  --card: #18130f; --line: rgba(var(--rp-rgb),.16); --ink: #f5efe9; --muted: #9a8f84;
  --brand: var(--brand-2); --brand-soft: rgba(var(--rp-rgb),.16); --rp-soft: rgba(var(--rp-rgb),.07);
  color: var(--ink);
  background:
    linear-gradient(rgba(var(--rp-rgb),.045) 1px, transparent 1px) 0 0 / 100% 30px,
    radial-gradient(120% 80% at 50% -15%, #2a1c12 0%, #0d0907 56%);
  border: 1px solid rgba(var(--rp-rgb),.18); border-radius: 18px;
  padding: 16px 14px 80px;
  box-shadow: inset 0 0 30px rgba(var(--rp-rgb),.05), 0 18px 50px rgba(0,0,0,.5);
  overflow: hidden; /* 裁切卡片外发光,不溢出面板边 */
}
/* 关键:grid 子项允许收缩,否则 date input 等最小宽度撑爆面板→内容被裁 */
#profileReport > * { min-width: 0; max-width: 100%; }
#profileReport #reportCustomRange { flex-wrap: wrap; }
#profileReport #reportCustomRange label { flex: 1 1 120px; min-width: 0; }
#profileReport #reportCustomRange input { width: 100%; min-width: 0; }
#profileReport #reportCustomRange #reportDateApply { flex: 1 1 100%; }
#profileReport .report-title { color:#fff; text-shadow: 0 0 14px rgba(var(--rp-rgb),.5); letter-spacing:.01em; }
#profileReport .report-sub { color:var(--muted); }
#profileReport .report-ekspor { background: var(--brand-2); color:#fff; font-weight:800; box-shadow: 0 0 16px rgba(var(--rp-rgb),.45); }
#profileReport .report-seg { background: rgba(var(--rp-rgb),.06); border-color: rgba(var(--rp-rgb),.18); }
#profileReport .report-seg button { color: var(--muted); }
#profileReport .report-seg button.active { background: var(--brand-2); color:#fff; box-shadow: 0 0 16px rgba(var(--rp-rgb),.5); }
#profileReport .report-insights .insight-list,
#profileReport .report-chart-card,
#profileReport .report-table-wrap,
#profileReport #reportSnapshotCards .report-card {
  background: rgba(255,255,255,.035); border:1px solid rgba(var(--rp-rgb),.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 0 14px rgba(var(--rp-rgb),.06), 0 8px 22px rgba(0,0,0,.4);
}
#profileReport #reportCustomRange { background: rgba(var(--rp-rgb),.06); }
#profileReport .period-card { border:1px solid rgba(var(--rp-rgb),.22); box-shadow: 0 0 24px rgba(var(--rp-rgb),.12), 0 14px 38px rgba(0,0,0,.5); }
#profileReport .period-net { text-shadow: 0 0 18px currentColor; }
#profileReport .period-net.pos { color:#34d399; } #profileReport .period-net.neg { color:#ff6b6b; }
#profileReport .period-card .delta--up { color:#34d399; } #profileReport .period-card .delta--down { color:#ff6b6b; }
#profileReport .report-zone-title { color:#fff; padding-left:12px; position:relative; text-shadow:0 0 10px rgba(var(--rp-rgb),.35); }
#profileReport .report-zone-title::before { content:""; position:absolute; left:2px; top:50%; transform:translateY(-50%);
  width:3px; height:15px; border-radius:2px; background:var(--brand-2); box-shadow:0 0 10px rgba(var(--rp-rgb),.85); }
#profileReport .report-zone-title.sub { padding-left:2px; color:var(--muted); text-shadow:none; }
#profileReport .report-zone-title.sub::before { display:none; }
#profileReport .report-zone-title .tag { color:var(--muted); }
#profileReport .insight-row .ic { background:rgba(var(--rp-rgb),.14); color:var(--brand-2); box-shadow:inset 0 0 0 1px rgba(var(--rp-rgb),.28), 0 0 8px rgba(var(--rp-rgb),.22); }
#profileReport .insight-row .ik { color:var(--muted); }
#profileReport .insight-row strong { color:#fff; }
#profileReport .report-table th { background:rgba(var(--rp-rgb),.07); color:#d8b8a4; }
#profileReport .report-table td { color:var(--ink); }
#profileReport #reportSnapshotCards .report-card span { color:var(--muted); }
#profileReport #reportSnapshotCards .report-card strong { color:#fff; }
#profileReport .period-net, #profileReport .io-pill .io-v,
#profileReport #reportSnapshotCards .report-card strong {
  font-family: ui-monospace,"SF Mono","Roboto Mono","Noto Sans Mono",monospace;
}

/* 报表 tab */
#profileReport .report-tabs { display:flex; gap:4px; background:rgba(255,255,255,.05); border:1px solid rgba(var(--rp-rgb),.18); border-radius:var(--radius-pill); padding:4px; margin:0 0 10px; }
#profileReport .report-tabs button { flex:1; height:34px; border:0; background:transparent; color:var(--muted); font-size:13px; font-weight:700; border-radius:var(--radius-pill); cursor:pointer; }
#profileReport .report-tabs button.active { background:var(--brand-2); color:#fff; box-shadow:0 0 14px rgba(var(--rp-rgb),.45); }
/* 之最卡 */
#profileReport .sorotan-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
#profileReport .sorotan-card { display:flex; flex-direction:column; gap:3px; background:rgba(255,255,255,.035); border:1px solid rgba(var(--rp-rgb),.16); border-radius:14px; padding:13px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04), 0 0 12px rgba(var(--rp-rgb),.05); }
#profileReport .sorotan-card .sorotan-ic { width:28px; height:28px; border-radius:9px; display:grid; place-items:center; background:rgba(var(--rp-rgb),.14); color:var(--brand-2); }
#profileReport .sorotan-card .sorotan-ic svg { width:16px; height:16px; }
#profileReport .sorotan-card .sorotan-label { font-size:11px; font-weight:700; letter-spacing:.02em; text-transform:uppercase; color:var(--muted); margin-top:4px; }
#profileReport .sorotan-card .sorotan-big { font-size:18px; font-weight:800; color:#fff; font-family:ui-monospace,"SF Mono","Roboto Mono",monospace; font-variant-numeric:tabular-nums; }
#profileReport .sorotan-card .sorotan-sub { font-size:11.5px; color:var(--muted); }

/* 月度趋势:月份竖排(月大·年小),首列窄,给金额更多横向空间 */
#profileReport .report-table .m-stack { display:flex; flex-direction:column; line-height:1.1; }
#profileReport .report-table .m-stack b { font-size:15px; font-weight:800; color:var(--ink); font-variant-numeric:tabular-nums; }
#profileReport .report-table .m-stack i { font-size:11px; font-style:normal; color:var(--muted); }

/* 其他▾ 底部上拉菜单 */
.sheet-backdrop { align-items: flex-end; }
.sheet-card { width: 100%; max-width: 520px; margin: 0 auto; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 8px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
.sheet-item { width: 100%; height: 52px; border: 0; background: transparent; color: var(--ink);
  font-size: 15px; font-weight: 600; border-radius: 12px; cursor: pointer; text-align: center; }
.sheet-item:active { background: var(--brand-soft); }
.sheet-cancel { color: var(--muted); font-weight: 700; }
/* 收入记录 */
/* 收入 panel 的 记录/收入记录 tab —— 复刻 money-tabs 胶囊外观(独立样式,避开 money-tabs 桌面隐藏规则) */
.income-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 4px 0 12px; padding: 4px;
  border-radius: var(--radius-pill); background: var(--soft); border: 1px solid var(--line); }
.income-tabs button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 14px;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--muted-strong); font-size: 12px; font-weight: 700; cursor: pointer; }
.income-tabs button.active { background: var(--ink); color: #fff; box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18); }
:root[data-theme="dark"] .income-tabs button.active { background: var(--brand-grad, var(--brand)); color: #fff; }
/* 收入面板:记录|预期收入|收入记录 三 tab */
#incomeLogTabs { grid-template-columns: 1fr 1fr 1fr; }
#incomeLogTabs button { padding: 0 8px; }
#incomeLogSearch, #reimburseSearch { width: 100%; min-height: 38px; padding: 0 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface, #fff); color: var(--ink); font-size: 14px; }
.add-expected-btn { margin-top: 14px; width: 100%; height: 48px; border: 0; border-radius: var(--radius-md); background: var(--brand-grad); color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; }
.add-expected-btn:active { transform: scale(0.99); }
/* 账户负余额(透支/欠款)用红色突出 */
.account-item strong.neg-balance { color: var(--danger, #dc2626); }
.income-log-cta { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.income-log-cta p { color: var(--muted); font-size: 13px; margin: 0; }
.income-log-cta button { height: 46px; border: 0; border-radius: 12px; background: var(--brand-grad, var(--brand)); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
/* 网格 minmax(0,1fr) auto:强制名称列不超过可用宽(和支出流水行一样),长名换行不撑破面板 */
.income-log-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.income-log-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
/* 导入的流水名常含超长无空格串(WSID…),会撑破行宽→整面板横向溢出。单行截断+省略号。 */
.income-log-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.income-log-main small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.income-log-amt { color: #16a34a; font-variant-numeric: tabular-nums; white-space: nowrap; }
:root[data-theme="dark"] .income-log-amt { color: #34d399; }

/* 环形图自定义图例(白名称+占比第二行,更工整;报表深色 scope) */
#profileReport .chart-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 14px 4px 2px; }
#profileReport .chart-legend-item { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; min-width: 0; }
#profileReport .chart-legend-item i { grid-row: 1 / span 2; width: 12px; height: 12px; border-radius: 3px; }
#profileReport .chart-legend-item .cl-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#profileReport .chart-legend-item .cl-pct { color: var(--brand-2); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* 类别下拉 + 右侧"默认"勾选 */
.select-with-default { display: flex; gap: 8px; align-items: center; }
.select-with-default select { flex: 1; min-width: 0; }
.select-with-default .default-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; }
/* 默认勾选统一为 pill 开关(见 .default-check input[type=checkbox] 规则);此处不再设 16px 方框 */

/* 表单内危险操作链接(删除预算) */
.danger-link { width: 100%; margin-top: 8px; border: 0; background: transparent; color: var(--danger); font-size: 13px; font-weight: 700; padding: 8px; cursor: pointer; border-radius: 8px; }
.danger-link:active { background: rgba(220,38,38,.08); }
/* 删除二次确认弹窗的红色主按钮 */
.danger-btn { height: 46px; border: 0; border-radius: var(--radius-md); background: var(--danger, #dc2626); color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; }
.danger-btn:active { transform: scale(0.98); }

/* 自定义大月历日期选择器 */
/* 隐藏原生日历指示器,统一走自定义弹窗;只读 date 输入仍可点。
   iOS WebKit 的 date input 有固有宽度,不收缩会撑破弹窗(手机端日期框溢出),
   强制占满列宽+允许收缩+去掉原生外观。 */
input[type="date"] { cursor: pointer; width: 100%; min-width: 0; box-sizing: border-box; -webkit-appearance: none; appearance: none; }
input[type="date"]::-webkit-calendar-picker-indicator { display: none; -webkit-appearance: none; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.cal-card { width: 360px; max-width: 94vw; padding: 18px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head strong { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.cal-nav { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--soft); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.cal-nav:active { transform: scale(0.94); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 6px; }
.cal-weekdays span { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid button { aspect-ratio: 1 / 1; border: 0; border-radius: 12px; background: transparent; color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.cal-grid button:hover { background: var(--hover); }
.cal-grid button.is-empty { visibility: hidden; cursor: default; }
.cal-grid button.is-today { box-shadow: inset 0 0 0 2px var(--brand); font-weight: 800; }
.cal-grid button.is-selected { background: var(--brand-grad); color: #fff; font-weight: 800; }
.cal-foot { display: flex; gap: 8px; margin-top: 16px; }
.cal-foot button { flex: 1; height: 44px; border-radius: var(--radius-md); font-size: 15px; font-weight: 700; cursor: pointer; }

/* ── Split Bill 分摊弹窗 ── */
.split-card { width: 420px; max-width: 94vw; max-height: 88vh; overflow-y: auto; overflow-x: hidden; box-sizing: border-box; }
/* 手机端防溢出:所有 label 列布局,input 占满列宽且允许收缩(原生 input 有固有最小宽度) */
#splitReview label { display: grid; gap: 5px; min-width: 0; font-size: 13px; color: var(--muted-strong); }
#splitReview input, #splitReview select { width: 100%; min-width: 0; box-sizing: border-box; }
.split-mode-tabs button, .split-pay-tabs button { min-width: 0; padding: 0 6px; white-space: normal; line-height: 1.2; }
.split-source { display: flex; gap: 10px; margin: 6px 0 4px; }
.split-photo-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; border: 0; border-radius: var(--radius-md); background: var(--brand-grad); color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; }
.split-photo-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.split-source .secondary-button { flex: 0 0 auto; height: 52px; padding: 0 16px; border-radius: var(--radius-md); cursor: pointer; }
.split-parsing { margin: 10px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.split-sub { display: block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-strong); margin: 14px 0 8px; }
.split-items { display: flex; flex-direction: column; gap: 6px; }
.split-item { display: grid; grid-template-columns: minmax(0,1fr) 92px 28px; gap: 8px; align-items: center; }
.split-item input { min-height: 36px; }
.split-item .si-del { border: 0; background: transparent; color: var(--muted); font-size: 17px; cursor: pointer; padding: 0; }
.split-item-chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; margin: -2px 0 4px; }
.split-item-chips button { min-height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted-strong); font-size: 11px; font-weight: 700; cursor: pointer; }
.split-item-chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.split-fees { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin-top: 12px; }
.split-fees label span { font-size: 12px; }
.split-fees input { min-height: 38px; }
.split-people { display: flex; flex-wrap: wrap; gap: 6px; }
.split-people button { min-height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted-strong); font-size: 13px; font-weight: 700; cursor: pointer; }
.split-people button.on { background: var(--brand-grad); border-color: transparent; color: #fff; }
.split-add-person { display: flex; gap: 8px; margin-top: 8px; }
.split-add-person input { flex: 1; min-height: 38px; }
.split-add-person button { flex: 0 0 auto; width: 44px; border-radius: var(--radius-md); font-size: 18px; cursor: pointer; }
.split-mode-tabs, .split-pay-tabs { margin-top: 14px; }
.split-result { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.split-result .sr-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.split-result .sr-row:last-child { border-bottom: 0; }
.split-result .sr-row b { font-variant-numeric: tabular-nums; }
.split-result .sr-row.me { background: var(--soft); }
.split-result .sr-note { padding: 8px 14px; font-size: 11px; color: var(--muted); }

/* ── 工具面板(我→资料→工具):Split Bill + 税计算器手风琴 ── */
.tool-list { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--card); }
.tool-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; text-align: left; }
.tool-list > .tool-row:last-of-type { border-bottom: 0; }
.tool-row .tool-ic { display: flex; width: 34px; height: 34px; border-radius: 10px; background: var(--soft); align-items: center; justify-content: center; flex: none; }
.tool-row .tool-ic svg { width: 18px; height: 18px; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool-row .tool-chev { margin-left: auto; font-style: normal; color: var(--muted); font-size: 15px; }
.tool-acc { padding: 4px 16px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.tool-acc label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted-strong); }
.tool-acc input, .tool-acc select { min-height: 40px; }
.tool-result { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tool-result .tr-row { display: flex; justify-content: space-between; padding: 9px 13px; border-bottom: 1px solid var(--line); font-size: 13px; }
.tool-result .tr-row:last-child { border-bottom: 0; }
.tool-result .tr-row b { font-variant-numeric: tabular-nums; }
.tool-result .tr-row.hl { background: var(--soft); font-weight: 800; }
.tool-result:empty { display: none; }
.tool-disclaimer { margin-top: 10px; font-size: 11px; color: var(--muted); text-align: center; }
/* 分摊记录列表 */
.split-history { display: flex; flex-direction: column; gap: 8px; }
.sh-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.sh-item .sh-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.sh-item .sh-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sh-item .sh-top b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-item small { color: var(--muted); font-size: 11px; }
.sh-item .sh-shares { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.sh-item .sh-shares span { font-size: 11px; color: var(--muted-strong); font-variant-numeric: tabular-nums; }
.ppn-tabs { margin: 2px 0 0; }
