/* =============================================================================
   KonLedger — Bento UI
   Tokens → base → shell → bento grid → components → views → motion → responsive
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
/* Brand: white · black · #3182ce. Text-on-white uses #2B6CB0 (same hue, AA contrast). */
:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;

  --brand: #3182CE;
  --brand-ink: #FFFFFF;
  --black: #0B0B0D;

  --bg: #F2F3F5;
  --bg-glass: rgba(242, 243, 245, 0.74);
  --tile: #FFFFFF;
  --tile-2: #F7F8FA;
  --tile-3: #ECEEF1;
  --ink: #0B0B0D;
  --ink-2: #33363D;
  --muted: #5F6470;          /* 5.9:1 on white */
  --line: #E5E7EB;
  --line-2: #D4D7DD;

  --accent: #2B6CB0;         /* brand blue, AA for text on white (5.4:1) */
  --accent-2: #63B3ED;
  --accent-ink: #FFFFFF;
  --accent-tint: #E6F0FA;
  --accent-grad: linear-gradient(140deg, #0B0B0D 0%, #15171C 55%, #1C2A3D 100%);

  --primary-bg: #0B0B0D;     /* primary buttons: black */
  --primary-ink: #FFFFFF;

  --green: #087A55;
  --green-2: #10B981;
  --green-tint: #E2F6EE;
  --red: #C9303B;
  --red-2: #F43F5E;
  --red-tint: #FDE9EB;
  --amber: #9A5B00;
  --amber-2: #F59E0B;
  --amber-tint: #FFF1D6;
  --blue: #2B6CB0;
  --blue-tint: #E6F0FA;

  --r-xs: 8px;
  --r-sm: 12px;
  --r: 16px;
  --r-lg: 20px;
  --r-xl: 28px;

  --gap: 12px;
  --pad: 16px;
  --shadow-1: 0 1px 2px rgba(11, 11, 13, 0.05), 0 1px 1px rgba(11, 11, 13, 0.03);
  --shadow-2: 0 10px 30px -12px rgba(11, 11, 13, 0.2), 0 2px 6px rgba(11, 11, 13, 0.05);
  --shadow-3: 0 24px 60px -20px rgba(11, 11, 13, 0.4);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 40%, transparent);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.32, 1.28, .5, 1);
  --t-fast: 140ms;
  --t: 240ms;
  --t-slow: 420ms;

  --nav-h: 68px;
  --top-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-glass: rgba(0, 0, 0, 0.72);
  --tile: #121316;
  --tile-2: #191B1F;
  --tile-3: #23262B;
  --ink: #F5F6F8;
  --ink-2: #D2D5DB;
  --muted: #9CA1AB;
  --line: #24272D;
  --line-2: #33373E;
  --accent: #63B3ED;
  --accent-2: #90CDF4;
  --accent-ink: #000000;
  --accent-tint: rgba(49, 130, 206, 0.18);
  --accent-grad: linear-gradient(140deg, #0F2A47 0%, #1A4F82 55%, #3182CE 100%);
  --primary-bg: #FFFFFF;
  --primary-ink: #000000;
  --green: #4ADE9D;
  --green-tint: rgba(74, 222, 157, 0.13);
  --red: #FB7185;
  --red-tint: rgba(251, 113, 133, 0.14);
  --amber: #FBBF24;
  --amber-tint: rgba(251, 191, 36, 0.14);
  --blue: #63B3ED;
  --blue-tint: rgba(99, 179, 237, 0.15);
  --shadow-1: none;
  --shadow-2: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, 0.9);
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  min-height: 100dvh;
}
html[lang="hi"] body { font-size: 15.5px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 750; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
.ic { flex: none; }
[hidden] { display: none !important; }
::selection { background: var(--accent-tint); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
main.view:focus, main.view:focus-visible { box-shadow: none; }
a.tile, a.item { color: inherit; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num, .money { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 700; }
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.accent { color: var(--accent); }
.center { text-align: center; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }
.gap-sm { gap: 6px; }
.stack > * + * { margin-top: var(--gap); }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) var(--pad) 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t) var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .title { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }

.biz-switch {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 4px 10px 4px 4px;
  border: 0; border-radius: 999px; background: var(--tile);
  box-shadow: var(--shadow-1); max-width: 60vw;
  transition: transform var(--t-fast) var(--ease);
}
.biz-switch:active { transform: scale(.97); }
.biz-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 800; font-size: 14px;
  background: var(--c, var(--accent));
}
.biz-switch .name { font-weight: 700; font-size: 15px; }

