    *,
    *::before,
    *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0
    }

    /* ═══════════════════════════════════════════════════════════════════════════
   LEDGER — Dual E-ink Theme System
   ───────────────────────────────────────────────────────────────────────────
   GRAYSCALE MODE (default / [data-theme="gray"])
     Pure black/white/gray — optimized for traditional e-ink (Carta, etc.)
     Semantic meaning conveyed via weight, border-style, fill — never hue.

   COLOR MODE ([data-theme="color"])
     Kaleido 3 color e-ink palette:
     • Bold, high-chroma primaries at near-full saturation
     • White / near-white backgrounds only (Kaleido struggles with dark fills)
     • No gradients — flat fills only
     • Colors still paired with weight/border cues for accessibility
     • ~60% sRGB gamut target; avoid pastels, midtone muds, and neons

   Touch targets: ≥44×44px (Apple HIG / WCAG 2.5.5)
   ═══════════════════════════════════════════════════════════════════════════ */

    /* ── GRAYSCALE (default) ──────────────────────────────────────────────────── */
    :root,
    [data-theme="gray"] {
      --bg: #ffffff;
      --sf: #ffffff;
      --sf2: #f2f2f2;
      --sf3: #e0e0e0;
      --b1: rgba(0, 0, 0, .15);
      --b2: rgba(0, 0, 0, .35);
      --tx: #000000;
      --tx2: #333333;
      --tx3: #666666;
      --g: #000000;
      --g2: #222222;
      --gbg: #e8e8e8;
      --gtx: #000000;
      --r: #000000;
      --rbg: #ececec;
      --rtx: #000000;
      --bl: #000000;
      --blbg: #e8e8e8;
      --bltx: #000000;
      --am: #444444;
      --ambg: #ebebeb;
      --amtx: #000000;
      --pu: #333333;
      --pubg: #e8e8e8;
      --putx: #000000;
      --ra: 8px;
      --rsm: 5px;
      --touch: 44px;
      /* theme-mode indicator */
      --theme-accent: #000000;
      --theme-accent-bg: #f2f2f2;
    }

    /* ── COLOR E-INK (Kaleido 3) ──────────────────────────────────────────────── */
    /* Design rules for Kaleido 3:
   - Always white/near-white backgrounds (color filter array on white substrate)
   - Saturated primaries: forest green, crimson, royal blue, deep amber, violet
   - Avoid: pastels (too light), dark fills (poor color rendering)
   - 1.5–2px borders to compensate for lower contrast vs LCD
   - Text always near-black for legibility                                    */
    [data-theme="color"] {
      --bg: #fafafa;
      --sf: #ffffff;
      --sf2: #f5f5f0;
      --sf3: #ebebdf;
      --b1: rgba(0, 0, 0, .12);
      --b2: rgba(0, 0, 0, .30);
      --tx: #111111;
      --tx2: #444444;
      --tx3: #737373;
      /* Green: bold forest — income, positive, assets */
      --g: #1a7a3c;
      --g2: #22a050;
      --gbg: #e6f5ec;
      --gtx: #0d4a22;
      /* Red: vivid crimson — expenses, negative, debt */
      --r: #c0282a;
      --rbg: #fce8e8;
      --rtx: #7a1010;
      /* Blue: royal — informational, investment */
      --bl: #1452b0;
      --blbg: #e0eafc;
      --bltx: #0b2d6b;
      /* Amber: deep gold — warnings, neutral flags */
      --am: #b56a00;
      --ambg: #fef0d0;
      --amtx: #6b3e00;
      /* Purple: violet — goals, savings */
      --pu: #5c35b0;
      --pubg: #ede8fb;
      --putx: #2e1270;
      --ra: 8px;
      --rsm: 5px;
      --touch: 44px;
      --theme-accent: #1a7a3c;
      --theme-accent-bg: #e6f5ec;
    }

    /* ── DARK COLOR MODE ([data-theme="dark"]) ───────────────────────────────────── */
    /* Full dark background with vivid color accents — LCD/OLED optimized.
       Retains full color semantics (green/red/blue/amber/purple) against dark canvas. */
    [data-theme="dark"] {
      --bg: #0b0e18;
      --sf: #161b2a;
      --sf2: #1c2235;
      --sf3: #232b40;
      --b1: rgba(255, 255, 255, .12);
      --b2: rgba(255, 255, 255, .30);
      --tx: #e8eaf0;
      --tx2: #a8afc4;
      --tx3: #8b90a8;
      /* Green: bright emerald — income, positive, assets */
      --g: #2dd078;
      --g2: #4ae090;
      --gbg: #0d2b1e;
      --gtx: #7effc0;
      /* Red: vivid coral-red — expenses, negative, debt */
      --r: #f04a4a;
      --rbg: #2e0f0f;
      --rtx: #ff9090;
      /* Blue: electric blue — informational, investment */
      --bl: #4d9dff;
      --blbg: #0b1e3d;
      --bltx: #a0c8ff;
      /* Amber: warm gold — warnings, neutral flags */
      --am: #f0a830;
      --ambg: #2b1e08;
      --amtx: #ffd080;
      /* Purple: vivid violet — goals, savings */
      --pu: #9b6eff;
      --pubg: #1c1040;
      --putx: #d0b0ff;
      --ra: 8px;
      --rsm: 5px;
      --touch: 44px;
      --theme-accent: #2dd078;
      --theme-accent-bg: #0d2b1e;
    }

    /* ── DARK GRAYSCALE (system dark + gray theme) ─────────────────────────────── */
    @media(prefers-color-scheme:dark) {

      :root:not([data-theme="color"]):not([data-theme="dark"]):not([data-theme="gray"]) {
        --bg: #000000;
        --sf: #0a0a0a;
        --sf2: #111111;
        --sf3: #1e1e1e;
        --b1: rgba(255, 255, 255, .15);
        --b2: rgba(255, 255, 255, .40);
        --tx: #ffffff;
        --tx2: #cccccc;
        --tx3: #888888;
        --g: #ffffff;
        --g2: #dddddd;
        --gbg: #1a1a1a;
        --gtx: #ffffff;
        --r: #ffffff;
        --rbg: #1a1a1a;
        --rtx: #ffffff;
        --bl: #ffffff;
        --blbg: #1a1a1a;
        --bltx: #ffffff;
        --am: #cccccc;
        --ambg: #1a1a1a;
        --amtx: #ffffff;
        --pu: #cccccc;
        --pubg: #1a1a1a;
        --putx: #ffffff;
        --theme-accent: #ffffff;
        --theme-accent-bg: #1a1a1a;
      }
    }

    /* ── GRAYSCALE-mode badge overrides ────────────────────────────────────────── */
    /* In gray mode badges use fill/outline/dash — restore color semantics in color mode */
    html[data-theme="color"] .bg {
      background: var(--gbg);
      color: var(--gtx);
      border-color: var(--g)
    }

    html[data-theme="color"] .br {
      background: var(--rbg);
      color: var(--rtx);
      border-color: var(--r)
    }

    html[data-theme="color"] .bb {
      background: var(--blbg);
      color: var(--bltx);
      border-color: var(--bl)
    }

    html[data-theme="color"] .ba {
      background: var(--ambg);
      color: var(--amtx);
      border-color: var(--am);
      border-style: solid
    }

    html[data-theme="color"] .bp {
      background: var(--pubg);
      color: var(--putx);
      border-color: var(--pu)
    }

    html[data-theme="color"] .bgr {
      background: var(--sf3);
      color: var(--tx2);
      border-color: var(--b1)
    }

    /* In color mode: nav active, pill active, btn.pri use accent green */
    html[data-theme="color"] .nb.on {
      background: var(--g);
      color: #fff;
      border-color: var(--g)
    }

    html[data-theme="color"] .pill.on {
      background: var(--g);
      color: #fff;
      border-color: var(--g)
    }

    html[data-theme="color"] .acc-cat-pill.on {
      background: var(--g);
      color: #fff;
      border-color: var(--g)
    }

    html[data-theme="color"] .btn.pri {
      background: var(--g);
      color: #fff;
      border-color: var(--g)
    }

    html[data-theme="color"] .btn.pri:hover {
      background: var(--g2);
      border-color: var(--g2)
    }

    html[data-theme="color"] .btn.dan {
      color: var(--r);
      border-color: var(--r);
      border-style: solid
    }

    html[data-theme="color"] .btn.dan:hover {
      background: var(--rbg)
    }

    html[data-theme="color"] input:focus,
    html[data-theme="color"] select:focus {
      border-color: var(--g)
    }

    html[data-theme="color"] .tog.on {
      background: var(--g);
      border-color: var(--g)
    }

    html[data-theme="color"] .acc-hist-range button.on {
      background: var(--g);
      color: #fff;
      border-color: var(--g)
    }

    [data-theme="color"] .ok-box {
      background: var(--gbg);
      border-color: var(--g);
      color: var(--gtx)
    }

    [data-theme="color"] .warn-box {
      background: var(--ambg);
      border-color: var(--am);
      color: var(--amtx)
    }

    [data-theme="color"] .err-box {
      background: var(--rbg);
      border-color: var(--r);
      color: var(--rtx);
      border-style: solid
    }

    [data-theme="color"] .pf {
      background: var(--g)
    }

    [data-theme="color"] .pf.r {
      background: var(--r)
    }

    [data-theme="color"] .pf.b {
      background: var(--bl)
    }

    [data-theme="color"] .pf.p {
      background: var(--pu)
    }

    [data-theme="color"] .hist-dot {
      background: var(--g)
    }

    [data-theme="color"] .tld {
      background: var(--g);
      border-color: var(--g)
    }

    [data-theme="color"] .tld.r {
      background: var(--sf);
      border-color: var(--r)
    }

    [data-theme="color"] .tx-acc-link:hover {
      color: var(--g2) !important
    }

    [data-theme="color"] .tx-desc-link:hover {
      color: var(--g)
    }

    [data-theme="color"] .inc-row.total strong {
      color: var(--g)
    }

    [data-theme="color"] .bkt-total-row {
      color: var(--tx)
    }

    [data-theme="color"] .agh .line {
      background: var(--b2)
    }

    [data-theme="color"] .ac:hover {
      border-color: var(--g)
    }

    /* Restore semantic text colors in color mode */
    [data-theme="color"] .mv.g {
      color: var(--g)
    }

    [data-theme="color"] .mv.r {
      color: var(--r)
    }

    [data-theme="color"] .mv.b {
      color: var(--bl)
    }

    [data-theme="color"] .mv.a {
      color: var(--am)
    }

    [data-theme="color"] .abal.pos {
      color: var(--g)
    }

    [data-theme="color"] .abal.neg {
      color: var(--r)
    }

    [data-theme="color"] .abal.am {
      color: var(--am)
    }

    [data-theme="color"] .mbr .vg {
      color: var(--g)
    }

    [data-theme="color"] .mbr .vr {
      color: var(--r)
    }

    [data-theme="color"] .gsv.g {
      color: var(--g)
    }

    [data-theme="color"] .gsv.r {
      color: var(--r)
    }

    [data-theme="color"] .logo {
      color: var(--g)
    }

    [data-theme="color"] .hdr {
      border-bottom-color: var(--b2)
    }

    [data-theme="color"] .nb.on {
      box-shadow: 0 1px 3px rgba(0, 0, 0, .12)
    }

    /* ── DARK COLOR MODE badge/component overrides ──────────────────────────────── */
    html[data-theme="dark"] .bg {
      background: var(--gbg);
      color: var(--gtx);
      border-color: var(--g)
    }

    html[data-theme="dark"] .br {
      background: var(--rbg);
      color: var(--rtx);
      border-color: var(--r)
    }

    html[data-theme="dark"] .bb {
      background: var(--blbg);
      color: var(--bltx);
      border-color: var(--bl)
    }

    html[data-theme="dark"] .ba {
      background: var(--ambg);
      color: var(--amtx);
      border-color: var(--am);
      border-style: solid
    }

    html[data-theme="dark"] .bp {
      background: var(--pubg);
      color: var(--putx);
      border-color: var(--pu)
    }

    html[data-theme="dark"] .bgr {
      background: var(--sf3);
      color: var(--tx2);
      border-color: var(--b1)
    }

    html[data-theme="dark"] .nb.on {
      background: var(--g);
      color: #0f1117;
      border-color: var(--g);
      box-shadow: 0 1px 3px rgba(0, 0, 0, .4)
    }

    html[data-theme="dark"] .pill.on {
      background: var(--g);
      color: #0f1117;
      border-color: var(--g)
    }

    html[data-theme="dark"] .acc-cat-pill.on {
      background: var(--g);
      color: #0f1117;
      border-color: var(--g)
    }

    html[data-theme="dark"] .btn.pri {
      background: var(--g);
      color: #0f1117;
      border-color: var(--g)
    }

    html[data-theme="dark"] .btn.pri:hover {
      background: var(--g2);
      border-color: var(--g2)
    }

    html[data-theme="dark"] .btn.dan {
      color: var(--r);
      border-color: var(--r);
      border-style: solid
    }

    html[data-theme="dark"] .btn.dan:hover {
      background: var(--rbg)
    }

    html[data-theme="dark"] input:focus,
    html[data-theme="dark"] select:focus {
      border-color: var(--g)
    }

    html[data-theme="dark"] .tog.on {
      background: var(--g);
      border-color: var(--g)
    }

    html[data-theme="dark"] .acc-hist-range button.on {
      background: var(--g);
      color: #0f1117;
      border-color: var(--g)
    }

    [data-theme="dark"] .ok-box {
      background: var(--gbg);
      border-color: var(--g);
      color: var(--gtx)
    }

    [data-theme="dark"] .warn-box {
      background: var(--ambg);
      border-color: var(--am);
      color: var(--amtx)
    }

    [data-theme="dark"] .err-box {
      background: var(--rbg);
      border-color: var(--r);
      color: var(--rtx);
      border-style: solid
    }

    [data-theme="dark"] .pf { background: var(--g) }
    [data-theme="dark"] .pf.r { background: var(--r) }
    [data-theme="dark"] .pf.b { background: var(--bl) }
    [data-theme="dark"] .pf.p { background: var(--pu) }

    [data-theme="dark"] .hist-dot { background: var(--g) }

    [data-theme="dark"] .tld {
      background: var(--g);
      border-color: var(--g)
    }

    [data-theme="dark"] .tld.r {
      background: var(--sf);
      border-color: var(--r)
    }

    [data-theme="dark"] .tx-acc-link:hover { color: var(--g2) !important }
    [data-theme="dark"] .tx-desc-link:hover { color: var(--g) }

    [data-theme="dark"] .inc-row.total strong { color: var(--g) }
    [data-theme="dark"] .bkt-total-row { color: var(--tx) }
    [data-theme="dark"] .agh .line { background: var(--b2) }
    [data-theme="dark"] .ac:hover { border-color: var(--g) }

    [data-theme="dark"] .mv.g { color: var(--g) }
    [data-theme="dark"] .mv.r { color: var(--r) }
    [data-theme="dark"] .mv.b { color: var(--bl) }
    [data-theme="dark"] .mv.a { color: var(--am) }

    [data-theme="dark"] .abal.pos { color: var(--g) }
    [data-theme="dark"] .abal.neg { color: var(--r) }
    [data-theme="dark"] .abal.am  { color: var(--am) }

    [data-theme="dark"] .mbr .vg { color: var(--g) }
    [data-theme="dark"] .mbr .vr { color: var(--r) }
    [data-theme="dark"] .gsv.g { color: var(--g) }
    [data-theme="dark"] .gsv.r { color: var(--r) }

    [data-theme="dark"] .logo { color: var(--g) }
    [data-theme="dark"] .hdr { border-bottom-color: var(--b2) }

    /* ── Display Mode selector ───────────────────────────────────────────────────── */
    .theme-mode-group {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-top: 8px;
    }

    .theme-mode-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 6px;
      border: 1.5px solid var(--b2);
      background: var(--sf2);
      color: var(--tx2);
      padding: 10px 8px;
      border-radius: var(--ra);
      cursor: pointer;
      font-size: 11px;
      font-weight: 600;
      font-family: inherit;
      transition: background .15s, border-color .15s, color .15s;
      white-space: nowrap;
      letter-spacing: .03em;
      text-transform: uppercase;
      line-height: 1;
    }

    .theme-mode-btn:hover {
      background: var(--sf3);
      border-color: var(--tx3);
      color: var(--tx);
    }

    .theme-mode-btn.on {
      border-color: var(--tx);
      background: var(--sf3);
      color: var(--tx);
    }

    [data-theme="color"] .theme-mode-btn.on {
      border-color: var(--g);
      background: var(--gbg);
      color: var(--gtx);
    }

    [data-theme="dark"] .theme-mode-btn.on {
      border-color: var(--g);
      background: var(--gbg);
      color: var(--gtx);
    }

    .theme-mode-swatch {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      border: none;
      flex-shrink: 0;
      overflow: hidden;
    }

    .tms-gray  { background: linear-gradient(135deg, #1a1a1a 50%, #f0f0f0 50%) }
    .tms-color { background: conic-gradient(#1a7a3c 0deg 120deg, #c0282a 120deg 240deg, #1452b0 240deg 360deg) }
    .tms-dark  { background: radial-gradient(circle at 40% 40%, #2dd078 0%, #0f1117 55%) }

    body {
      font-family: system-ui, -apple-system, sans-serif;
      background: var(--bg);
      color: var(--tx);
      font-size: 15px;
      line-height: 1.55;
      min-height: 100vh;
      overflow-y: scroll
    }

    /* Header */
    .hdr {
      background: var(--sf);
      border-bottom: 1.5px solid var(--tx)
    }

    .hdr-inner {
      max-width: 1100px;
      margin: 0 auto;
      padding: 8px 22px;
      display: flex;
      flex-direction: column;
      gap: 8px
    }

    /* Wide breakpoint: logo left, nav right as 4×2 grid */
    @media(min-width:901px) {
      .hdr-inner {
        flex-direction: row;
        align-items: center;
        gap: 20px
      }
    }

    .logo {
      display: flex;
      align-items: center;
      gap: 20px;
      flex-shrink: 0;
      text-decoration: none;
      user-select: none
    }

    .logo-mark {
      flex-shrink: 0;
      width: 100px;
      height: 76px;
      overflow: visible
    }

    .logo-text {
      display: flex;
      flex-direction: column;
      gap: 1px
    }

    .logo-name {
      font-size: 19px;
      font-weight: 700;
      color: var(--tx);
      letter-spacing: -.02em;
      line-height: 1
    }

    .logo-sub {
      font-size: 10px;
      font-weight: 400;
      color: var(--tx2);
      letter-spacing: .08em;
      line-height: 1;
      text-transform: uppercase
    }

    /* Nav grid — uniform cells, no orphan wrapping */
    .nav {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      gap: 2px;
      background: var(--sf2);
      border-radius: var(--ra);
      padding: 3px
    }

    /* Wide: 4 columns × 2 rows beside the logo */
    @media(min-width:901px) {
      .nav {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(2, 1fr);
        flex: 1
      }
    }

    /* Nav buttons — min 44px tall for touch */
    .nb {
      border: none;
      background: transparent;
      padding: 0 10px;
      min-height: 44px;
      border-radius: var(--rsm);
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      color: var(--tx2);
      font-family: inherit;
      transition: all .15s;
      white-space: nowrap;
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      width: 100%
    }

    .nb.on {
      background: var(--tx);
      color: var(--bg);
      font-weight: 700
    }

    .nb:hover:not(.on) {
      background: var(--sf3);
      color: var(--tx)
    }

    @media(max-width:600px) {
      .nav {
        grid-template-columns: repeat(3, 1fr)
      }

      .nb {
        font-size: 12px;
        min-height: 40px
      }
    }

    .mn {
      padding: 18px 22px;
      max-width: 1100px;
      margin: 0 auto;
      overflow-x: hidden
    }

    .stitle {
      font-size: 18px;
      font-weight: 700;
      margin-bottom: 14px;
      letter-spacing: -.02em
    }

    .card {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 16px 20px
    }

    .mg {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
      gap: 8px;
      margin-bottom: 16px
    }

    .met {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 13px 15px;
      border: 1px solid var(--b1)
    }

    .ml {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: .08em;
      color: var(--tx2);
      margin-bottom: 3px;
      font-weight: 600
    }

    .mv {
      font-size: 22px;
      font-weight: 700
    }

    /* E-ink semantic: use underline/weight differentiation, not hue */
    .mv.g {
      color: var(--tx)
    }

    .mv.r {
      color: var(--tx)
    }

    .mv.b {
      color: var(--tx)
    }

    .mv.a {
      color: var(--tx2)
    }

    .ms {
      font-size: 11px;
      color: var(--tx3);
      margin-top: 2px
    }

    .g2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px
    }

    .g2>* {
      min-width: 0
    }

    .fr {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 9px
    }

    .fr>* {
      min-width: 0
    }

    @media(max-width:800px) {
      .g2 {
        grid-template-columns: 1fr
      }

      .mn {
        padding: 12px
      }

      .ac {
        min-width: 0;
        overflow: hidden
      }
    }

    body {
      overflow-x: hidden
    }

    @media(max-width:600px) {
      .fr {
        grid-template-columns: 1fr
      }
    }

    /* Buttons — 44px min-height for touch compliance */
    .btn {
      border: 1.5px solid var(--b2);
      background: transparent;
      color: var(--tx);
      padding: 0 16px;
      min-height: 44px;
      border-radius: var(--rsm);
      cursor: pointer;
      font-size: 14px;
      font-weight: 500;
      font-family: inherit;
      transition: all .15s;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      white-space: nowrap
    }

    .btn:hover {
      background: var(--sf2)
    }

    .btn.pri {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx)
    }

    .btn.pri:hover {
      background: var(--tx2);
      border-color: var(--tx2)
    }

    .btn.dan {
      color: var(--tx);
      border-color: var(--tx);
      border-style: dashed
    }

    .btn.dan:hover {
      background: var(--sf2)
    }

    /* Active state for compact range/mode toggle buttons */
    .btn.on {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx)
    }

    [data-theme="color"] .btn.on {
      background: var(--g);
      color: #fff;
      border-color: var(--g)
    }

    [data-theme="dark"] .btn.on {
      background: var(--g);
      color: #0f1117;
      border-color: var(--g)
    }

        /* sm/xs: still touch-friendly, just narrower padding */
    .btn.sm {
      padding: 0 12px;
      min-height: 36px;
      font-size: 13px
    }

    .btn.xs {
      padding: 0 9px;
      min-height: 32px;
      font-size: 12px
    }

    /* Inputs — 44px min-height for touch */
    input,
    select {
      width: 100%;
      padding: 0 12px;
      min-height: 44px;
      border: 1.5px solid var(--b2);
      border-radius: var(--rsm);
      background: var(--sf);
      color: var(--tx);
      font-size: 14px;
      font-family: inherit;
      outline: none;
      transition: border .15s
    }

    input:focus,
    select:focus {
      border-color: var(--tx);
      border-width: 2px
    }

    input[type=checkbox] {
      width: 20px;
      height: 20px;
      min-height: 20px;
      accent-color: var(--tx);
      cursor: pointer
    }

    input[type=range] {
      min-height: 32px
    }

    input[type=number] {
      -moz-appearance: textfield
    }

    input[type=number]::-webkit-outer-spin-button,
    input[type=number]::-webkit-inner-spin-button {
      -webkit-appearance: none
    }

    label {
      display: block;
      font-size: 12px;
      color: var(--tx2);
      margin-bottom: 4px;
      margin-top: 12px;
      font-weight: 600;
      letter-spacing: .03em;
      text-transform: uppercase
    }

    label:first-child {
      margin-top: 0
    }

    /* Tables — larger row heights for touch-friendly tap areas */
    .tbl-wrap {
      overflow-x: auto
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
      min-width: 480px
    }

    th {
      text-align: left;
      padding: 10px 12px;
      color: var(--tx);
      font-weight: 700;
      border-bottom: 2px solid var(--tx);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: .07em;
      white-space: nowrap
    }

    td {
      padding: 11px 12px;
      border-bottom: 1px solid var(--b1);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 180px
    }

    tr:last-child td {
      border-bottom: none
    }

    tr:hover td {
      background: var(--sf2)
    }

    /* Badges — use borders + weight instead of color fills */
    .badge {
      display: inline-block;
      padding: 3px 8px;
      border-radius: 4px;
      font-size: 11px;
      font-weight: 700;
      border: 1.5px solid var(--tx);
      background: transparent;
      color: var(--tx)
    }

    /* Semantic badge variants: use pattern/weight differentiation */
    .bg {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx)
    }

    /* positive/income: filled black */
    .br {
      background: transparent;
      color: var(--tx);
      border-color: var(--tx)
    }

    /* negative/expense: outline */
    .bb {
      background: var(--sf2);
      color: var(--tx);
      border-color: var(--b2)
    }

    /* neutral: gray fill */
    .ba {
      background: var(--sf3);
      color: var(--tx);
      border-color: var(--tx2);
      border-style: dashed
    }

    /* warning: dashed */
    .bp {
      background: transparent;
      color: var(--tx2);
      border-color: var(--tx2)
    }

    /* secondary */
    .bgr {
      background: var(--sf3);
      color: var(--tx2);
      border-color: var(--b1)
    }

    /* Progress bars */
    .pb {
      background: var(--sf3);
      border-radius: 3px;
      height: 6px;
      overflow: hidden;
      border: 1px solid var(--b1)
    }

    .pf {
      height: 100%;
      border-radius: 3px;
      background: var(--tx);
      transition: width .3s
    }

    .pf.r {
      background: var(--tx2)
    }

    .pf.b {
      background: var(--tx3)
    }

    /* Pills — 44px min-height for touch */
    .pills {
      display: flex;
      gap: 5px;
      flex-wrap: wrap;
      margin-bottom: 12px
    }

    .pill {
      padding: 0 16px;
      min-height: 44px;
      border-radius: 22px;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      border: 1.5px solid var(--b2);
      background: transparent;
      color: var(--tx2);
      font-family: inherit;
      transition: all .15s;
      display: inline-flex;
      align-items: center
    }

    .pill.on {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx)
    }

    .row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap
    }

    .sp {
      flex: 1
    }

    .empty {
      text-align: center;
      padding: 36px 20px;
      color: var(--tx3);
      font-size: 13px;
      line-height: 2
    }

    .chart-empty {
      position: absolute;
      inset: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      color: var(--tx3);
      font-size: 12px;
      line-height: 1.6;
      text-align: center;
      padding: 16px;
      pointer-events: none;
    }

    .chart-empty .ce-icon {
      font-size: 22px;
      opacity: .5;
      margin-bottom: 2px;
    }

    .chart-empty strong {
      color: var(--tx2);
      font-weight: 600;
      pointer-events: auto;
    }

    .dv {
      border: none;
      border-top: 1px solid var(--b2);
      margin: 14px 0
    }

    .upd {
      font-size: 11px;
      color: var(--tx3);
      margin-top: 2px
    }

    .snote {
      font-size: 12px;
      color: var(--tx2);
      margin-bottom: 14px;
      margin-top: -8px;
      line-height: 1.7
    }

    .agh {
      font-size: 11px;
      font-weight: 700;
      color: var(--tx2);
      text-transform: uppercase;
      letter-spacing: .08em;
      margin: 18px 0 8px;
      display: flex;
      align-items: center;
      gap: 9px
    }

    .agh .line {
      flex: 1;
      height: 1px;
      background: var(--b2)
    }

    /* Account list */
    #accList {
      column-count: 2;
      column-gap: 12px;
    }

    #accList .agh {
      column-span: all;
      display: block;
    }

    #accList .ac {
      break-inside: avoid;
    }

    @media(max-width:800px) {
      #accList {
        column-count: 1
      }
      #accList .ac.ac-wide { column-span: none }
    }

    .ac {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 14px 16px;
      margin-bottom: 8px;

      display: flex;
      align-items: flex-start;
      gap: 12px;
      flex-wrap: wrap
    }

    .ac:hover {
      border-color: var(--tx)
    }

    /* Icon */
    .ai {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      flex-shrink: 0;
      font-weight: 800;
      border: 2px solid var(--tx);
      background: var(--sf2)
    }

    /* Main info block */
    .ainfo {
      flex: 1;
      min-width: 0
    }

    .aname {
      font-weight: 700;
      font-size: 14px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: flex;
      align-items: center;
      gap: 4px
    }

    .asub {
      font-size: 12px;
      color: var(--tx2);
      margin-top: 2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    /* Balance + buttons */
    .aright {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      flex-shrink: 0;
      margin-left: auto;
      min-width: 0;
      max-width: 50%
    }

    .aval {
      text-align: right
    }

    .abal {
      font-size: 17px;
      font-weight: 700;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .abal.pos {
      color: var(--tx)
    }

    .abal.neg {
      color: var(--tx)
    }

    .abal.am {
      color: var(--tx2)
    }

    .abtns {
      display: flex;
      flex-direction: column;
      gap: 5px;
      flex-shrink: 0;
      align-items: flex-end
    }

    .mbd {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 11px 14px;
      margin-top: 8px;
      font-size: 13px;
      border: 1px solid var(--b1)
    }

    .ac-full {
      width: 100%;
      min-width: 0
    }

    .mbr {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 8px;
      padding: 4px 0;
      color: var(--tx2)
    }

    .mbr span:first-child {
      flex: 1;
      min-width: 0;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .mbr .v {
      font-weight: 600;
      color: var(--tx);
      flex-shrink: 0;
      white-space: nowrap
    }

    .mbr .vg {
      font-weight: 700;
      color: var(--tx);
      flex-shrink: 0;
      white-space: nowrap
    }

    .mbr .vr {
      font-weight: 700;
      color: var(--tx2);
      flex-shrink: 0;
      white-space: nowrap
    }

    .mbt {
      border-top: 1.5px solid var(--b2);
      margin-top: 7px;
      padding-top: 7px;
      font-weight: 700
    }

    #goalList {
      column-count: 2;
      column-gap: 12px;
    }

    #goalList .gc {
      display: block;
      break-inside: avoid;
      margin-bottom: 12px;

    }

    @media(max-width:800px) {
      #goalList { column-count: 1 }
      #goalList .gc.gc-wide { column-span: none }
    }

    /* ── Account & Goal card full-width expansion ───────────────────────────── */
    /* Spans both columns. On 1-col screens this is a no-op. */
    .ac.ac-wide  { column-span: all; margin-top: 12px }
    .ac.ac-wide:first-child { margin-top: 0 }
    .gc.gc-wide  { column-span: all; margin-top: 12px }
    .gc.gc-wide:first-child { margin-top: 0 }
    /* Collapsed account card: hide sub-line, updated date, and full section; keep balance */
    .ac.ac-collapsed .asub,
    .ac.ac-collapsed .upd,
    .ac.ac-collapsed .ac-full { display: none !important }
    .ac.ac-collapsed { align-items: center }
    .ac.ac-collapsed .aval .upd { display: none !important }
    /* Collapsed goal card: hide everything after the header */
    .gc.gc-collapsed .gc-body { display: none !important }

    /* Width toggle button — shared style for account and goal cards */
    .card-width-btn {
      background: none;
      border: 1px solid var(--b2);
      border-radius: var(--rsm);
      cursor: pointer;
      color: var(--tx3);
      font-size: 11px;
      padding: 2px 5px;
      line-height: 1.4;
      opacity: .6;
      transition: opacity .15s, border-color .15s;
      flex-shrink: 0;
      font-family: inherit;
      white-space: nowrap
    }

    .card-width-btn:hover {
      opacity: 1;
      border-color: var(--tx3)
    }

    /* ── Three-dot card options menu ──────────────────────────────────────────── */
    .card-menu-wrap {
      position: relative;
      flex-shrink: 0
    }

    .card-menu-btn {
      background: none;
      border: 1px solid transparent;
      border-radius: var(--rsm);
      cursor: pointer;
      color: var(--tx3);
      font-size: 18px;
      line-height: 1;
      padding: 2px 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 28px;
      min-height: 28px;
      opacity: .55;
      transition: opacity .15s, border-color .15s, background .15s;
      font-family: inherit
    }

    .card-menu-btn:hover,
    .card-menu-btn.open {
      opacity: 1;
      border-color: var(--b2);
      background: var(--sf2)
    }

    .card-menu-dropdown {
      display: none;
      position: fixed;
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      box-shadow: 0 4px 16px rgba(0,0,0,.13);
      min-width: 150px;
      z-index: 9999;
      overflow: visible
    }

    .card-menu-dropdown.open {
      display: block
    }

    .card-menu-item {
      display: block;
      width: 100%;
      background: none;
      border: none;
      border-bottom: 1px solid var(--b1);
      padding: 10px 14px;
      text-align: left;
      font-size: 13px;
      font-family: inherit;
      color: var(--tx);
      cursor: pointer;
      white-space: nowrap;
      transition: background .12s
    }

    .card-menu-item:last-child {
      border-bottom: none
    }

    .card-menu-item:hover {
      background: var(--sf2)
    }

    .card-menu-item.dan {
      color: var(--r)
    }

    .card-menu-item.dan:hover {
      background: var(--rbg)
    }

    .card-menu-confirm {
      padding: 8px 10px;
      border-bottom: 1px solid var(--b1);
      background: var(--rbg)
    }

    .card-menu-confirm p {
      font-size: 12px;
      color: var(--rtx);
      margin-bottom: 6px;
      font-weight: 600
    }

    .card-menu-confirm-btns {
      display: flex;
      gap: 5px
    }

    .card-menu-confirm-btns button {
      flex: 1;
      padding: 5px 0;
      font-size: 12px;
      font-family: inherit;
      border-radius: var(--rsm);
      cursor: pointer;
      border: 1.5px solid var(--b2);
      background: var(--sf)
    }

    .card-menu-confirm-btns .cmc-yes {
      background: var(--r);
      color: #fff;
      border-color: var(--r)
    }

    .card-menu-confirm-btns .cmc-no {
      background: var(--sf);
      color: var(--tx2)
    }

    /* ── Overview grid + card drag-and-drop ─────────────────────────────────── */
    /* Two-column multi-column layout: cards stack independently in each column
       so a short/collapsed card never leaves dead space beside a taller neighbour.
       DOM order is still a single flat list, so drag-and-drop works unchanged.  */
    #ov-grid {
      column-count: 2;
      column-gap: 12px;
    }

    /* Full-width card breaks across both columns */
    .ov-card.ov-full { column-span: all; margin-top: 12px }
    .ov-card.ov-full:first-child { margin-top: 0 }

    /* Half-width card stays in one column */
    .ov-card:not(.ov-full) { column-span: none }

    /* Always single column on mobile */
    @media(max-width:800px) {
      #ov-grid { column-count: 1 }
      .ov-card.ov-full,
      .ov-card:not(.ov-full) { column-span: none }
    }

    .ov-card {
      display: block;
      break-inside: avoid;
      margin-bottom: 12px;

      transition: box-shadow .18s, border-color .18s, opacity .2s, transform .22s cubic-bezier(.25,.46,.45,.94)
    }

    /* Spending card inner layout: when half-width, it IS the card.
       When full-width we still want a single card, not a g2 grid. */
    .ov-card[data-ov-key="spending"] .ov-spend-inner {
      display: block
    }

    .ov-card.ov-drag-over {
      outline: 2px dashed var(--b2);
      outline-offset: 3px
    }

    .ov-card.ov-shift-down {
      transform: translateY(10px)
    }

    /* Collapsed state — shrinks card to a single header line */
    .ov-card.ov-collapsed > *:not(:first-child) { display: none !important }
    .ov-card.ov-collapsed { padding-bottom: 10px }
    #cfSumLine { display: none }
    .ov-card.ov-collapsed #cfSumLine { display: flex !important }
    #sbSumLine { display: none }
    .ov-card.ov-collapsed #sbSumLine { display: flex !important }

    .ov-card.ov-shift-up {
      transform: translateY(-10px)
    }

    .ov-drag-handle {
      cursor: grab;
      color: var(--tx3);
      font-size: 13px;
      letter-spacing: -2px;
      user-select: none;
      flex-shrink: 0;
      padding: 0 3px 0 0;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      opacity: .45;
      transition: opacity .15s
    }

    .ov-drag-handle:hover { opacity: 1 }
    .ov-drag-handle:active { cursor: grabbing }

    /* Width-toggle button */

    /* ── Forecast grid + card drag-and-drop ─────────────────────────────────── */
    #fc-grid {
      column-count: 2;
      column-gap: 12px;
    }

    .fc-card.fc-full { column-span: all; margin-top: 12px }
    .fc-card.fc-full:first-child { margin-top: 0 }
    .fc-card:not(.fc-full) { column-span: none }

    @media(max-width:800px) {
      #fc-grid { column-count: 1 }
      .fc-card.fc-full,
      .fc-card:not(.fc-full) { column-span: none }
    }

    .fc-card {
      display: block;
      break-inside: avoid;
      margin-bottom: 12px;

      transition: box-shadow .18s, border-color .18s, opacity .2s, transform .22s cubic-bezier(.25,.46,.45,.94)
    }

    .fc-card.fc-drag-over {
      outline: 2px dashed var(--b2);
      outline-offset: 3px
    }

    .fc-card.fc-shift-down { transform: translateY(10px) }
    .fc-card.fc-shift-up   { transform: translateY(-10px) }

    /* Collapsed state — shrinks card to header only */
    .fc-card.fc-collapsed > *:not(:first-child) { display: none !important }
    .fc-card.fc-collapsed { padding-bottom: 10px }

    /* ── Summary card two-column layout ─────────────────────────────────────────
       Full width: Pay Off and Save Up sit side-by-side as equal columns.
       Half width: stacked — each section's 1fr 1fr .mg grid wraps naturally 2×2.
       A vertical rule separates the two columns at full width. */
    .fc-sum-inner {
      display: block
    }
    .fc-card.fc-full .fc-sum-inner {
      display: flex;
      gap: 0;
      align-items: flex-start
    }
    .fc-sum-col {
      flex: 1;
      min-width: 0;
      padding: 0 20px
    }
    .fc-sum-col:first-child {
      padding-left: 0
    }
    .fc-card.fc-full .fc-sum-col:first-child {
      border-right: 1px solid var(--b1)
    }
    .fc-sum-col:last-child {
      padding-right: 0
    }
    /* Half-width: remove side padding, add divider between stacked sections */
    .fc-card:not(.fc-full) .fc-sum-col {
      padding: 0
    }
    .fc-card:not(.fc-full) .fc-sum-col + .fc-sum-col {
      margin-top: 14px;
      padding-top: 14px;
      border-top: 1px solid var(--b1)
    }
    /* On mobile, always stacked regardless of fc-full */
    @media(max-width:800px) {
      .fc-card.fc-full .fc-sum-inner { display: block }
      .fc-sum-col { padding: 0 }
      .fc-sum-col:first-child { border-right: none }
      .fc-sum-col + .fc-sum-col { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--b1) }
    }

    .fc-drag-handle {
      cursor: grab;
      color: var(--tx3);
      font-size: 13px;
      letter-spacing: -2px;
      user-select: none;
      flex-shrink: 0;
      padding: 0 3px 0 0;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      opacity: .45;
      transition: opacity .15s
    }

    .fc-drag-handle:hover  { opacity: 1 }
    .fc-drag-handle:active { cursor: grabbing }

    /* ── Transaction grid + card drag-and-drop ───────────────────────────────── */
    #tx-grid {
      column-count: 2;
      column-gap: 12px;
    }

    .tx-card.tx-full { column-span: all; margin-top: 12px }
    .tx-card.tx-full:first-child { margin-top: 0 }
    .tx-card:not(.tx-full) { column-span: none }

    @media(max-width:800px) {
      #tx-grid { column-count: 1 }
      .tx-card.tx-full,
      .tx-card:not(.tx-full) { column-span: none }
    }

    .tx-card {
      display: block;
      break-inside: avoid;
      margin-bottom: 12px;

      transition: box-shadow .18s, border-color .18s, opacity .2s, transform .22s cubic-bezier(.25,.46,.45,.94)
    }

    .tx-card.tx-drag-over {
      outline: 2px dashed var(--b2);
      outline-offset: 3px
    }

    .tx-card.tx-shift-down { transform: translateY(10px) }
    .tx-card.tx-shift-up   { transform: translateY(-10px) }

    /* Collapsed state — shrinks card to header only */
    .tx-card.tx-collapsed > *:not(:first-child) { display: none !important }
    .tx-card.tx-collapsed { padding-bottom: 10px }

    .tx-drag-handle {
      cursor: grab;
      color: var(--tx3);
      font-size: 13px;
      letter-spacing: -2px;
      user-select: none;
      flex-shrink: 0;
      padding: 0 3px 0 0;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      opacity: .45;
      transition: opacity .15s
    }

    .tx-drag-handle:hover { opacity: 1 }
    .tx-drag-handle:active { cursor: grabbing }

    /* ── Budget grid + card drag-and-drop ───────────────────────────────────── */
    #bud-grid {
      column-count: 2;
      column-gap: 12px;
    }

    .bud-card.bud-full { column-span: all; margin-top: 12px }
    .bud-card.bud-full:first-child { margin-top: 0 }
    .bud-card:not(.bud-full) { column-span: none }

    @media(max-width:800px) {
      #bud-grid { column-count: 1 }
      .bud-card.bud-full,
      .bud-card:not(.bud-full) { column-span: none }
    }

    .bud-card {
      display: block;
      break-inside: avoid;
      margin-bottom: 12px;

      transition: box-shadow .18s, border-color .18s, opacity .2s, transform .22s cubic-bezier(.25,.46,.45,.94)
    }

    .bud-card.bud-drag-over {
      outline: 2px dashed var(--b2);
      outline-offset: 3px
    }

    .bud-card.bud-shift-down { transform: translateY(10px) }
    .bud-card.bud-shift-up   { transform: translateY(-10px) }

    /* Collapsed state — shrinks card to header only */
    .bud-card.bud-collapsed > *:not(:first-child) { display: none !important }
    .bud-card.bud-collapsed { padding-bottom: 10px }

    .bud-drag-handle {
      cursor: grab;
      color: var(--tx3);
      font-size: 13px;
      letter-spacing: -2px;
      user-select: none;
      flex-shrink: 0;
      padding: 0 3px 0 0;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      opacity: .45;
      transition: opacity .15s
    }

    .bud-drag-handle:hover { opacity: 1 }
    .bud-drag-handle:active { cursor: grabbing }

    /* ── Recurring Rules list ────────────────────────────────────────────────── */
    /* Recurring Rules — single-row layout (≥ 600 px) */
    .rec-rule-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 9px 0;
      border-bottom: .5px solid var(--b1);
      font-size: 13px
    }

    .rec-rule-row:last-child { border-bottom: none }

    .rec-rule-icon {
      color: var(--tx3);
      font-size: 10px;
      flex-shrink: 0;
      width: 14px;
      text-align: center;
      align-self: flex-start;
      margin-top: 3px
    }

    .rec-rule-body   { flex: 1; min-width: 0 }

    .rec-rule-top {
      display: flex;
      align-items: baseline;
      gap: 6px;
      min-width: 0
    }

    .rec-rule-desc {
      font-weight: 500;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      min-width: 0;
      flex: 1
    }

    .rec-rule-meta {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-top: 2px;
      flex-wrap: wrap
    }

    .rec-rule-freq {
      font-size: 11px;
      color: var(--tx3);
      white-space: nowrap
    }

    .rec-rule-next {
      font-size: 11px;
      color: var(--tx2);
      white-space: nowrap;
      display: flex;
      align-items: center;
      gap: 4px
    }

    .rec-rule-amt {
      font-size: 12px;
      font-weight: 600;
      white-space: nowrap;
      margin-left: auto
    }

    .rec-rule-edit {
      font-size: 11px;
      padding: 0 10px;
      height: 28px;
      border-radius: var(--rsm);
      border: 1.5px solid var(--b2);
      background: none;
      color: var(--tx2);
      cursor: pointer;
      font-family: inherit;
      font-weight: 600;
      white-space: nowrap;
      flex-shrink: 0;
      align-self: center
    }

    .rec-rule-edit:hover { background: var(--sf2); color: var(--tx) }

    /* ── Account card drag-and-drop (group mode only) ───────────────────────── */
    .ac {
      position: relative
    }

    .ac-drag-handle {
      cursor: grab;
      color: var(--tx3);
      font-size: 13px;
      letter-spacing: -2px;
      user-select: none;
      flex-shrink: 0;
      padding: 2px 4px 2px 0;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      align-self: center;
      opacity: .35;
      transition: opacity .15s
    }

    .ac-drag-handle:hover { opacity: 1 }
    .ac-drag-handle:active { cursor: grabbing }

    .ac.ac-dragging {
      opacity: .38;
      transform: scale(0.98);
      box-shadow: 0 6px 24px rgba(0,0,0,0.16);
      z-index: 10;
      transition: opacity .15s, transform .15s, box-shadow .15s
    }

    .ac.ac-drag-over {
      border-color: var(--tx);
      box-shadow: 0 0 0 2px var(--b2);
      background: var(--sf2)
    }

    .ac.ac-shift-down {
      transform: translateY(8px);
      transition: transform .18s cubic-bezier(.25,.46,.45,.94)
    }

    .ac.ac-shift-up {
      transform: translateY(-8px);
      transition: transform .18s cubic-bezier(.25,.46,.45,.94)
    }

            .gc {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 13px 15px;
      margin-bottom: 10px;
      transition: box-shadow .18s, border-color .18s, opacity .2s, transform .22s cubic-bezier(.25,.46,.45,.94)
    }

    .gc.gc-drag-over {
      border-color: var(--tx);
      box-shadow: 0 0 0 2px var(--b2);
      background: var(--sf2)
    }

    .gc.gc-shift-down {
      transform: translateY(8px);
    }

    .gc.gc-shift-up {
      transform: translateY(-8px);
    }

    .gc-drag-handle {
      cursor: grab;
      color: var(--tx3);
      font-size: 14px;
      letter-spacing: -2px;
      user-select: none;
      flex-shrink: 0;
      padding: 0 4px 0 0;
      line-height: 1;
      display: inline-flex;
      align-items: center
    }

    .gc-drag-handle:active {
      cursor: grabbing
    }

    .gchead {
      display: flex;
      align-items: flex-start;
      gap: 8px;
      margin-bottom: 9px
    }

    .gcbtns {
      display: flex;
      flex-direction: column;
      gap: 5px;
      flex-shrink: 0;
      margin-left: auto;
      align-items: flex-end
    }

    .gcname {
      font-weight: 700;
      font-size: 15px;
      flex: 1
    }

    .gbody {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      gap: 7px;
      margin-bottom: 9px
    }

    .gstat {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 8px 10px;
      border: 1px solid var(--b1)
    }

    .gsl {
      font-size: 11px;
      color: var(--tx2);
      text-transform: uppercase;
      letter-spacing: .06em;
      font-weight: 600
    }

    .gsv {
      font-size: 14px;
      font-weight: 700;
      margin-top: 2px
    }

    .gsv.g {
      color: var(--tx)
    }

    .gsv.r {
      color: var(--tx2)
    }

    .gc-chart-wrap {
      margin-top: 8px;
      position: relative;
      height: 80px;
    }

    .gc-chart-status {
      position: absolute;
      top: 6px;
      right: 8px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: .04em;
      padding: 2px 7px;
      border-radius: 20px;
      background: var(--sf2);
      border: 1px solid var(--b1);
    }

    .gc-chart-status.ahead { color: var(--g); border-color: var(--g); background: var(--gbg); }
    .gc-chart-status.behind { color: var(--r); border-color: var(--r); background: var(--rbg); }
    .tgrow {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 10px 0;
      border-bottom: 1px solid var(--b1);
      min-height: 44px
    }

    .tgrow:last-child {
      border-bottom: none
    }

    .tog {
      width: 48px;
      height: 26px;
      border-radius: 13px;
      background: var(--sf3);
      border: 1.5px solid var(--b2);
      cursor: pointer;
      position: relative;
      transition: background .2s;
      flex-shrink: 0
    }

    .tog.on {
      background: var(--tx);
      border-color: var(--tx)
    }

    .tog::after {
      content: '';
      position: absolute;
      top: 3px;
      left: 3px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #fff;
      transition: left .2s;
      box-shadow: 0 1px 3px rgba(0, 0, 0, .3)
    }

    .tog.on::after {
      left: 23px
    }

    /* Extra payment row */
    .ep-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 0;
      border-top: 1px solid var(--b1);
      margin-top: 8px;
      min-height: 44px
    }

    .ep-lbl {
      font-size: 13px;
      font-weight: 500;
      color: var(--tx2);
      flex: 1;
      min-width: 120px
    }

    .ep-btn {
      border: 1.5px solid var(--b2);
      background: var(--sf2);
      color: var(--tx);
      width: 36px;
      height: 36px;
      border-radius: var(--rsm);
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      transition: all .15s;
      font-family: inherit
    }

    .ep-btn:hover {
      background: var(--sf3);
      border-color: var(--tx)
    }

    .ep-inp {
      width: 88px;
      text-align: right;
      padding: 0 10px;
      min-height: 36px;
      flex-shrink: 0
    }

    /* Timeline */
    .tli {
      display: flex;
      align-items: flex-start;
      gap: 11px;
      margin-bottom: 10px;
      font-size: 13px
    }

    .tld {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: var(--tx);
      flex-shrink: 0;
      margin-top: 3px;
      border: 2px solid var(--tx)
    }

    .tld.r {
      background: var(--sf);
      border-color: var(--tx)
    }

    /* Chart legend */
    /* Account checkbox list */
    .acchk {
      border: 1.5px solid var(--b2);
      border-radius: var(--rsm);
      padding: 6px;
      max-height: 180px;
      overflow-y: auto;
      margin-top: 3px
    }

    .chkrow {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 5px;
      border-bottom: 1px solid var(--b1);
      cursor: pointer;
      min-height: 44px
    }

    .chkrow:last-child {
      border-bottom: none
    }

    .chkrow:hover {
      background: var(--sf2)
    }

    .chkrow .cklbl {
      font-size: 13px;
      flex: 1
    }

    /* Modal */
    #modal {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, .6);
      z-index: 200;
      align-items: center;
      justify-content: center;
      padding: 16px
    }

    .mdli {
      background: var(--sf);
      border-radius: var(--ra);
      border: 2px solid var(--tx);
      padding: 24px;
      width: 100%;
      max-width: 540px;
      max-height: 92vh;
      overflow-y: auto
    }

    .mdlt {
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 16px
    }

    .mdlb {
      display: flex;
      justify-content: flex-end;
      gap: 8px;
      margin-top: 16px
    }

    #fileInput {
      display: none
    }

    #bakInput {
      display: none
    }

    .bak-section {
      margin-bottom: 20px
    }

    .bak-section-title {
      font-size: 14px;
      font-weight: 700;
      margin-bottom: 5px;
      color: var(--tx)
    }

    .bak-card > button {
      color: var(--tx);
      outline: none;
      -webkit-tap-highlight-color: transparent;
    }
    .bak-card > button:focus,
    .bak-card > button:active {
      outline: none;
      background: none;
    }

    .bak-section-sub {
      font-size: 12px;
      color: var(--tx2);
      margin-bottom: 12px;
      line-height: 1.7
    }

    .bak-card {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 16px 18px;
      margin-bottom: 10px
    }

    .bak-meta {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 12px 14px;
      font-size: 13px;
      margin-bottom: 14px;
      border: 1px solid var(--b1)
    }

    .bak-meta-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 4px 0
    }

    .bak-meta-row span:first-child {
      color: var(--tx2)
    }

    .bak-meta-row strong {
      color: var(--tx);
      font-weight: 600
    }

    /* ── Settings hub grid ───────────────────────────────────────────────────── */
    .st-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin-top: 4px;
    }

    .st-tile {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 18px 16px 16px;
      cursor: pointer;
      text-align: left;
      display: flex;
      flex-direction: column;
      gap: 6px;
      transition: background .15s, border-color .15s;
      -webkit-tap-highlight-color: transparent;
      outline: none;
    }
    .st-tile:hover {
      background: var(--sf2);
    }
    .st-tile:active {
      background: var(--sf3);
    }
    .st-tile.danger {
      border-color: var(--r);
    }
    .st-tile-icon {
      display: none;
    }
    .st-tile-label {
      font-size: 15px;
      font-weight: 700;
      color: var(--tx);
      line-height: 1.2;
    }
    .st-tile.danger .st-tile-label {
      color: var(--r);
    }
    .st-tile-sub {
      font-size: 12px;
      color: var(--tx3);
      line-height: 1.4;
    }


    /* ── Settings panel (slide-in) ───────────────────────────────────────────── */
    .st-panel-wrap {
      position: absolute;
      inset: 0;
      background: var(--bg);
      overflow-y: auto;
      transform: translateX(100%);
      transition: transform .22s cubic-bezier(.4,0,.2,1);
      z-index: 10;
    }
    .st-panel-wrap.open {
      transform: translateX(0);
    }
    .st-panel-head {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 14px 16px 12px;
      border-bottom: 1px solid var(--b1);
      position: sticky;
      top: 0;
      background: var(--bg);
      z-index: 1;
    }
    .st-panel-back {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--tx2);
      font-size: 18px;
      padding: 2px 6px 2px 0;
      line-height: 1;
      -webkit-tap-highlight-color: transparent;
    }
    .st-panel-back:hover { color: var(--tx); }
    .st-panel-title {
      font-size: 15px;
      font-weight: 700;
      color: var(--tx);
    }
    .st-panel-body {
      padding: 18px 16px 32px;
    }

    .bak-actions {
      display: flex;
      gap: 9px;
      flex-wrap: wrap
    }

    .restore-preview {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 12px 14px;
      margin: 12px 0;
      font-size: 13px;
      border: 1.5px solid var(--b2)
    }

    .restore-preview-title {
      font-weight: 700;
      margin-bottom: 8px;
      font-size: 14px
    }

    .rp-row {
      display: flex;
      justify-content: space-between;
      padding: 4px 0;
      border-bottom: 1px solid var(--b1)
    }

    .rp-row:last-child {
      border-bottom: none
    }

    .rp-row span:first-child {
      color: var(--tx2)
    }

    .warn-box {
      background: var(--sf2);
      border: 2px solid var(--tx2);
      border-radius: var(--rsm);
      padding: 11px 14px;
      font-size: 13px;
      color: var(--tx);
      margin: 10px 0;
      line-height: 1.7
    }

    .ok-box {
      background: var(--sf2);
      border: 2px solid var(--tx);
      border-radius: var(--rsm);
      padding: 11px 14px;
      font-size: 13px;
      color: var(--tx);
      margin: 10px 0;
      line-height: 1.7
    }

    .err-box {
      background: var(--sf2);
      border: 2px dashed var(--tx);
      border-radius: var(--rsm);
      padding: 11px 14px;
      font-size: 13px;
      color: var(--tx);
      margin: 10px 0;
      line-height: 1.7
    }

    .hist-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 0;
      border-bottom: 1px solid var(--b1);
      font-size: 13px
    }

    .hist-item:last-child {
      border-bottom: none
    }

    .hist-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--tx);
      flex-shrink: 0
    }

    /* Income tab */
    .inc-card {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 14px 16px;
      margin-bottom: 10px
    }

    .inc-stub {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 12px 14px;
      margin-bottom: 8px;
      font-size: 13px;
      border: 1px solid var(--b1)
    }

    .inc-stub-hdr {
      display: flex;
      align-items: center;
      gap: 9px;
      margin-bottom: 8px
    }

    .inc-stub-title {
      font-weight: 700;
      font-size: 14px;
      flex: 1
    }

    .inc-row {
      display: flex;
      justify-content: space-between;
      padding: 3px 0;
      font-size: 13px;
      color: var(--tx2)
    }

    .inc-row strong {
      color: var(--tx);
      font-weight: 600
    }

    .inc-row.total {
      border-top: 1.5px solid var(--b2);
      margin-top: 6px;
      padding-top: 6px;
      font-weight: 700;
      color: var(--tx)
    }

    .inc-row.total strong {
      color: var(--tx)
    }

    /* Account balance history */
    .acc-cat-pill {
      border: 1.5px solid var(--b2);
      background: transparent;
      color: var(--tx2);
      padding: 0 10px;
      min-height: 44px;
      border-radius: var(--rsm);
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      font-family: inherit;
      transition: all .15s;
      white-space: nowrap;
      display: flex;
      align-items: center;
      justify-content: center;
      text-align: center;
      width: 100%
    }

    .acc-cat-pill.on {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx)
    }

    .acc-cat-pill:hover:not(.on) {
      background: var(--sf3);
      color: var(--tx)
    }

    @media(max-width:600px) {
      .acc-filter-grid {
        grid-template-columns: repeat(3, 1fr) !important
      }

      .tx-filter-grid {
        grid-template-columns: 1fr !important
      }
    }

    .acc-hist-hdr {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      margin-bottom: 6px;
      flex-wrap: wrap;
      gap: 4px
    }

    .acc-hist-title {
      font-size: 12px;
      font-weight: 600;
      color: var(--tx2);
      margin-right: auto
    }

    .acc-hist-range {
      display: flex;
      gap: 3px;
      flex-wrap: wrap
    }

    .acc-hist-range button {
      border: 1.5px solid var(--b2);
      background: transparent;
      color: var(--tx2);
      padding: 0 10px;
      min-height: 36px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 11px;
      font-family: inherit;
      transition: all .15s;
      display: inline-flex;
      align-items: center
    }

    .acc-hist-range button.on {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx)
    }

    .acc-hist-pts-toggle {
      font-size: 11px;
      color: var(--tx3);
      cursor: pointer;
      user-select: none;
      margin-top: 6px;
      display: inline-block
    }

    .acc-hist-pts-toggle:hover {
      color: var(--tx2)
    }

    .acc-hist-body {
      display: none
    }

    .acc-hist-body.open {
      display: block
    }

    /* Buckets */
    .bkt-section {
      background: var(--sf2);
      border-radius: var(--rsm);
      padding: 11px 14px;
      margin-top: 8px;
      font-size: 13px;
      border: 1px solid var(--b1)
    }

    .bkt-section-hdr {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 8px
    }

    .bkt-section-title {
      font-size: 11px;
      font-weight: 700;
      color: var(--tx2);
      text-transform: uppercase;
      letter-spacing: .07em;
      flex: 1
    }

    .bkt-row {
      padding: 8px 0;
      border-bottom: 1px solid var(--b1)
    }

    .bkt-row:last-child {
      border-bottom: none
    }

    .bkt-row-hdr {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 6px
    }

    .bkt-row-name {
      font-weight: 600;
      font-size: 13px;
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .bkt-row-vals {
      font-size: 11px;
      color: var(--tx2);
      white-space: nowrap;
      flex-shrink: 0
    }

    .bkt-inline-row {
      display: flex;
      align-items: center;
      gap: 5px;
      flex-wrap: wrap
    }

    .bkt-inline-lbl {
      font-size: 12px;
      color: var(--tx2);
      white-space: nowrap;
      flex-shrink: 0
    }

    .bkt-inline-sep {
      font-size: 12px;
      color: var(--tx2);
      white-space: nowrap;
      flex-shrink: 0
    }

    .bkt-amt-inp {
      width: 84px;
      padding: 0 8px;
      min-height: 36px;
      font-size: 13px;
      text-align: right;
      border: 1.5px solid var(--b2);
      border-radius: 4px;
      background: var(--sf);
      color: var(--tx);
      font-family: inherit
    }

    .bkt-max-inp {
      width: 92px;
      padding: 0 8px;
      min-height: 36px;
      font-size: 13px;
      text-align: right;
      border: 1.5px solid var(--b2);
      border-radius: 4px;
      background: var(--sf);
      color: var(--tx);
      font-family: inherit
    }

    .bkt-total-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 8px;
      margin-top: 2px;
      border-top: 1.5px solid var(--b2);
      font-size: 12px;
      font-weight: 700
    }

    .bal-dp {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 5px 0;
      border-bottom: 1px solid var(--b1);
      font-size: 12px
    }

    .bal-dp:last-child {
      border-bottom: none
    }

    .bal-dp-date {
      color: var(--tx2);
      min-width: 90px
    }

    .bal-dp-val {
      font-weight: 600;
      flex: 1
    }

    /* Transaction month group headers */
    .tx-month-hdr {
      font-size: 12px;
      font-weight: 700;
      color: var(--tx2);
      text-transform: uppercase;
      letter-spacing: .07em;
      padding: 10px 12px 5px;
      background: var(--sf2);
      border-bottom: 1px solid var(--b2)
    }

    .tx-month-hdr:first-child {
      padding-top: 7px
    }

    .tx-month-sum {
      font-size: 11px;
      font-weight: 400;
      color: var(--tx2);
      float: right;
      text-transform: none;
      letter-spacing: 0
    }

    /* Paystub upload zone */
    #stubInput {
      display: none
    }

    #incInput {
      display: none
    }

    /* Budget cards */
    .bkt-card {
      background: var(--sf);
      border: 1.5px solid var(--b2);
      border-radius: var(--ra);
      padding: 16px 18px
    }

    .bkt-header {
      display: flex;
      align-items: center;
      gap: 9px;
      margin-bottom: 12px
    }

    .bkt-icon {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      flex-shrink: 0;
      border: 2px solid var(--tx);
      background: var(--sf2)
    }

    .bkt-name {
      font-weight: 700;
      font-size: 15px
    }

    .bkt-pct {
      font-size: 12px;
      color: var(--tx2);
      margin-top: 2px
    }

    .bkt-amounts {
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      margin-bottom: 9px
    }

    .bkt-spent {
      font-size: 24px;
      font-weight: 700
    }

    .bkt-limit {
      font-size: 13px;
      color: var(--tx2);
      padding-bottom: 3px
    }

    .bkt-pb {
      background: var(--sf3);
      border-radius: 3px;
      height: 8px;
      overflow: hidden;
      margin-bottom: 7px;
      border: 1px solid var(--b1)
    }

    .bkt-pf {
      height: 100%;
      border-radius: 3px;
      transition: width .3s
    }

    .bkt-footer {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: var(--tx2)
    }

    .bucket-sel {
      padding: 0 10px;
      min-height: 36px;
      font-size: 12px;
      border: 1.5px solid var(--b2);
      border-radius: 4px;
      background: var(--sf);
      color: var(--tx);
      font-family: inherit;
      cursor: pointer
    }

    .bucket-sel:focus {
      outline: none;
      border-color: var(--tx);
      border-width: 2px
    }

    .tx-desc-link {
      color: var(--tx);
      cursor: pointer;
      text-decoration: underline;
      text-decoration-style: dotted;
      text-underline-offset: 3px
    }

    .tx-desc-link:hover {
      color: var(--tx2)
    }

    .tx-acc-link:hover {
      color: var(--tx2) !important
    }

    #budCatList {
      max-height: 280px;
      overflow-y: auto;
      border: 1.5px solid var(--b1);
      border-radius: var(--rsm);
      padding: 4px 10px;
      margin-bottom: 2px
    }

    #budRuleList {
      max-height: 180px;
      overflow-y: auto;
      border: 1.5px solid var(--b1);
      border-radius: var(--rsm);
      padding: 4px 10px;
      margin-bottom: 2px
    }

    @keyframes spin {
      to {
        transform: rotate(360deg)
      }
    }

    /* Recurring transaction markers */
    .tx-rec {
      color: var(--tx3);
      font-size: 10px;
      margin-left: 3px;
      vertical-align: middle;
      letter-spacing: 0
    }

    /* Split transaction rows */
    .tx-split-row td {
      background: var(--sf2);
      font-size: 12px;
      border-top: none !important
    }

    .tx-split-row td:first-child {
      padding-left: 28px;
      position: relative
    }

    .tx-split-row td:first-child::before {
      content: '↳';
      position: absolute;
      left: 14px;
      color: var(--tx3);
      font-size: 11px
    }

    .tx-split-badge {
      display: inline-block;
      font-size: 9px;
      font-weight: 600;
      padding: 1px 5px;
      border-radius: 3px;
      background: var(--sf3);
      color: var(--tx2);
      vertical-align: middle;
      margin-left: 4px;
      letter-spacing: .04em
    }

    .tx-note {
      font-size: 11px;
      color: var(--tx3);
      font-style: italic;
      margin-top: 2px;
      white-space: normal;
      word-break: break-word;
      line-height: 1.35;
    }

    .tx-has-splits td {
      border-bottom: none !important
    }

    .tx-row-selected {
      background: var(--ambg) !important
    }

    .up-row-overdue {
      background: var(--rbg);
      border-radius: var(--rsm);
      padding-left: 6px;
      padding-right: 6px;
      margin: 0 -6px
    }

    .post-btn {
      font-size: 11px;
      padding: 0 10px;
      height: 28px;
      border-radius: var(--rsm);
      border: 1.5px solid var(--g);
      background: var(--gbg);
      color: var(--gtx);
      cursor: pointer;
      font-family: inherit;
      font-weight: 600;
      white-space: nowrap;
      flex-shrink: 0
    }

    .post-btn:hover {
      background: var(--g);
      color: #fff
    }

    .dismiss-btn {
      font-size: 11px;
      padding: 0 8px;
      height: 28px;
      border-radius: var(--rsm);
      border: 1.5px solid var(--am);
      background: var(--ambg);
      color: var(--amtx);
      cursor: pointer;
      font-family: inherit;
      white-space: nowrap;
      flex-shrink: 0
    }

    .dismiss-btn:hover {
      background: var(--am);
      color: #fff
    }

    .up-row {
      display: flex;
      flex-direction: column;
      padding: 8px 0;
      border-bottom: .5px solid var(--b1);
      font-size: 13px;
      gap: 6px
    }

    .up-row:last-child {
      border-bottom: none
    }

    .up-row-main {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%
    }

    .up-row-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: flex-end
    }

    .up-row-act-sep {
      width: 1px;
      height: 16px;
      background: var(--b1);
      flex-shrink: 0
    }

    .up-date {
      font-size: 11px;
      color: var(--tx2);
      width: 44px;
      flex-shrink: 0;
      white-space: nowrap
    }

    .up-days {
      font-size: 10px;
      border-radius: 4px;
      padding: 1px 5px;
      flex-shrink: 0;
      white-space: nowrap
    }

    .up-days.soon {
      background: rgba(180, 30, 30, .12);
      color: #b41e1e
    }

    .up-days.today {
      background: rgba(20, 82, 176, .15);
      color: #1452b0;
      font-weight: 600
    }

    .up-days.future {
      background: var(--sf2);
      color: var(--tx3)
    }

    .up-desc {
      flex: 1;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap
    }

    .up-amt {
      font-weight: 600;
      white-space: nowrap;
      flex-shrink: 0
    }

    .up-cat {
      font-size: 10px;
      color: var(--tx3);
      flex-shrink: 0
    }

    /* ── Tooltip system ──────────────────────────────────────────────────────────
   The floating panel appears above the icon on hover/focus.
   Repositions to below if insufficient space above.              */
    .tip {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 15px;
      height: 15px;
      border-radius: 50%;
      font-size: 9px;
      font-weight: 700;
      font-family: Arial, sans-serif;
      line-height: 1;
      cursor: help;
      user-select: none;
      border: 1.5px solid var(--b2);
      background: var(--sf2);
      color: var(--tx2);
      vertical-align: middle;
      margin-left: 5px;
      position: relative;
      flex-shrink: 0;
      transition: background .12s, color .12s, border-color .12s;
    }

    .tip:hover,
    .tip:focus {
      background: var(--tx);
      color: var(--bg);
      border-color: var(--tx);
      outline: none;
    }

    [data-theme="color"] .tip:hover,
    [data-theme="color"] .tip:focus {
      background: var(--bl);
      color: #fff;
      border-color: var(--bl);
    }

    /* Floating panel */
    .tip-panel {
      display: none;
      position: fixed;
      z-index: 9999;
      max-width: 260px;
      min-width: 160px;
      background: var(--tx);
      color: var(--bg);
      border-radius: var(--ra);
      padding: 9px 12px;
      font-size: 12px;
      line-height: 1.55;
      font-family: Arial, sans-serif;
      font-weight: 400;
      box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
      pointer-events: none;
    }

    [data-theme="color"] .tip-panel {
      background: #0f2a5c;
      color: #fff;
    }

    /* Arrow */
    .tip-panel::after {
      content: '';
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      border: 6px solid transparent;
    }

    .tip-panel.above::after {
      top: 100%;
      border-top-color: var(--tx);
    }

    [data-theme="color"] .tip-panel.above::after {
      border-top-color: #0f2a5c;
    }

    .tip-panel.below::after {
      bottom: 100%;
      border-bottom-color: var(--tx);
    }

    [data-theme="color"] .tip-panel.below::after {
      border-bottom-color: #0f2a5c;
    }

    /* ── PIN Entry Modal ─────────────────────────────────────────────────────── */
    .pin-modal-overlay {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(0,0,0,.6);
      z-index: 500;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }
    .pin-modal-overlay.open { display: flex; }
    .pin-modal-box {
      background: var(--sf);
      border: 2px solid var(--tx);
      border-radius: var(--ra);
      padding: 28px 24px 22px;
      width: 100%;
      max-width: 340px;
      text-align: center;
      box-shadow: 0 8px 32px rgba(0,0,0,.22);
    }
    [data-theme="color"] .pin-modal-box { border-color: var(--g); }
    [data-theme="dark"]  .pin-modal-box { border-color: var(--g); }
    .pin-modal-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
    .pin-modal-sub { font-size: 12px; color: var(--tx2); margin-bottom: 20px; line-height: 1.6; }
    .pin-inputs { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
    .pin-digit {
      width: 58px !important;
      min-height: unset !important;
      height: 66px;
      font-size: 30px;
      font-weight: 700;
      text-align: center;
      border: 2px solid var(--b2) !important;
      border-radius: var(--ra) !important;
      background: var(--sf2) !important;
      color: var(--tx) !important;
      padding: 0 !important;
      outline: none;
      caret-color: transparent;
      transition: border-color .15s;
      -moz-appearance: textfield;
    }
    .pin-digit::-webkit-outer-spin-button,
    .pin-digit::-webkit-inner-spin-button { -webkit-appearance: none; }
    .pin-digit:focus { border-color: var(--tx) !important; border-width: 2.5px !important; }
    [data-theme="color"] .pin-digit:focus { border-color: var(--g) !important; }
    [data-theme="dark"]  .pin-digit:focus { border-color: var(--g) !important; }
    .pin-modal-err { font-size: 12px; color: var(--r); min-height: 18px; margin-bottom: 10px; }
    .pin-modal-btns { display: flex; gap: 8px; justify-content: flex-end; }
    .pin-modal-note { font-size: 10px; color: var(--tx3); margin-top: 14px; line-height: 1.5; }
