  :root {
    color-scheme: light;
    --bg: #f4f4f1; --surface: #fcfcfb; --surface-2: #efeee9; --text: #0b0b0b; --text-2: #52514e; --muted: #6b6a64;
    --line: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11, 11, 11, .07);
    --accent: #6250d6; --accent-ink: #fff; --accent-soft: rgba(98, 80, 214, .16);
    --pos: #006300; --neg: #d03b3b; --warn: #8a5a00;
    --s-income: #1baf7a; --s-expense: #eb6834; --s-saving: #2a78d6; --s-ctx: #b5b3ab;
    --st-good: #0ca30c; --st-warn: #fab219; --st-bad: #d03b3b;
    --heat-0: #efeee9; --heat-1: #cde2fb; --heat-2: #9ec5f4; --heat-3: #5598e7; --heat-4: #256abf; --heat-5: #104281;
    --heat-ink: #fff; --heat-ink-5: #fff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .05);
    --hero: linear-gradient(135deg, #6250d6 0%, #2a78d6 100%);
    --radius: 20px;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #262624; --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
      --line: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, .07);
      --accent: #9085e9; --accent-ink: #0d0d0d; --accent-soft: rgba(144, 133, 233, .22);
      --pos: #0ca30c; --neg: #e66767; --warn: #fab219;
      --s-income: #199e70; --s-expense: #d95926; --s-saving: #3987e5; --s-ctx: #5a5955;
      --heat-0: #262624; --heat-1: #0d366b; --heat-2: #184f95; --heat-3: #256abf; --heat-4: #3987e5; --heat-5: #86b6ef;
      --heat-ink: #fff; --heat-ink-5: #0d0d0d;
      --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
      --hero: linear-gradient(135deg, #4a3aa7 0%, #1c5cab 100%);
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #262624; --text: #f0efec; --text-2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, .07);
    --accent: #9085e9; --accent-ink: #0d0d0d; --accent-soft: rgba(144, 133, 233, .22);
    --pos: #0ca30c; --neg: #e66767; --warn: #fab219;
    --s-income: #199e70; --s-expense: #d95926; --s-saving: #3987e5; --s-ctx: #5a5955;
    --heat-0: #262624; --heat-1: #0d366b; --heat-2: #184f95; --heat-3: #256abf; --heat-4: #3987e5; --heat-5: #86b6ef;
    --heat-ink: #fff; --heat-ink-5: #0d0d0d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    --hero: linear-gradient(135deg, #4a3aa7 0%, #1c5cab 100%);
  }

  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
         font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
  [hidden] { display: none !important; }
  button, input, select { font: inherit; color: inherit; }
  h2 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: -.005em; }
  p { margin: 0; }
  .s { font-size: 13px; color: var(--text-2); }
  .muted { color: var(--muted); }
  .pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }
  .spacer { flex: 1; }

  /* ---------- header ---------- */
  .top { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line);
         background: color-mix(in srgb, var(--bg) 82%, transparent);
         -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px); }
  .bar { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 8px; }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; margin-right: auto; letter-spacing: -.01em; }
  /* The logo is violet-blue itself, so it always sits on a white tile to stay visible on any background. */
  .logo { width: 34px; height: 34px; border-radius: 10px; background: #fff; display: grid; place-items: center; flex: none;
          box-shadow: 0 0 0 1px rgba(15, 23, 42, .08), 0 1px 3px rgba(15, 23, 42, .12); }
  .logo img { display: block; }
  .period { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2px; }
  .period .lbl { min-width: 128px; text-align: center; font-weight: 650; font-size: 14px; border: 0; background: none;
                 cursor: pointer; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
  .period .lbl:hover { background: var(--surface-2); }
  .icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: none; border-radius: 9px;
              cursor: pointer; color: var(--text-2); flex: none; transition: background .15s, color .15s; }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
  .seg button, .seg label { position: relative; border: 0; background: none; padding: 5px 11px; border-radius: 8px; cursor: pointer;
                            font-size: 13px; font-weight: 600; color: var(--text-2); transition: background .2s, color .2s, box-shadow .2s; white-space: nowrap; }
  .seg button.on, .seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
  .seg label input { position: absolute; opacity: 0; pointer-events: none; }
  .seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
  .seg.wide { display: flex; width: 100%; } .seg.wide label { flex: 1; text-align: center; }
  .nav { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto; position: relative; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { border: 0; background: none; padding: 8px 12px 11px; color: var(--text-2); font-weight: 600; font-size: 14px;
                cursor: pointer; white-space: nowrap; transition: color .2s; }
  .nav button:hover, .nav button.on { color: var(--text); }
  .ink { position: absolute; bottom: 0; left: 0; height: 3px; width: 0; border-radius: 3px 3px 0 0; background: var(--accent);
         transition: transform .4s cubic-bezier(.2, .8, .2, 1), width .4s cubic-bezier(.2, .8, .2, 1); }

  /* ---------- layout ---------- */
  main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 110px; display: grid; gap: 16px; }
  main.enter > * { animation: up .5s cubic-bezier(.2, .8, .2, 1) both; }
  main.enter > *:nth-child(2) { animation-delay: .04s; } main.enter > *:nth-child(3) { animation-delay: .08s; }
  main.enter > *:nth-child(4) { animation-delay: .12s; } main.enter > *:nth-child(n+5) { animation-delay: .16s; }
  @keyframes up { from { opacity: 0; transform: translateY(12px); } }
  .grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
  .card { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
  .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
  .row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

  /* hero */
  .hero { background: var(--hero); color: #fff; border: 0; position: relative; overflow: hidden; }
  .hero::before { content: ''; position: absolute; width: 380px; height: 380px; right: -120px; top: -180px; pointer-events: none;
                  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 62%); }
  .hero::after { content: ''; position: absolute; width: 260px; height: 260px; left: -90px; bottom: -160px; pointer-events: none;
                 background: radial-gradient(circle, rgba(255, 255, 255, .12), transparent 65%); }
  .hero > * { position: relative; }
  .hero .k { opacity: .88; font-size: 14px; font-weight: 500; }
  .hero-num { font-size: clamp(34px, 7vw, 50px); font-weight: 750; letter-spacing: -.025em; line-height: 1.1; margin: 4px 0 16px; }
  .hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
  .hero-stats > div { background: rgba(255, 255, 255, .13); border-radius: 14px; padding: 10px 12px; }
  .hero-stats span { font-size: 12px; opacity: .88; display: block; }
  .hero-stats b { font-size: 18px; font-weight: 700; display: block; }
  .delta { font-size: 12px; opacity: .9; }

  /* tiles */
  .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .tile { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; min-width: 0; }
  .tile span { font-size: 12px; color: var(--text-2); display: block; }
  .tile b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tile small { font-size: 12px; color: var(--muted); }

  /* rows */
  .row { display: flex; align-items: center; gap: 12px; padding: 9px 8px; margin: 0 -8px; border-radius: 12px; transition: background .15s; }
  .row[role=button] { cursor: pointer; }
  .row[role=button]:hover, .row[role=button]:focus-visible { background: var(--surface-2); }
  :where(button, [role=button], summary, a):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .row[role=button]:focus-visible { outline-offset: -2px; }
  .sw:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
  .ico { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 18px;
         background: color-mix(in srgb, var(--c, #898781) 18%, transparent); }
  .grow { flex: 1; min-width: 0; }
  .grow .t, .grow .s { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .amt { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
  .amt.income { color: var(--pos); }
  .amt small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
  .day-h { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; color: var(--muted);
           text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 2px; }
  .day-h:first-child { margin-top: 4px; }
  .tag { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); margin-left: 4px; }

  /* buttons */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink);
         border: 0; border-radius: 11px; padding: 9px 15px; font-weight: 600; cursor: pointer; white-space: nowrap;
         transition: transform .12s, filter .2s, background .2s; }
  .btn:hover { filter: brightness(1.08); } .btn:active { transform: scale(.97); }
  .btn.ghost { background: var(--surface-2); color: var(--text); }
  .btn.danger { background: transparent; color: var(--neg); box-shadow: inset 0 0 0 1px currentColor; }
  .btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
  .linkish { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; font-size: 13px; }

  /* inputs */
  input, select { background: var(--surface-2); border: 1px solid transparent; border-radius: 11px; padding: 9px 11px; width: 100%;
                  transition: border-color .2s, box-shadow .2s, background .2s; min-width: 0; }
  input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
  input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
  input[type=color] { padding: 0; border: 0; width: 30px; height: 30px; background: none; cursor: pointer; }
  label.f { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 14px 0 6px; }
  label.check { display: flex; gap: 10px; align-items: center; margin-top: 16px; cursor: pointer; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
  .hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
  .err { color: var(--neg); font-size: 13px; font-weight: 600; margin-top: 12px; }

  /* progress */
  .prog { display: block; position: relative; height: 8px; background: var(--surface-2); border-radius: 99px; margin-top: 8px; }
  .prog i { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); border-radius: 99px; animation: grow .9s cubic-bezier(.2, .8, .2, 1); }
  .prog b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; opacity: .5; }
  @keyframes grow { from { width: 0; } }
  .st { font-size: 12px; font-weight: 600; margin-top: 4px; display: block; }

  /* dialog */
  dialog { border: 0; padding: 0; border-radius: 22px; background: var(--surface); color: var(--text);
           width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 80px rgba(0, 0, 0, .35); }
  dialog[open] { animation: pop .3s cubic-bezier(.2, .9, .3, 1.15); }
  dialog::backdrop { background: rgba(10, 10, 10, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  @keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
  .dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 4px; }
  .dlg-head h2 { font-size: 18px; }
  .dlg-body { padding: 4px 20px 14px; }
  .dlg-foot { display: flex; gap: 8px; padding: 14px 20px 18px; position: sticky; bottom: 0; background: var(--surface);
              border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
  .amt-in { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 16px; padding: 4px 16px; margin-top: 14px;
            transition: box-shadow .2s; }
  .amt-in:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
  .amt-in span { font-size: 24px; color: var(--muted); font-weight: 650; }
  .amt-in input { font-size: 32px; font-weight: 750; background: none !important; border: 0; padding: 6px 0; box-shadow: none !important; letter-spacing: -.02em; }
  .amt-in small { color: var(--text-2); font-weight: 600; white-space: nowrap; }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 176px; overflow: auto; padding: 2px; }
  .chip { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--surface-2);
          cursor: pointer; font-size: 13px; border: 1px solid transparent; transition: background .15s, border-color .15s; user-select: none; }
  .chip input { position: absolute; opacity: 0; pointer-events: none; }
  .chip:hover { border-color: var(--line); }
  .chip:has(input:checked) { background: color-mix(in srgb, var(--c) 22%, var(--surface)); border-color: var(--c); font-weight: 650; }
  .chip:has(input:focus-visible) { outline: 2px solid var(--accent); }
  .emoji-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  .emoji-row input { width: 64px; text-align: center; font-size: 18px; padding: 6px; }
  .emo { border: 0; background: none; font-size: 19px; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; }
  .emo:hover { background: var(--surface-2); }
  .swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .sw { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--c); cursor: pointer; transition: transform .15s; }
  .sw input { position: absolute; opacity: 0; }
  .sw:hover { transform: scale(1.1); }
  .sw:has(input:checked) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }

  /* quick add */
  .qa { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; }
  .qa-in { font-size: 20px; padding: 18px 20px; border-radius: 0 !important; background: none !important; border: 0 !important;
           border-bottom: 1px solid var(--line) !important; box-shadow: none !important; }
  .qa-prev { padding: 14px 20px; display: flex; flex-wrap: wrap; gap: 6px; min-height: 58px; align-items: center; }
  .qa-help { padding: 0 20px 18px; font-size: 12px; color: var(--muted); line-height: 1.7; }
  .pill { padding: 4px 11px; border-radius: 99px; background: var(--surface-2); font-size: 13px; font-weight: 600; }
  .pill.big { background: var(--accent); color: var(--accent-ink); }
  .kb { font: 600 11px/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-2);
        border: 1px solid var(--line); white-space: nowrap; }
  .shake { animation: shake .35s; }
  @keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

  /* toasts & tooltip */
  #toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100;
            width: max-content; max-width: calc(100vw - 32px); }
  .toast { background: var(--text); color: var(--bg); padding: 10px 12px 10px 16px; border-radius: 14px; display: flex; align-items: center;
           gap: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); animation: tin .35s cubic-bezier(.2, .9, .3, 1.2); font-size: 14px; font-weight: 500; }
  .toast button { background: none; border: 0; color: inherit; font-weight: 750; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
  .toast button:hover { background: rgba(127, 127, 127, .25); }
  .toast.out { animation: tout .25s forwards; }
  @keyframes tin { from { opacity: 0; transform: translateY(16px) scale(.95); } }
  @keyframes tout { to { opacity: 0; transform: translateY(8px) scale(.97); } }
  #tip { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 200; background: var(--surface); color: var(--text);
         border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 11px; padding: 8px 11px; font-size: 12px;
         opacity: 0; transition: opacity .12s; min-width: 130px; max-width: 260px; }
  #tip.on { opacity: 1; }
  #tip b { display: block; font-size: 13px; margin-bottom: 3px; }
  #tip .tr { display: flex; align-items: center; gap: 14px; justify-content: space-between; color: var(--text-2); }
  #tip .tr span:last-child { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
  #tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

  .fab { position: fixed; right: 18px; bottom: 18px; width: 58px; height: 58px; border-radius: 19px; background: var(--hero); color: #fff;
         border: 0; box-shadow: 0 12px 30px rgba(74, 58, 167, .45); cursor: pointer; z-index: 30; display: none; place-items: center;
         transition: transform .25s cubic-bezier(.2, .9, .3, 1.3); }
  .fab:active { transform: scale(.92); }

  /* charts */
  svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
  .chart .grid { stroke: var(--line); stroke-width: 1; }
  .chart .base { stroke: var(--axis); stroke-width: 1; }
  .chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
  .chart .hit { fill: transparent; }
  .chart .col:hover .hit { fill: var(--ring); }
  .chart .xh { stroke: var(--axis); opacity: 0; }
  .chart .pt { opacity: 0; }
  .chart .col:hover .xh, .chart .col:hover .pt { opacity: 1; }
  .chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .chart .draw { stroke-dasharray: 1; animation: draw 1.2s cubic-bezier(.3, .7, .2, 1) both; }
  @keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
  .chart .barm { transform-box: fill-box; transform-origin: 50% 100%; animation: rise .7s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes rise { from { transform: scaleY(0); } }
  .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
  .legend span { display: inline-flex; align-items: center; gap: 6px; }
  .legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
  .legend i.dash { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed; }
  details.tv { margin-top: 10px; font-size: 13px; }
  details.tv summary { cursor: pointer; color: var(--text-2); font-weight: 600; }
  .donut { max-width: 210px; margin: 0 auto 6px; }
  .donut svg { display: block; width: 100%; animation: dn 1s cubic-bezier(.2, .8, .2, 1) both; transform-origin: 50% 50%; }
  @keyframes dn { from { opacity: 0; transform: rotate(-70deg) scale(.9); } }
  .donut .seg { transition: stroke-width .2s, opacity .2s; cursor: pointer; }
  .donut svg:hover .seg { opacity: .4; }
  .donut svg .seg:hover { opacity: 1; stroke-width: 27; }
  .donut .dn-l { fill: var(--text-2); font-size: 12px; }
  .donut .dn-v { fill: var(--text); font-size: 19px; font-weight: 750; }
  .hm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
  .hm-w { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; }
  .hm { aspect-ratio: 1; border: 0; border-radius: 9px; font-size: 11px; cursor: pointer; color: var(--text-2); background: var(--heat-0);
        transition: transform .15s; padding: 0; font-variant-numeric: tabular-nums; }
  .hm:hover:not(:disabled) { transform: scale(1.1); }
  .hm.l1 { background: var(--heat-1); } .hm.l2 { background: var(--heat-2); } .hm.l3 { background: var(--heat-3); color: var(--heat-ink); }
  .hm.l4 { background: var(--heat-4); color: var(--heat-ink); } .hm.l5 { background: var(--heat-5); color: var(--heat-ink-5); }
  .hm.today { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 750; }
  .hm:disabled { opacity: .35; cursor: default; }
  .hm-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: 11px; color: var(--muted); margin-top: 10px; }
  .hm-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; aspect-ratio: auto; }

  .filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 8px; }
  .filters .q { grid-column: 1 / -1; }
  .txsum { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin: 14px 0 4px; }
  .txsum b { color: var(--text); font-variant-numeric: tabular-nums; }
  .fchip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--text); border-radius: 99px;
           padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 600; margin-top: 10px; }
  .fchip button { border: 0; background: none; cursor: pointer; border-radius: 50%; width: 22px; height: 22px; }
  .more { text-align: center; padding: 16px; color: var(--muted); font-size: 13px; }
  .tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
  .tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
  .tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
  .tbl .r { text-align: right; }
  .tbl tr:last-child td { border-bottom: 0; }
  .empty { text-align: center; padding: 26px 12px; color: var(--text-2); }
  .empty .e-ico { font-size: 34px; display: block; margin-bottom: 6px; }
  .empty .btn { margin-top: 14px; }
  .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
  .set-row:first-of-type { border-top: 0; }
  .set-row > div:first-child { min-width: 0; } .set-row b { display: block; font-weight: 600; }
  .set-row select { width: auto; min-width: 180px; }
  .warnbox { background: color-mix(in srgb, var(--st-warn) 18%, var(--surface)); border-color: color-mix(in srgb, var(--st-warn) 50%, transparent); }
  .onboard { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .onboard h2 { font-size: 17px; margin-bottom: 4px; }
  .onboard > div:first-child { flex: 1 1 320px; }
  .setup-card { border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
  .su-alt { margin-top: 8px; }
  .su-alt .linkish { font-size: inherit; }

  /* first-run setup */
  .su-prog { list-style: none; padding: 0; margin: 4px 0 18px; display: flex; gap: 6px; }
  .su-prog li { flex: 1; font-size: 11px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
  .su-prog li::before { content: ''; height: 4px; border-radius: 99px; background: var(--surface-2); transition: background .3s; }
  .su-prog li.on, .su-prog li.done { color: var(--text); }
  .su-prog li.on::before, .su-prog li.done::before { background: var(--accent); }
  .su-prog li span { display: none; }
  .su-q { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 2px; }
  .su-amt { margin-top: 10px; }
  .su-amt input { font-size: 26px; }
  .su-emi { display: grid; grid-template-columns: 1.4fr 1.2fr .6fr .9fr auto; gap: 6px; margin-top: 10px; align-items: end; }
  .su-emi label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .su-emi small { font-size: 11px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .su-emi .icon-btn { margin-bottom: 4px; }
  .su-sum { background: var(--surface-2); border-radius: 14px; padding: 6px 14px; margin-top: 10px; }
  .su-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; border-top: 1px solid var(--line); }
  .su-line:first-child { border-top: 0; }
  .su-line b { font-variant-numeric: tabular-nums; font-weight: 600; }
  .su-line.total { font-weight: 700; } .su-line.total b { font-weight: 750; color: var(--pos); }
  .su-line.total.neg b { color: var(--neg); }
  .su-warn { margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 13px; background: color-mix(in srgb, var(--st-warn) 18%, var(--surface)); }
  .su-plan { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
  .su-plan label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
  #suTotal .neg { color: var(--neg); font-weight: 600; }
  .keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; font-size: 13px; }
  .keys div { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
  .tbl-wrap { overflow-x: auto; }
  .btn.glass { background: rgba(255, 255, 255, .18); color: #fff; }
  .mini-bar { display: block; height: 6px; border-radius: 99px; background: var(--s-expense); margin-top: 5px; animation: grow .9s cubic-bezier(.2, .8, .2, 1); }

  @media (max-width: 760px) {
    .brand .name, .new-btn, .theme-btn { display: none; }
    .fab { display: grid; }
    .filters { grid-template-columns: 1fr 1fr; }
  }
  @media (max-width: 520px) {
    .period .lbl { min-width: 92px; font-size: 13px; }
    .seg.mode button { padding: 5px 9px; }
    .seg.mode .full { display: none; }
    .bar { gap: 6px; }
    .two { grid-template-columns: 1fr; }
    .su-emi { grid-template-columns: 1fr 1fr auto; }
    .su-emi { grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--line); padding-bottom: 12px; }
    .su-emi label:first-child { grid-column: 1 / 3; grid-row: 1; }
    .su-emi .icon-btn { grid-column: 3; grid-row: 1; justify-self: end; }
    .card { padding: 16px; }
    dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; max-height: 92vh; }
    dialog[open] { animation: sheet .35s cubic-bezier(.2, .9, .3, 1); }
    .qa { margin: 0 auto auto; border-radius: 0 0 22px 22px; }
    .qa[open] { animation: pop .3s; }
  }
  @keyframes sheet { from { transform: translateY(100%); } }
  .every-wrap { display: flex; align-items: center; gap: 8px; }
  .every-wrap input { width: 90px; }
  #recWarn { color: var(--warn); font-weight: 600; }
  #recSummary { color: var(--text); font-weight: 600; }

  /* account, sync state, loading */
  .who-wrap { display: flex; align-items: center; gap: 4px; margin-left: 4px; }
  .who { border: 0; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 13px; padding: 6px 11px; border-radius: 99px;
         cursor: pointer; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who:hover { background: var(--line); }
  .sync { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; padding: 0 4px; }
  .sync[data-state=saved] { color: var(--pos); }
  .sync[data-state=offline], .sync[data-state=error] { color: var(--neg); }
  .pw-form { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
  .three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
  .pw-wrap { position: relative; display: block; }
  .pw-wrap input { padding-right: 62px; }
  .pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--accent);
               font-weight: 650; font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
  .loading { display: flex; align-items: center; gap: 12px; color: var(--text-2); }
  .spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @media (max-width: 760px) {
    .who { display: none; }
    .three { grid-template-columns: 1fr; }
    /* On small screens the sync state is a dot; the full text stays available to screen readers. */
    .sync { font-size: 0; width: 10px; height: 10px; padding: 0; border-radius: 50%; background: var(--warn); }
    .sync[data-state=saved] { background: var(--st-good); }
    .sync[data-state=offline], .sync[data-state=error] { background: var(--st-bad); }
  }
  @media (max-width: 520px) { .who-wrap .icon-btn { display: none; } }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  }