.icon-btn {
  position: relative;
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--tile); color: var(--ink);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast);
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { background: transparent; box-shadow: none; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--red-2); color: #fff; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid var(--tile);
}

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700;
  background: var(--amber-tint); color: var(--amber);
  animation: pop-in var(--t) var(--spring);
}
.sync-pill.ok { background: var(--green-tint); color: var(--green); }
.sync-pill.off { background: var(--tile-3); color: var(--muted); }
.sync-pill .spin { animation: spin 1s linear infinite; }

main.view {
  padding: 8px var(--pad) calc(var(--nav-h) + var(--safe-b) + 32px);
  max-width: 1280px; margin: 0 auto;
}

/* bottom nav (phone) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; border-radius: var(--r);
  color: var(--muted); font-size: 11px; font-weight: 650;
  transition: color var(--t-fast);
}
.nav-item .ic { transition: transform var(--t) var(--spring); }
.nav-item.active { color: var(--accent); }
.nav-item.active .ic { transform: translateY(-1px) scale(1.08); }
.nav-item:active .ic { transform: scale(.88); }
.fab {
  justify-self: center;
  width: 60px; height: 60px; margin-top: -26px;
  border: 0; border-radius: 22px;
  display: grid; place-items: center;
  color: #fff; background: var(--brand);
  box-shadow: 0 12px 28px -8px color-mix(in srgb, var(--brand) 75%, transparent), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform var(--t) var(--spring), border-radius var(--t) var(--ease);
}
.fab:active { transform: scale(.9) rotate(-8deg); }
.fab.open { transform: rotate(45deg); border-radius: 50%; }

/* sidebar (desktop) */
.sidebar { display: none; }

/* ---------------------------------------------------------------- bento grid */
.bento {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  grid-auto-flow: dense;
}
.bento > * { min-width: 0; }
.span-2, .full { grid-column: span 2; }
.row-2 { grid-row: span 2; }

.tile {
  position: relative;
  background: var(--tile);
  border-radius: var(--r-lg);
  padding: var(--pad);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  isolation: isolate;
}
.tile.flat { box-shadow: none; background: var(--tile-2); }
.tile.pad-0 { padding: 0; }
.tile.link { cursor: pointer; transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease); }
.tile.link:hover { box-shadow: var(--shadow-2); }
.tile.link:active { transform: scale(.985); }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.tile-head h3 { font-size: 14px; }
.tile-head .more { font-size: 13px; font-weight: 650; color: var(--accent); display: inline-flex; align-items: center; gap: 2px; min-height: 32px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.big { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.mid { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }

.tile.hero {
  color: #fff; background: var(--accent-grad);
  box-shadow: 0 18px 40px -18px rgba(11, 11, 13, .55);
}
.tile.hero .eyebrow, .tile.hero .muted { color: rgba(255,255,255,.82); }
.tile.hero::after {
  content: ""; position: absolute; z-index: -1; inset: auto -40px -60px auto;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--brand) 70%, transparent), transparent);
}
.tile.hero::before {
  content: ""; position: absolute; z-index: -1; inset: -50px auto auto -30px;
  width: 140px; height: 140px; border-radius: 40px; transform: rotate(25deg);
  background: rgba(255,255,255,.08);
}
.tile.t-green { background: var(--green-tint); box-shadow: none; }
.tile.t-red { background: var(--red-tint); box-shadow: none; }
.tile.t-amber { background: var(--amber-tint); box-shadow: none; }
.tile.t-accent { background: var(--accent-tint); box-shadow: none; }
.tile.t-blue { background: var(--blue-tint); box-shadow: none; }

