/* =========================================================================
   TBT — styles
   Sections: 1 Tokens · 2 Base · 3 Shell & tab bar · 4 Quick-add & keypad
             5 Cards & dashboard · 6 Charts · 7 History · 8 Converter
             9 Sheets, forms, dialogs · 10 Toast & save burst · 11 Misc
   ========================================================================= */

/* ---------- 1. TOKENS ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabbar-h: 54px;
  --pad: 16px;
  --radius: 18px;
  --tap: 44px;

  /* status colours (fixed; always paired with icon + label) */
  --good: #0aac23;
  --warn: #fbb315;
  --bad: #dc3c3d;
}

/* Dark (default): true black for OLED */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0e0e10;
  --surface-2: #17171a;
  --surface-3: #222226;
  --line: #232327;
  --text: #f5f5f7;
  --text-2: #a1a1a8;
  --text-3: #6c6c74;
  --primary-bg: #f5f5f7;
  --primary-fg: #000000;
  --accent: #338ced;
  --op-fg: #8fbaf5;
  --sb-bg: transparent;
  /* chart series (dark steps) */
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  --s-other: #5c5c64; --s-other-2: #7a7a82; --s-other-3: #45454c;
  --c-kr: #338ced; --c-jp: #eb6263; --c-none: #4a4a52;
  --track: #1d1d21;
}

/* Light */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f5;
  --surface: #ffffff;
  --surface-2: #ececf0;
  --surface-3: #e0e0e6;
  --line: #e2e2e8;
  --text: #0b0b0f;
  --text-2: #5c5c66;
  --text-3: #8d8d96;
  --primary-bg: #0b0b0f;
  --primary-fg: #ffffff;
  --accent: #1f6fd1;
  --op-fg: #1f6fd1;
  /* If iOS keeps the translucent status bar (white text), paint the strip dark */
  --sb-bg: #0b0b0f;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --s5: #ee7fac; --s6: #008a17; --s7: #6a4ce2; --s8: #ec4647;
  --s-other: #a3a3ab; --s-other-2: #c4c4cb; --s-other-3: #85858d;
  --c-kr: #257de0; --c-jp: #ec4647; --c-none: #c4c4cb;
  --track: #e6e6eb;
}

/* ---------- 2. BASE ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, select, textarea {
  font: inherit; font-size: 16px; /* ≥16px stops iOS zoom-on-focus */
  color: var(--text);
}
[hidden] { display: none !important; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sb-fill { position: fixed; top: 0; left: 0; right: 0; height: var(--safe-t); background: var(--sb-bg); z-index: 50; pointer-events: none; }

/* ---------- 3. SHELL & TAB BAR ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#views { position: relative; flex: 1; min-height: 0; }
.view {
  position: absolute; inset: 0;
  display: none;
  padding: calc(var(--safe-t) + 8px) calc(var(--pad) + var(--safe-r)) 12px calc(var(--pad) + var(--safe-l));
}
.view.active { display: block; }
.view.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 28px; }
.view-add.active { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; overscroll-behavior: contain; }

.big-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 2px 12px; }
.big-head h1 { font-size: 32px; letter-spacing: -0.02em; margin: 0; font-weight: 800; }
.head-sub { color: var(--text-2); font-size: 14px; text-align: right; }

.tabbar {
  flex: none;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tap); color: var(--text-3); font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg circle { fill: currentColor; stroke-width: 1.6; }
.tabbar button.active { color: var(--text); }

/* Horizontal scrollers */
.hscroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); scroll-padding: 0 var(--pad); }
.hscroll::-webkit-scrollbar { display: none; }

/* ---------- 4. QUICK-ADD & KEYPAD ---------- */
.add-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { min-width: 58px; min-height: 40px; padding: 0 14px; border-radius: 11px; font-size: 18px; font-weight: 700; color: var(--text-2); }
.seg button.on { background: var(--primary-bg); color: var(--primary-fg); }
.leg-pill { min-width: 0; overflow: hidden; text-overflow: ellipsis; min-height: var(--tap); padding: 0 14px; border-radius: 22px; background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap; }

.edit-banner { flex: none; display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); font-weight: 600; font-size: 15px; }
.edit-banner span { flex: 1; }
.link-btn { min-height: 40px; padding: 0 12px; color: var(--accent); font-weight: 600; }
.edit-banner #editDelete { color: var(--bad); }