.tile-ic {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; flex: none;
  background: var(--tile-3); color: var(--ink);
}
.t-green .tile-ic { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.t-red .tile-ic { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.t-amber .tile-ic { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.t-accent .tile-ic { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.hero .tile-ic { background: rgba(255,255,255,.2); color: #fff; }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 750; padding: 3px 8px; border-radius: 99px;
  background: var(--tile-3); color: var(--muted);
}
.delta.up { background: var(--green-tint); color: var(--green); }
.delta.down { background: var(--red-tint); color: var(--red); }
.hero .delta { background: rgba(255,255,255,.2); color: #fff; }

/* ---------------------------------------------------------------- buttons */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r);
  font-weight: 700; font-size: 15px; letter-spacing: -0.005em;
  background: var(--tile); color: var(--ink); border-color: var(--line);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--primary-bg); color: var(--primary-ink); border-color: transparent; box-shadow: 0 8px 20px -12px rgba(0,0,0,.45); }
.btn.brand { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.green { background: var(--green-2); color: #04291c; border-color: transparent; }
.btn.danger { background: var(--red-tint); color: var(--red); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.soft { background: var(--accent-tint); color: var(--accent); border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn.lg { min-height: 56px; font-size: 16px; border-radius: 18px; }
.btn .ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .18; transform: scale(0);
  animation: ripple 520ms var(--ease) forwards;
}
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--primary-ink); border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn:not(.primary).loading::after { border-color: var(--ink); border-right-color: transparent; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* chips & segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--tile); color: var(--ink-2);
  font-size: 14px; font-weight: 650; white-space: nowrap; scroll-snap-align: start;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--ink); color: var(--tile); border-color: var(--ink); }
.chip.on-accent { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip.sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; gap: 4px; border-radius: var(--r); background: var(--tile-3);
}
.seg button {
  min-height: 40px; border: 0; border-radius: 12px; background: transparent;
  font-weight: 700; font-size: 14px; color: var(--muted);
  transition: background var(--t) var(--ease), color var(--t), box-shadow var(--t);
}
.seg button.on { background: var(--tile); color: var(--ink); box-shadow: var(--shadow-1); }
.seg.type button.on[data-v="expense"] { color: var(--red); }
.seg.type button.on[data-v="income"] { color: var(--green); }
.seg.type button.on[data-v="transfer"] { color: var(--blue); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 750;
  background: var(--tile-3); color: var(--muted); white-space: nowrap;
}
.pill.green { background: var(--green-tint); color: var(--green); }
.pill.red { background: var(--red-tint); color: var(--red); }
.pill.amber { background: var(--amber-tint); color: var(--amber); }
.pill.accent { background: var(--accent-tint); color: var(--accent); }
.pill.blue { background: var(--blue-tint); color: var(--blue); }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r);
  background: var(--tile); color: var(--ink); font-size: 16px; /* 16px stops iOS zoom */
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  appearance: none; -webkit-appearance: none;
}
.textarea { min-height: 88px; resize: vertical; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2367647E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.field.err .input, .field.err .select, .field.err .textarea { border-color: var(--red); }
.field .err-msg { color: var(--red); font-size: 12.5px; font-weight: 600; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; pointer-events: none; }
.input-group .input { padding-left: 34px; }
.input-group .suffix-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.form-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form-grid > *, .field { min-width: 0; }
.input[type="date"] { min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 46px; height: 28px; border-radius: 99px; background: var(--line-2); flex: none;
  position: relative; transition: background var(--t) var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform var(--t) var(--spring);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ---------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; }
.list-group-title {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px 4px 8px; font-size: 13px; font-weight: 750; color: var(--muted);
}
.list-card { background: var(--tile); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.item {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 14px; background: var(--tile);
  border: 0; width: 100%; text-align: left; color: inherit;
}
.list-card .item + .item, .list-card .swipe + .swipe { border-top: 1px solid var(--line); }
button.item, a.item { cursor: pointer; transition: background var(--t-fast); }
button.item:active, a.item:active { background: var(--tile-2); }
.item .avatar {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent);
  color: var(--c, var(--accent));
}
.item .t1 { font-weight: 650; font-size: 15px; }
.item .t2 { font-size: 12.5px; color: var(--muted); }
.item .amt { font-weight: 750; font-size: 15.5px; text-align: right; }
.item .amt.in { color: var(--green); }
.item .amt.out { color: var(--ink); }
.item .amt.tr { color: var(--blue); }
.item.pending { opacity: .78; }

/* swipe-to-reveal actions */
.swipe { position: relative; overflow: hidden; touch-action: pan-y; }
.swipe .actions {
  position: absolute; inset: 0 0 0 auto; display: flex; z-index: 0;
}
.swipe .actions button {
  width: 76px; border: 0; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.swipe .actions .edit { background: var(--blue); }
.swipe .actions .del { background: var(--red); }
.swipe .item { z-index: 1; transition: transform var(--t) var(--ease); will-change: transform; }
.swipe.dragging .item { transition: none; }

/* ---------------------------------------------------------------- progress */
.bar { height: 8px; border-radius: 99px; background: var(--tile-3); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: inherit; background: var(--brand);
  transform-origin: left; animation: grow-x 900ms var(--ease) both;
}
.bar.green > i { background: var(--green-2); }
.bar.amber > i { background: var(--amber-2); }
.bar.red > i { background: var(--red-2); }
.ring { --p: 0; --c: var(--accent); width: 64px; height: 64px; border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--tile-3) 0); display: grid; place-items: center; }
.ring::after { content: attr(data-label); width: 48px; height: 48px; border-radius: 50%; background: var(--tile); display: grid; place-items: center; font-size: 13px; font-weight: 800; }

/* ---------------------------------------------------------------- sheet & overlays */
.backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 8, 20, 0.42);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity var(--t) var(--ease);
}
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-height: calc(100dvh - 40px - var(--safe-t)); display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  transform: translateY(105%);
  transition: transform 460ms var(--spring);
  padding-bottom: var(--safe-b);
  outline: none;
}
.sheet.show { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet .grab { padding: 10px 0 2px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet .grab::before { content: ""; width: 40px; height: 5px; border-radius: 99px; background: var(--line-2); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px var(--pad) 10px; }
.sheet-body { padding: 0 var(--pad) var(--pad); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px var(--pad) 14px; border-top: 1px solid var(--line); background: var(--bg); }

.toast-wrap {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 90;
  transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(92vw, 440px); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 16px; width: 100%;
  background: var(--ink); color: var(--tile); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-3);
  animation: toast-in 360ms var(--spring) both;
}
.toast.out { animation: toast-out 220ms var(--ease) forwards; }
.toast.error { background: var(--red); color: #fff; }
.toast.success .ic { color: var(--green-2); }
.toast .t-action { margin-left: auto; border: 0; background: transparent; color: var(--accent-2); font-weight: 800; min-height: 32px; }

.success-burst {
  position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; pointer-events: none;
}
.success-burst .disc {
  width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green-2); color: #fff; box-shadow: 0 20px 50px -10px color-mix(in srgb, var(--green-2) 70%, transparent);
  animation: burst 900ms var(--spring) both;
}
.success-burst svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 420ms 180ms var(--ease) forwards; }

/* app lock */
.lock {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px;
  animation: fade-in var(--t) var(--ease);
}
.pin-dots { display: flex; gap: 14px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); transition: background var(--t-fast), transform var(--t-fast) var(--spring); }
.pin-dots i.on { background: var(--brand); border-color: var(--brand); transform: scale(1.15); }
.pin-dots.shake { animation: shake 420ms var(--ease); }