.display { flex: none; text-align: right; padding: 2px 4px 0; user-select: none; -webkit-user-select: none; }
.display .expr { font-family: var(--font-num); color: var(--text-2); font-size: 17px; min-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.display .amount { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 54px; line-height: 1.05; font-weight: 700; letter-spacing: -0.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display .amount.small { font-size: 42px; }
.display .amount.xsmall { font-size: 34px; }
.display .aud { font-family: var(--font-num); color: var(--text-2); font-size: 18px; font-weight: 600; min-height: 24px; }
.display .aud b { color: var(--text); }
.shake { animation: shake .35s; }
@keyframes shake { 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }

.fav-row { flex: none; }
.fav-row:empty { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  min-height: var(--tap); padding: 0 14px; border-radius: 22px;
  background: var(--surface-2); border: 1px solid transparent;
  font-size: 15px; font-weight: 600; white-space: nowrap; color: var(--text);
}
.chip .e { font-size: 18px; line-height: 1; }
.chip .sub { color: var(--text-2); font-weight: 500; font-family: var(--font-num); }
.chip.on { background: var(--primary-bg); color: var(--primary-fg); }
.chip.on .sub { color: inherit; opacity: .7; }
.chip.fav { background: transparent; border-color: var(--line); }
.chip.dim { opacity: .45; }
.chip.add-chip { color: var(--text-2); background: transparent; border: 1px dashed var(--surface-3); }

.cat-grid { flex: none; display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, var(--tap)); gap: 8px; }
.cat-grid .chip { max-width: 210px; }
.cat-grid .chip .t { overflow: hidden; text-overflow: ellipsis; }
.wallet-row { flex: none; }

.extras { flex: none; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.x-btn {
  min-height: var(--tap); border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600; color: var(--text-2); gap: 1px; padding: 3px 2px; position: relative; overflow: hidden;
}
.x-btn .e { font-size: 17px; line-height: 1.1; }
.x-btn.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.x-btn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.x-btn .lbl { position: relative; white-space: nowrap; }

.extra-panel { flex: none; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.extra-panel .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.extra-panel .lab { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

.keypad {
  flex: 1; min-height: 250px;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(5, 1fr); gap: 8px;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.key {
  min-height: 46px; border-radius: 18px; background: var(--surface-2);
  font-family: var(--font-num); font-size: 28px; font-weight: 500; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: transform .06s ease, background-color .12s ease;
}
.key:active, .key.pressed { transform: scale(.95); background: var(--surface-3); }
.key.op { color: var(--op-fg); font-size: 30px; background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.key.fn { color: var(--text-2); font-size: 22px; }
.key.save { grid-column: span 3; background: var(--primary-bg); color: var(--primary-fg); font-family: var(--font); font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.key.save:active, .key.save.pressed { background: color-mix(in srgb, var(--primary-bg) 80%, var(--bg)); }
.key svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 5. CARDS & DASHBOARD ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 12px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.card h3 .r { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text-2); }
.hero .label { color: var(--text-2); font-size: 14px; font-weight: 600; }
.hero .big { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 46px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin: 2px 0 6px; }
.hero .big.neg { color: var(--bad); }
.hero .of { color: var(--text-2); font-size: 15px; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; margin: 12px 0 4px; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--text); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.kpi { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.kpi .k { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kpi .v { font-family: var(--font-num); font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.pace { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 20px; font-size: 13px; font-weight: 700; }
.pace.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pace.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pace.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
:root[data-theme="light"] .pace.warn { color: #9a6700; }

.today-row { display: flex; align-items: center; gap: 16px; }
.today-row .ring { flex: none; }
.today-row .meta { flex: 1; min-width: 0; }
.today-row .meta .v { font-family: var(--font-num); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

.warn-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.alert { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; border: 1px solid; }
.alert.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); }
.alert.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.alert .ico { font-size: 18px; }

.wallet-cards { margin-bottom: 12px; }
.w-card { flex: none; width: 168px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: left; min-height: var(--tap); }
.w-card .n { font-size: 13px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-card .b { font-family: var(--font-num); font-size: 22px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-card .b.neg { color: var(--bad); }
.w-card .s { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.list-rows { display: flex; flex-direction: column; }
.lrow { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow .e { font-size: 20px; width: 28px; text-align: center; flex: none; }
.lrow .t { flex: 1; min-width: 0; font-weight: 600; }
.lrow .t small { display: block; color: var(--text-3); font-weight: 500; font-size: 12.5px; }
.lrow .v { font-family: var(--font-num); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lrow .v small { display: block; color: var(--text-3); font-weight: 500; font-size: 12px; }
.lrow.btn { width: 100%; text-align: left; }
.chev { color: var(--text-3); font-size: 20px; }

.legend { display: grid; grid-template-columns: 1fr; gap: 2px; margin-top: 12px; }
.lg { display: flex; align-items: center; gap: 10px; min-height: 34px; font-size: 14px; border-radius: 10px; padding: 0 6px; width: 100%; text-align: left; }
.lg.on { background: var(--surface-2); }
.lg .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lg .n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg .p { color: var(--text-3); font-family: var(--font-num); width: 42px; text-align: right; }
.lg .a { font-family: var(--font-num); font-weight: 700; min-width: 84px; text-align: right; }

.country-cmp { display: flex; flex-direction: column; gap: 14px; }
.cc-row .top { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.cc-row .top .a { font-family: var(--font-num); }
.cc-row .sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; display: flex; justify-content: space-between; }
.cc-row .bar { margin: 8px 0 0; }
.cc-row.kr .bar > i { background: var(--c-kr); }
.cc-row.jp .bar > i { background: var(--c-jp); }

.rates-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); }
.rates-foot .r { font-family: var(--font-num); color: var(--text); font-weight: 600; }
.small-btn { min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.small-btn.tap { min-height: var(--tap); }

/* ---------- 6. CHARTS ---------- */
.donut-wrap { display: flex; justify-content: center; position: relative; }
.donut-wrap svg { display: block; overflow: visible; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.donut-center .k { font-size: 13px; color: var(--text-2); font-weight: 600; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-center .v { font-family: var(--font-num); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.donut-center .p { font-size: 12px; color: var(--text-3); }
.seg-hit { cursor: pointer; }
.chart-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
.chart-scroll::-webkit-scrollbar { display: none; }
.chart-scroll svg { display: block; }
.chart-tip { min-height: 22px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.chart-tip b { color: var(--text); font-family: var(--font-num); }
.axis-t { font-size: 10px; fill: var(--text-3); font-family: var(--font-num); }
.axis-t.today { fill: var(--text); font-weight: 700; }
.mini-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; flex-wrap: wrap; }
.mini-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mini-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.mini-legend i.dash { height: 0; border-top: 2px dashed var(--text-2); border-radius: 0; width: 14px; }

/* ---------- 7. HISTORY ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 8px; position: sticky; top: -8px; z-index: 3; background: var(--bg); padding: 4px 0 6px; }
.search-bar input { flex: 1; min-height: var(--tap); border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; outline: none; -webkit-appearance: none; appearance: none; }
.search-bar input:focus { border-color: var(--accent); }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border-radius: 14px; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; position: relative; font-size: 18px; color: var(--text); }
.icon-btn .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 4px; background: var(--accent); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.filter-chips:empty { display: none; }
.fchip { min-height: 36px; padding: 0 12px; border-radius: 18px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); font-size: 13.5px; font-weight: 600; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 4px 6px; font-size: 14px; font-weight: 700; color: var(--text-2); }
.day-head .a { font-family: var(--font-num); color: var(--text); }
.day-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tx-row { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.tx-row:last-child { border-bottom: 0; }
.tx-del { position: absolute; inset: 0; background: var(--bad); color: #fff; display: flex; align-items: center; justify-content: flex-end; padding-right: 22px; font-weight: 700; }
.tx-main { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 60px; background: var(--surface); touch-action: pan-y; user-select: none; -webkit-user-select: none; will-change: transform; }
.tx-main.anim { transition: transform .22s ease; }
.tx-ico { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 19px; flex: none; }
.tx-mid { flex: 1; min-width: 0; }
.tx-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); margin-left: 4px; vertical-align: 1px; }
.badge.tf { background: color-mix(in srgb, var(--good) 22%, transparent); color: var(--good); }
.tx-amt { text-align: right; flex: none; }
.tx-amt .o { font-family: var(--font-num); font-weight: 700; font-variant-numeric: tabular-nums; }
.tx-amt .o.in { color: var(--good); }
.tx-amt .au { font-family: var(--font-num); font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--text-3); padding: 48px 20px; font-size: 15px; }
.empty .e { font-size: 40px; display: block; margin-bottom: 10px; }
.swipe-hint { text-align: center; color: var(--text-3); font-size: 12px; padding: 14px 0 0; }

/* ---------- 8. CONVERTER ---------- */
.conv-results { flex: none; display: flex; flex-direction: column; gap: 6px; }
.conv-line { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; min-height: var(--tap); }
.conv-line .k { font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.conv-line .v { font-family: var(--font-num); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.conv-line.main .v { font-size: 24px; }
.conv-ref { display: flex; gap: 6px; }
.conv-ref button { flex: 1; min-height: var(--tap); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; color: var(--text-2); line-height: 1.2; }
.conv-ref button b { display: block; color: var(--text); font-family: var(--font-num); font-size: 13px; }

/* ---------- 9. SHEETS, FORMS, DIALOGS ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); opacity: 0; transition: opacity .25s; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: relative; width: 100%; max-width: 560px;
  max-height: calc(100% - var(--safe-t) - 10px);
  background: var(--surface); border-radius: 24px 24px 0 0; border: 1px solid var(--line); border-bottom: 0;
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
:root[data-theme="dark"] .sheet { background: #0c0c0e; }
.sheet-wrap.open .sheet { transform: none; }
.sheet.full { height: calc(100% - var(--safe-t) - 10px); }
.sheet-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px 6px 20px; flex: none; }
.sheet-head h2 { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 6px 20px 20px; }
.sheet-foot { flex: none; padding: 10px 20px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-body.pad-b { padding-bottom: calc(24px + var(--safe-b)); }

.fsec { margin: 8px 0 22px; }
.fsec > h4 { margin: 0 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.fsec > p.hint, .hint { font-size: 13px; color: var(--text-3); margin: 6px 2px 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.inp, .sel {
  width: 100%; min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); padding: 0 12px; outline: none; -webkit-appearance: none; appearance: none;
}
.inp:focus, .sel:focus { border-color: var(--accent); }
.sel { background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="date"].inp, input[type="datetime-local"].inp { display: flex; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .field { margin-bottom: 0; }
.inline-in { display: flex; gap: 8px; }
.inline-in .inp { flex: 1; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 4px 0; }
.switch-row .t { font-weight: 600; }
.switch-row .t small { display: block; font-weight: 500; color: var(--text-3); font-size: 12.5px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 1; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 16px; background: var(--surface-3); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(20px); }

.btn { min-height: 50px; border-radius: 14px; padding: 0 18px; font-weight: 700; font-size: 16px; background: var(--surface-2); color: var(--text); flex: 1; }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); }
.btn.danger { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); color: var(--bad); }
.btn.block { width: 100%; display: block; }
.btn:disabled { opacity: .45; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }

.item-list { background: var(--surface-2); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 4px 6px 4px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .e { font-size: 19px; width: 26px; text-align: center; }
.item .t { flex: 1; min-width: 0; font-weight: 600; }
.item .t small { display: block; color: var(--text-3); font-weight: 500; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .mini { min-width: 40px; min-height: var(--tap); border-radius: 10px; color: var(--text-2); font-size: 16px; }
.item.tap { width: 100%; text-align: left; }
.add-line { min-height: 48px; width: 100%; text-align: left; padding: 0 14px; color: var(--accent); font-weight: 700; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

.dialog-wrap { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.6); opacity: 0; transition: opacity .18s; }
.dialog-wrap.open { opacity: 1; }
.dialog { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px; transform: scale(.94); transition: transform .18s; }
.dialog-wrap.open .dialog { transform: none; }
.dialog h3 { margin: 0 0 6px; font-size: 18px; }
.dialog p { margin: 0 0 16px; color: var(--text-2); font-size: 15px; white-space: pre-line; }
.dialog .btn-col .btn { flex: none; }

.setup-hero { text-align: center; padding: 4px 0 18px; }
.setup-hero img { width: 72px; height: 72px; border-radius: 18px; }
.setup-hero h1 { margin: 10px 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.setup-hero p { margin: 0; color: var(--text-2); font-size: 15px; }

.photo-view { width: 100%; border-radius: 14px; display: block; }

/* ---------- 10. TOAST & SAVE BURST ---------- */
#toastRoot { position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 6px); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 420px; width: 100%; background: var(--primary-bg); color: var(--primary-fg); border-radius: 16px; padding: 8px 8px 8px 16px; min-height: 48px; font-size: 15px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.35); transform: translateY(-20px); opacity: 0; transition: transform .25s, opacity .25s; }
.toast.show { transform: none; opacity: 1; }
.toast .m { flex: 1; }
.toast button { min-height: 40px; padding: 0 14px; border-radius: 12px; font-weight: 800; color: var(--accent); background: color-mix(in srgb, var(--primary-fg) 8%, transparent); }
:root[data-theme="dark"] .toast button { color: #1f6fd1; }

#savedBurst { position: fixed; inset: 0; z-index: 250; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; pointer-events: none; opacity: 0; }
#savedBurst.go { animation: burstFade .75s ease forwards; }
.burst-circle { width: 96px; height: 96px; border-radius: 50%; background: var(--good); display: flex; align-items: center; justify-content: center; transform: scale(.4); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); }
#savedBurst.go .burst-circle { animation: burstPop .75s cubic-bezier(.2,1.4,.4,1) forwards; }
.burst-circle svg { width: 56px; height: 56px; fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; }
#savedBurst.go .burst-circle svg { animation: draw .35s .12s ease forwards; }
.burst-amt { font-family: var(--font-num); font-size: 22px; font-weight: 800; background: var(--surface); border: 1px solid var(--line); padding: 6px 14px; border-radius: 14px; }
@keyframes burstFade { 0% { opacity: 0; } 12% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes burstPop { 0% { transform: scale(.4); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 45% { transform: scale(1.05); } 100% { transform: scale(1); box-shadow: 0 0 0 40px transparent; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- 11. MISC ---------- */
@media (max-height: 760px) {
  .display .amount { font-size: 44px; }
  .key { font-size: 24px; border-radius: 14px; }
  .view-add.active { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