/* ---------------------------------------------------------------- keypad (quick add) */
.amount-display {
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
  min-height: 72px; padding: 6px 0; font-weight: 800; letter-spacing: -0.03em;
}
.amount-display .cur { font-size: 28px; color: var(--muted); }
.amount-display .val { font-size: 52px; line-height: 1; font-variant-numeric: tabular-nums; transition: transform var(--t-fast) var(--spring); }
.amount-display .val.bump { transform: scale(1.05); }
.amount-display.expense .val { color: var(--red); }
.amount-display.income .val { color: var(--green); }
.amount-display.transfer .val { color: var(--blue); }
.amount-display .caret { width: 3px; height: 44px; align-self: center; background: var(--brand); border-radius: 2px; animation: blink 1s steps(1) infinite; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  min-height: 56px; border: 0; border-radius: 16px; background: var(--tile);
  font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums;
  display: grid; place-items: center; box-shadow: var(--shadow-1);
  transition: transform 90ms var(--ease), background 90ms;
}
.keypad button:active { transform: scale(.93); background: var(--tile-3); }
.keypad .k-save { grid-column: span 3; }

.cat-chip { --c: var(--accent); }
.cat-chip .ic { color: var(--c); }
.cat-chip.on { background: color-mix(in srgb, var(--c) 14%, var(--tile)); border-color: var(--c); color: var(--ink); }

.details-toggle { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; border: 0; background: none; color: var(--accent); font-weight: 700; }
.details-toggle .ic { transition: transform var(--t) var(--ease); }
.details-toggle.open .ic { transform: rotate(180deg); }
.collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-slow) var(--ease); }
.collapse.open { grid-template-rows: 1fr; }
.collapse > div { overflow: hidden; }

/* ---------------------------------------------------------------- skeleton & empty */
.skel {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--tile-3) 0%, var(--tile-2) 50%, var(--tile-3) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
.skel.tile { min-height: 110px; border-radius: var(--r-lg); box-shadow: none; }
.skel.line { height: 14px; margin: 6px 0; }
.skel.circle { border-radius: 50%; }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 36px 20px;
}
.empty svg.art { width: 150px; height: 120px; margin-bottom: 6px; }
.empty h3 { font-size: 17px; }
.empty p { color: var(--muted); max-width: 320px; font-size: 14px; }

/* pull to refresh */
.ptr {
  position: fixed; top: calc(var(--top-h) + var(--safe-t) + 6px); left: 50%; z-index: 29;
  width: 40px; height: 40px; margin-left: -20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--tile); color: var(--accent); box-shadow: var(--shadow-2);
  transform: translateY(-70px) scale(.6); opacity: 0; transition: transform var(--t) var(--ease), opacity var(--t);
}
.ptr.spinning .ic { animation: spin .8s linear infinite; }

/* ---------------------------------------------------------------- auth */
.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b));
  background:
    radial-gradient(60vmax 60vmax at 110% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%),
    radial-gradient(50vmax 50vmax at -20% 110%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 420px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 850; font-size: 22px; letter-spacing: -0.03em; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--black); display: grid; place-items: center; color: #fff; box-shadow: 0 10px 24px -12px rgba(0,0,0,.5); }
:root[data-theme="dark"] .brand-mark { background: var(--brand); }
.auth-bento { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0; }
.auth-bento .tile { padding: 14px; }

/* ---------------------------------------------------------------- page bits */
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.page-head h1 { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.chart-box { position: relative; width: 100%; }
.chart-box canvas { width: 100% !important; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.menu-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-height: 96px; border: 0; text-align: left; }
.menu-tile .tile-ic { --c: var(--accent); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.menu-tile .lbl { font-weight: 700; font-size: 14px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl td.n, table.tbl th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl tr.total td { font-weight: 800; border-bottom: 0; background: var(--tile-2); }
.inv-line { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--tile-2); position: relative; }
.inv-line .full { grid-column: 1 / -1; }
.inv-line .rm { position: absolute; top: 6px; right: 6px; }
.dropzone { border: 2px dashed var(--line-2); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs a, .thumbs .th { width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--tile-3); display: grid; place-items: center; position: relative; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.credit { margin: 20px 0 4px; text-align: center; font-size: 12px; color: var(--muted); }
.credit a { color: var(--ink); font-weight: 800; letter-spacing: .06em; }
.credit a:hover { color: var(--accent); }
.sidebar .credit { margin: 10px 8px 0; text-align: left; font-size: 11px; line-height: 1.5; }
.offline-banner { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--r); background: var(--tile-3); color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 12px; }

/* ---------------------------------------------------------------- motion */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.8); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes burst { 0% { transform: scale(.3); opacity: 0; } 35% { transform: scale(1.08); opacity: 1; } 70% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes view-in { from { opacity: 0; transform: translate3d(14px, 0, 0); } }
@keyframes view-back { from { opacity: 0; transform: translate3d(-14px, 0, 0); } }
@keyframes tile-in { from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.985); } }

.view-enter { animation: view-in 320ms var(--ease) both; }
.view-enter.back { animation-name: view-back; }
.bento > .tile, .stagger > * { animation: tile-in 480ms var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
  .skel { animation: none; }
}

/* ---------------------------------------------------------------- responsive */
@media (min-width: 600px) {
  .bento { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bento .span-2 { grid-column: span 2; }
  .bento .full, .bento .md-full { grid-column: 1 / -1; }
  .bento .md-span-1 { grid-column: span 1; }
  .bento .md-span-3 { grid-column: span 3; }
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
  .sheet { left: 50%; right: auto; width: 560px; margin-left: -280px; }
  .big { font-size: 34px; }
}

@media (min-width: 1024px) {
  :root { --pad: 20px; --gap: 14px; }
  body { font-size: 15px; }
  .app { display: grid; grid-template-columns: 252px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 0; height: 100dvh; padding: 18px 14px; overflow-y: auto;
    border-right: 1px solid var(--line); background: var(--tile);
  }
  .sidebar .brand { padding: 0 8px 12px; font-size: 20px; }
  .side-link {
    display: flex; align-items: center; gap: 12px; min-height: 38px; padding: 0 12px;
    border-radius: 12px; color: var(--ink-2); font-weight: 600; font-size: 14.5px;
    transition: background var(--t-fast), color var(--t-fast);
  }
  .side-link:hover { background: var(--tile-2); }
  .side-link.active { background: var(--accent-tint); color: var(--accent); }
  .side-sep { height: 1px; background: var(--line); margin: 6px 8px; }
  .sidebar .grow { min-height: 12px; }
  .side-link.red { color: var(--red); }
  .side-link.red:hover { background: var(--red-tint); }
  .side-new { margin-bottom: 8px; min-height: 44px; }
  .bottom-nav { display: none; }
  main.view { padding: 8px 28px 48px; }
  .topbar { padding: 0 28px; }
  .bento { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .bento .span-2 { grid-column: span 2; }
  .bento .lg-span-1 { grid-column: span 1; }
  .bento .lg-span-2 { grid-column: span 2; }
  .bento .lg-span-3 { grid-column: span 3; }
  .bento .lg-span-4 { grid-column: span 4; }
  .bento .lg-full, .bento .full { grid-column: 1 / -1; }
  .bento .lg-row-2 { grid-row: span 2; }
  .toast-wrap { bottom: 24px; }
  .menu-grid { grid-template-columns: repeat(6, 1fr); }
  .sheet { top: 50%; bottom: auto; border-radius: var(--r-xl); max-height: min(86vh, 860px); transform: translateY(-46%) scale(.96); opacity: 0;
           transition: transform 360ms var(--spring), opacity 200ms var(--ease); }
  .sheet.show { transform: translateY(-50%) scale(1); opacity: 1; }
  .sheet .grab { display: none; }
  .sheet-head { padding-top: 18px; }
  .ptr { display: none; }
  .split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
}

@media (hover: hover) {
  .btn:hover { filter: brightness(1.04); }
  .chip:hover { border-color: var(--line-2); }
  button.item:hover, a.item:hover { background: var(--tile-2); }
}
