@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap");

/* ---------------------------------------------------------------------
   1. TOKENS — LIGHT (default)
   --------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* sidebar / auth darks */
  --bg-1: #0e1f22;
  --bg-2: #16302f;

  /* surfaces */
  --surface: #ffffff;
  --surface-2: #f1f5f4;
  --surface-3: #e8eeec;          /* NEW: pressed chips, track fills */
  --line: #e2e8e6;
  --line-strong: #d0dad7;        /* NEW: input borders, outline buttons */

  /* text */
  --text: #14201f;               /* 16.4:1 on --surface */
  --muted: #5d6b69;              /* 5.6:1 on --surface, 5.1:1 on --surface-2 */

  /* brand */
  --primary: #0f8a7e;            /* fills, bars, focus — 4.3:1 (UI/large only) */
  --primary-2: #3aa89a;          /* gradient partner */
  --primary-d: #0b6b62;          /* links, active text, theme-color — 6.5:1 */
  --primary-bg: #e3f3f0;         /* NEW: tinted selection / active chip */
  --on-primary: #ffffff;         /* NEW: text on --primary */

  /* semantic */
  --green: #12925a;              /* bars, icons */
  --green-text: #0f7d4c;         /* NEW: +amounts — 5.1:1 */
  --green-bg: #e3f5ec;
  --red: #d14343;
  --red-text: #c03838;           /* NEW: −amounts — 5.0:1 */
  --red-bg: #fcebea;
  --amber: #d98e04;
  --amber-text: #8a5a00;         /* NEW */
  --amber-bg: #fdf3dc;           /* NEW */
  --blue: #5b7fd6;               /* NEW: transfer accent */
  --blue-bg: #e7eefb;            /* NEW */

  /* shape */
  --radius: 16px;
  --radius-sm: 10px;             /* NEW: buttons, inputs, nav pills */
  --radius-xs: 6px;              /* NEW: badges-square, swatches */
  --radius-pill: 999px;          /* NEW */

  /* depth — soft, teal-tinted, two-layer */
  --shadow-sm: 0 1px 2px rgba(15, 40, 38, .04), 0 4px 14px -6px rgba(15, 40, 38, .10);
  --shadow-md: 0 2px 4px rgba(15, 40, 38, .05), 0 10px 24px -10px rgba(15, 40, 38, .18);
  --shadow-lg: 0 4px 8px rgba(15, 40, 38, .05), 0 20px 40px -14px rgba(15, 40, 38, .26);
  --shadow-primary: 0 4px 12px -4px rgba(15, 138, 126, .50); /* NEW */
  --focus-ring: 0 0 0 3px rgba(15, 138, 126, .28);           /* NEW */

  /* motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur: .22s;                   /* NEW */

  /* type */
  --font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* NEW */

  /* sidebar (NEW, derived) */
  --side-text: #b9cdca;
  --side-muted: #6f8c88;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(58, 168, 154, .20);

  /* ---------- 2. EXTENDED PALETTE (§3.4) ---------- */
  /* chart / donut ramp (in order) */
  --chart-1: #0f8a7e;  /* teal     */
  --chart-2: #5b7fd6;  /* periwinkle */
  --chart-3: #e0894a;  /* apricot  */
  --chart-4: #9a6fcf;  /* violet   */
  --chart-5: #3fb0c9;  /* lagoon   */
  --chart-6: #d4648a;  /* rose     */
  --chart-7: #d9a21b;  /* sand gold*/
  --chart-8: #7f9a4a;  /* moss     */
  --chart-grid: #e8eeec;
  --chart-axis: #8a9a97;

  /* hashed avatars */
  --avatar-1: #0f8a7e;
  --avatar-2: #5b7fd6;
  --avatar-3: #9a6fcf;
  --avatar-4: #e0894a;
  --avatar-5: #3fb0c9;
  --avatar-6: #d4648a;

  /* calculators */
  --calc-principal: #0f8a7e;
  --calc-interest: #e0894a;

  /* favourite / expiry */
  --fav: #e0894a;

  /* master-dashboard module icon gradients */
  --grad-brand:       linear-gradient(135deg, var(--primary), var(--primary-2));
  --grad-finance:     linear-gradient(135deg, #0f8a7e, #3aa89a);
  --grad-goals:       linear-gradient(135deg, #d4648a, #9a6fcf);
  --grad-time:        linear-gradient(135deg, #0f8a7e, #3fb0c9);
  --grad-assets:      linear-gradient(135deg, #9a6fcf, #3fb0c9);
  --grad-people:      linear-gradient(135deg, #e0894a, #d9a21b);
  --grad-credentials: linear-gradient(135deg, #5b7fd6, #9a6fcf);
  --grad-diary:       linear-gradient(135deg, #d4648a, #e0894a);
  --grad-car:         linear-gradient(135deg, #3fb0c9, #5b7fd6);
  --grad-ai:          linear-gradient(135deg, #14201f, #0f8a7e);

  /* badges (bg / fg) */
  --badge-income-bg: #e3f5ec;   --badge-income-fg: #0c5c39;
  --badge-expense-bg: #fcebea;  --badge-expense-fg: #8c2323;
  --badge-transfer-bg: #e7eefb; --badge-transfer-fg: #2c4a8a;
  --badge-muted-bg: #edf1f0;    --badge-muted-fg: #4f5d5b;
  --badge-auto-bg: #fdf3dc;     --badge-auto-fg: #7d5500;

  /* payment card faces (NEW) */
  --paycard-1: linear-gradient(135deg, #0e3b38 0%, #0f8a7e 100%);
  --paycard-2: linear-gradient(135deg, #1b2a4a 0%, #5b7fd6 100%);
  --paycard-3: linear-gradient(135deg, #3a1f3f 0%, #9a6fcf 100%);
  --paycard-4: linear-gradient(135deg, #4a2412 0%, #e0894a 100%);
  --paycard-5: linear-gradient(135deg, #111a19 0%, #34403e 100%);
}

/* ---------------------------------------------------------------------
   1b. TOKENS — DARK
   Applied by [data-theme="dark"] on <html>. The bootstrap script in
   README.md sets it from saved choice or prefers-color-scheme.
   --------------------------------------------------------------------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-1: #060b0b;
  --bg-2: #0c1615;

  --surface: #141d1c;
  --surface-2: #0d1413;
  --surface-3: #1c2826;
  --line: #243230;
  --line-strong: #2f3f3c;

  --text: #e6eeec;               /* 14.6:1 on --surface */
  --muted: #93a4a1;              /* 6.9:1 on --surface */

  --primary: #2bb3a3;
  --primary-2: #5cc7b8;
  --primary-d: #5fd0c1;          /* links on dark — 9.4:1 */
  --primary-bg: #12302c;
  --on-primary: #06201d;

  --green: #3ccf8e;
  --green-text: #52d69b;
  --green-bg: #0f2a1f;
  --red: #ff7a73;
  --red-text: #ff8c85;
  --red-bg: #34191a;
  --amber: #f0b43c;
  --amber-text: #f3c56a;
  --amber-bg: #2f2410;
  --blue: #8aa8ff;
  --blue-bg: #18223a;

  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 1px 2px rgba(0, 0, 0, .40);
  --shadow-md: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 8px 20px -8px rgba(0, 0, 0, .55);
  --shadow-lg: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 18px 40px -12px rgba(0, 0, 0, .70);
  --shadow-primary: 0 4px 14px -4px rgba(43, 179, 163, .45);
  --focus-ring: 0 0 0 3px rgba(95, 208, 193, .32);

  --side-text: #a9bdb9;
  --side-muted: #5f7874;
  --side-hover: rgba(255, 255, 255, .05);
  --side-active: rgba(43, 179, 163, .18);

  --chart-1: #2bb3a3;
  --chart-2: #8aa8ff;
  --chart-3: #f0a36a;
  --chart-4: #b995f0;
  --chart-5: #5fcbe0;
  --chart-6: #f08aac;
  --chart-7: #f0c24a;
  --chart-8: #a3c46a;
  --chart-grid: #1f2b29;
  --chart-axis: #6f8480;

  --avatar-1: #1f9a8d;
  --avatar-2: #5b7fd6;
  --avatar-3: #9a6fcf;
  --avatar-4: #d57d40;
  --avatar-5: #2f9fb8;
  --avatar-6: #c9587f;

  --calc-principal: #2bb3a3;
  --calc-interest: #f0a36a;
  --fav: #f0a36a;

  --badge-income-bg: #0f2a1f;   --badge-income-fg: #7fe0b1;
  --badge-expense-bg: #34191a;  --badge-expense-fg: #ffa39d;
  --badge-transfer-bg: #18223a; --badge-transfer-fg: #a9c1ff;
  --badge-muted-bg: #1c2826;    --badge-muted-fg: #a9bab7;
  --badge-auto-bg: #2f2410;     --badge-auto-fg: #f3c56a;
}

/* ===== ORIGINAL app.css layout/structure rules (below) — colors driven by tokens above ===== */
/* ============================================================
   Personal Finance — animated design system
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-family);
    color: var(--text);
    background: radial-gradient(1200px 600px at 100% -10%, #eef1fb 0%, transparent 60%),
                radial-gradient(1000px 500px at -10% 110%, #f0ecfb 0%, transparent 55%),
                var(--surface-2);
    background-attachment: fixed;
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-d); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-2); }

/* ---- Keyframes -------------------------------------------- */
@keyframes fadeInUp   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn     { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInL   { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@keyframes popIn      { 0% { opacity: 0; transform: translateY(14px) scale(.96); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes floatPulse { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3px) rotate(-3deg); } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes shimmer    { 100% { transform: translateX(100%); } }
@keyframes flashIn    { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes ripple     { to { transform: scale(3.2); opacity: 0; } }
@keyframes spin       { to { transform: rotate(360deg); } }

/* ---- App layout ------------------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px; flex-shrink: 0;
    background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
    color: #c2c8de; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    box-shadow: 4px 0 24px rgba(11,16,32,.18);
    z-index: 10;
    transition: width .25s var(--ease), opacity .2s var(--ease);
}
html.sidebar-hidden .sidebar { width: 0; opacity: 0; overflow: hidden; pointer-events: none; }

.sidebar-toggle {
    margin-left: auto; background: rgba(255,255,255,.08); border: none; color: #c2c8de;
    width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; cursor: pointer;
    display: grid; place-items: center; font-size: 13px;
    transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--spring);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.18); color: #fff; transform: scale(1.08); }

.sidebar-reopen {
    display: none; position: fixed; top: 18px; left: 14px; z-index: 20;
    width: 34px; height: 34px; border-radius: 10px; place-items: center; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line); color: var(--text);
    box-shadow: var(--shadow-sm); transition: transform .2s var(--spring), box-shadow .2s var(--ease);
}
.sidebar-reopen:hover { transform: scale(1.08); box-shadow: var(--shadow-md, var(--shadow-sm)); }
html.sidebar-hidden .sidebar-reopen { display: grid; }

/* Mobile nav drawer backdrop — hidden on desktop, shown under the open drawer on mobile. */
.nav-backdrop { display: none; }

.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 16px; animation: fadeIn .6s var(--ease) both; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 11px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff; font-weight: 700; font-size: 20px;
    display: grid; place-items: center;
    box-shadow: 0 6px 18px -4px rgba(99,102,241,.6);
    animation: floatPulse 5s ease-in-out infinite;
}
.brand-text { display: flex; flex-direction: column; font-weight: 700; color: #fff; line-height: 1.15; }
.brand-text small { font-weight: 400; font-size: 11px; color: #7d85a3; letter-spacing: .04em; }

.nav { padding: 8px; flex: 1; overflow-y: auto; }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 13px; margin: 3px 0; border-radius: 11px;
    color: #c2c8de; font-weight: 500; position: relative;
    transition: transform .18s var(--ease), background .2s var(--ease), color .2s var(--ease);
    animation: slideInL .4s var(--ease) both;
}
.nav .nav-link:nth-child(1) { animation-delay: .03s; }
.nav .nav-link:nth-child(2) { animation-delay: .06s; }
.nav .nav-link:nth-child(3) { animation-delay: .09s; }
.nav .nav-link:nth-child(4) { animation-delay: .12s; }
.nav .nav-link:nth-child(5) { animation-delay: .15s; }
.nav .nav-link:nth-child(n+7) { animation-delay: .2s; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; transform: translateX(4px); text-decoration: none; }
.nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    color: #fff; box-shadow: 0 8px 20px -8px rgba(99,102,241,.8);
}
.nav-link.active::before {
    content: ""; position: absolute; left: -8px; top: 18%; height: 64%; width: 4px;
    border-radius: 4px; background: #fff;
}
.nav-link .ico { width: 18px; text-align: center; opacity: .92; transition: transform .2s var(--spring); }
.nav-link:hover .ico { transform: scale(1.2); }
.nav-section { padding: 18px 13px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #636b88; }

/* Collapsible nav domain groups (Finance now; Time etc. later) */
.nav-group-toggle { width: 100%; background: none; border: none; font: inherit; text-align: left; cursor: pointer; }
.nav-group-toggle .nav-caret { margin-left: auto; font-size: 10px; opacity: .65; }
.nav-group[hidden] { display: none; }
.nav-group .nav-sub { padding-left: 30px; margin: 2px 0; font-size: 13.5px; animation: none; }
.nav-group .nav-sub .ico { width: 16px; font-size: 13px; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); animation: fadeIn .8s var(--ease) both; }
.user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: grid; place-items: center; font-weight: 700; box-shadow: 0 4px 12px -3px rgba(99,102,241,.6); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { color: #fff; font-size: 13.5px; }
.user-meta small { color: #7d85a3; font-size: 11.5px; }
.user-link { text-decoration: none; }
.user-link:hover .user-meta strong { text-decoration: underline; }

/* Fills whatever width the viewport actually has next to the sidebar, instead
   of capping at a fixed px value that leaves dead space on wider screens.
   min-width:0 overrides the flex-item default (min-width:auto), which would
   otherwise refuse to shrink below wide content like the transactions table
   and force the whole page to overflow instead of scrolling internally. */
.main { flex: 1; min-width: 0; padding: 30px 34px; animation: fadeIn .4s var(--ease) both; }

/* ---- Page header ------------------------------------------ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; animation: fadeInUp .45s var(--ease) both; }
.page-head h1 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.page-head p { margin: 5px 0 0; color: var(--muted); max-width: 680px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.page-action-form { display: inline-flex; align-items: center; margin: 0; }

/* ---- Cards ------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); overflow: hidden;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
    animation: fadeInUp .5s var(--ease) both;
}
a.you-card { cursor: pointer; }
a.you-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md, var(--shadow-sm)); transform: translateY(-1px); }
a.you-card:hover span[aria-hidden] { color: var(--primary); }
.main > .card { animation-delay: .08s; }
.main > .card:nth-of-type(2) { animation-delay: .16s; }
.main > .card:nth-of-type(3) { animation-delay: .22s; }
.main > .card:nth-of-type(4) { animation-delay: .28s; }
.card:hover { box-shadow: var(--shadow-lg); border-color: #d9deef; transform: translateY(-2px); }
.card + .card { margin-top: 20px; }
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { margin: 0; font-size: 15px; }
.card-body { padding: 18px; }
.card-pad { padding: 18px; }

/* ---- Stat tiles ------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kind-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kind-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; display: flex; flex-direction: column; text-align: left;
}
.kind-card .label { margin-bottom: 6px; }
.kind-card p { margin: 0 0 14px; font-size: 13px; flex: 1; }
.kind-card .filters { margin-top: auto; }
@media (max-width: 880px) { .kind-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kind-grid { grid-template-columns: 1fr; } }

.holding-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }
.holding-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; display: flex; flex-direction: column; gap: 12px;
    text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
    transition: transform .25s var(--spring), box-shadow .25s var(--ease);
    animation: popIn .45s var(--ease) both;
}
.holding-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.holding-card-hd { display: flex; align-items: center; gap: 12px; }
.holding-card-hd .name { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.holding-card-meta { font-size: 12px; color: var(--muted); margin-top: -6px; }
.holding-card-stats { display: flex; justify-content: space-between; gap: 10px; }
.holding-card-stats .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.holding-card-stats .value { font-size: 17px; font-weight: 700; margin-top: 3px; }
.holding-card-ft { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; }
.holding-card-ft-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.auto-post-icon {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 22px; height: 22px; border-radius: 50%; font-size: 11.5px;
}
.auto-post-icon.on { background: #fff4dc; color: #8a5a00; }
.auto-post-icon.off { background: #eef0f4; color: var(--muted); opacity: .65; }
.tile {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
    transition: transform .25s var(--spring), box-shadow .25s var(--ease);
    animation: popIn .55s var(--ease) both;
}
.tile::before {
    content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 0;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
    transition: width .4s var(--ease);
}
.tile:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.tile:hover::before { width: 100%; }
.tiles .tile:nth-child(1) { animation-delay: .05s; }
.tiles .tile:nth-child(2) { animation-delay: .11s; }
.tiles .tile:nth-child(3) { animation-delay: .17s; }
.tiles .tile:nth-child(4) { animation-delay: .23s; }
.tiles .tile:nth-child(5) { animation-delay: .29s; }
.tiles .tile:nth-child(6) { animation-delay: .35s; }
.tile .label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.tile .value { font-size: 25px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; }

/* ---- Pagination --------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 13px; }
.pagination-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination-ellipsis { padding: 0 4px; color: var(--muted); }
.btn.disabled { opacity: .4; pointer-events: none; }

/* ---- Tables ----------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
table.data .nowrap { white-space: nowrap; }
table.data th.sortable { cursor: pointer; user-select: none; padding-right: 24px; position: relative; transition: color .15s var(--ease); }
table.data th.sortable:hover { color: var(--text); }
table.data th.sortable::after { content: '⇅'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; opacity: .35; }
table.data th.sortable:hover::after { opacity: .65; }
table.data th.sortable[data-sort-dir="asc"]::after { content: '↑'; opacity: 1; color: var(--primary); }
table.data th.sortable[data-sort-dir="desc"]::after { content: '↓'; opacity: 1; color: var(--primary); }
/* Opt-in per table (e.g. transactions) — amount stays right-aligned regardless via .num's higher specificity. */
table.data.table-center th:not(.num), table.data.table-center td:not(.num) { text-align: center; }
table.data.table-center th.tl, table.data.table-center td.tl { text-align: left; }   /* opt specific columns back to left-aligned */
table.data tbody tr { transition: background .18s var(--ease), transform .18s var(--ease); animation: fadeInUp .4s var(--ease) both; }
table.data tbody tr:nth-child(1) { animation-delay: .04s; } table.data tbody tr:nth-child(2) { animation-delay: .08s; }
table.data tbody tr:nth-child(3) { animation-delay: .12s; } table.data tbody tr:nth-child(4) { animation-delay: .16s; }
table.data tbody tr:nth-child(5) { animation-delay: .2s; }  table.data tbody tr:nth-child(6) { animation-delay: .24s; }
table.data tbody tr:nth-child(7) { animation-delay: .28s; } table.data tbody tr:nth-child(8) { animation-delay: .32s; }
table.data tbody tr:nth-child(n+9) { animation-delay: .36s; }
table.data tbody tr:hover { background: linear-gradient(90deg, #f6f7ff, #fbf9ff); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---- Buttons ---------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px;
    border: 1px solid transparent; font-weight: 600; font-size: 13.5px; cursor: pointer;
    background: var(--surface-2); color: var(--text); position: relative; overflow: hidden;
    transition: transform .14s var(--ease), box-shadow .2s var(--ease), filter .2s var(--ease), background .2s var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%); color: #fff; box-shadow: 0 6px 16px -6px rgba(99,102,241,.7); }
.btn-primary:hover { color: #fff; box-shadow: 0 10px 22px -6px rgba(99,102,241,.85); }
/* shine sweep on primary hover */
.btn-primary::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-120%);
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
}
.btn-primary:hover::after { animation: shimmer .7s var(--ease); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #c2c8de; }
.btn-ghost:hover { background: rgba(255,255,255,.09); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-d); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: #fbdcdc; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; line-height: 0; }
.btn-icon svg { display: block; }
.btn-block { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; color: var(--primary-d); padding: 4px 6px; cursor: pointer; font-weight: 600; }

/* ripple */
.ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.5); width: 12px; height: 12px; margin: -6px 0 0 -6px; pointer-events: none; animation: ripple .6s var(--ease) forwards; }
.btn-outline .ripple, .btn-danger .ripple, .btn-sm .ripple { background: rgba(99,102,241,.25); }

/* ---- Forms ------------------------------------------------ */
.field { display: block; margin-bottom: 15px; }
.field[hidden] { display: none; }   /* the `hidden` attr must win over .field's display:block (e.g. filter fields) */
.field-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.field-label .req { color: var(--red); font-weight: 700; }   /* required-field asterisk */
.field-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Project colour picker — "Auto" + curated preset swatches (no freeform hex fiddling) */
.swatches { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.swatches .swatch {
    position: relative; width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
    background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.14);
    display: flex; align-items: center; justify-content: center;
    transition: transform .12s var(--ease);
}
.swatches .swatch:hover { transform: scale(1.12); }
.swatches .swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatches .swatch.is-on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.swatches .swatch-auto {
    width: auto; height: 32px; padding: 0 14px; background: var(--surface-2);
    color: var(--text); font-size: 12.5px; font-weight: 600;
}
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password], input[type=number], input[type=date], input[type=month], input[type=week], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    font: inherit; color: var(--text); background: #fff;
    transition: border-color .18s var(--ease), box-shadow .2s var(--ease), transform .15s var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,.14); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid .col-span { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }

/* ---- Alerts ----------------------------------------------- */
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 13.5px; animation: flashIn .4s var(--spring) both; }
.alert-success { background: var(--green-bg); color: #0f5132; border: 1px solid #b6e6cf; }
.alert-error { background: var(--red-bg); color: #7f1d1d; border: 1px solid #f3c2c2; }
.alert-list { margin: 8px 0 0; padding-left: 18px; }

/* ---- Badges & amounts ------------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; transition: transform .15s var(--spring); }
tr:hover .badge { transform: scale(1.06); }
.badge-income { background: var(--green-bg); color: #0f5132; }
.badge-expense { background: var(--red-bg); color: #7f1d1d; }
.badge-transfer { background: #eef0ff; color: #3730a3; }
.badge-muted { background: #eef0f4; color: var(--muted); }
.badge-auto { background: #fff4dc; color: #8a5a00; }
.amt-pos { color: var(--green); font-weight: 650; }
.amt-neg { color: var(--red); font-weight: 650; }
.muted { color: var(--muted); }
.tree-indent { color: #c2c6d2; }

/* ---- Filter bar ------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .field { margin-bottom: 0; }
.filters .field-label { font-size: 11.5px; }
.filters select, .filters input { min-width: 140px; }

/* ---- Auth -------------------------------------------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh;
    background: linear-gradient(135deg, #1e1b4b, #0b1020 55%, #2a1b4b);
    background-size: 200% 200%; animation: gradientShift 14s ease infinite; }
.auth-card { width: 366px; background: rgba(255,255,255,.97); border-radius: 18px; padding: 30px; box-shadow: 0 30px 70px rgba(0,0,0,.4); animation: popIn .5s var(--ease) both; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 19px; margin: 0; display: flex; flex-direction: column; }
.auth-brand small { font-weight: 400; font-size: 11.5px; color: var(--muted); }
.error-code { font-size: 60px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.error-message { color: var(--muted); margin: 8px 0 20px; }

/* ---- Split rows ------------------------------------------- */
.splits-table { width: 100%; border-collapse: collapse; }
.splits-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; padding: 0 8px 6px; }
.splits-table td { padding: 4px 8px 8px; vertical-align: top; }
.split-row { animation: fadeInUp .3s var(--ease) both; }
.split-sum { display: flex; gap: 18px; align-items: center; margin-top: 10px; font-weight: 600; }
.split-sum .ok { color: var(--green); }
.split-sum .bad { color: var(--red); }

[data-types] { transition: opacity .2s var(--ease); }

@media (max-width: 820px) {
    /* Sidebar becomes a slide-in drawer opened by the hamburger; closed by default. */
    .sidebar {
        position: fixed !important; top: 0; left: 0; bottom: 0; height: 100vh;
        width: 264px !important; opacity: 1 !important; overflow-y: auto; pointer-events: auto !important;
        z-index: 60; transform: translateX(-100%); transition: transform .28s var(--ease);
    }
    html.nav-open .sidebar { transform: translateX(0); box-shadow: 6px 0 30px rgba(11,16,32,.45); }
    /* Hamburger always available on mobile (regardless of the desktop hidden state). */
    .sidebar-reopen { display: grid !important; top: 12px; left: 12px; z-index: 58; }
    html.nav-open .sidebar-reopen { opacity: 0; pointer-events: none; }
    .sidebar-toggle { display: grid; }
    .nav-backdrop {
        display: block; position: fixed; inset: 0; z-index: 59; background: rgba(8,10,20,.5);
        opacity: 0; pointer-events: none; transition: opacity .28s var(--ease);
    }
    html.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
    .main { padding: 66px 16px 24px; }   /* room for the fixed hamburger */
    .form-grid { grid-template-columns: 1fr; }
}

/* ---- Payment cards (bank-app style) ----------------------- */
.paycard {
    position: relative; color: #fff; border-radius: 18px; padding: 22px;
    aspect-ratio: 1.586 / 1; max-width: 380px; width: 100%;
    display: flex; flex-direction: column; justify-content: space-between;
    box-shadow: 0 18px 40px -16px rgba(20,24,60,.55), inset 0 1px 0 rgba(255,255,255,.2);
    overflow: hidden; text-decoration: none; color: #fff;
    transition: transform .3s var(--spring), box-shadow .3s var(--ease);
    animation: popIn .5s var(--ease) both;
}
a.paycard:hover { transform: translateY(-6px) rotate(-.5deg) scale(1.015); box-shadow: 0 30px 60px -18px rgba(20,24,60,.6); color: #fff; text-decoration: none; }
.paycard-sheen { position: absolute; inset: 0; background:
    radial-gradient(130% 90% at 0% 0%, rgba(255,255,255,.28), transparent 48%),
    linear-gradient(125deg, rgba(255,255,255,.14), transparent 42%); pointer-events: none; }
.paycard > * { position: relative; z-index: 1; }
.paycard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.paycard-brand { display: flex; flex-direction: column; gap: 3px; }
.paycard-bank { font-weight: 700; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,.2); }
.paycard-logo { max-height: 30px; max-width: 130px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.paycard-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; opacity: .85; }
.paycard-bal { text-align: right; display: flex; flex-direction: column; }
.paycard-bal small { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; opacity: .8; }
.paycard-bal strong { font-size: 17px; }
.paycard-bal strong.neg { color: #ffd5d5; }
.paycard-chip { width: 44px; height: 33px; border-radius: 7px; background: linear-gradient(135deg, #f7d774, #cda23a); position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.paycard-chip::after { content: ""; position: absolute; inset: 6px 9px; border: 1px solid rgba(0,0,0,.2); border-radius: 3px; }
.paycard-number { font-size: 19px; letter-spacing: .14em; font-family: "Consolas","SF Mono",monospace; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.paycard-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.paycard-fields { display: flex; gap: 18px; }
.paycard-field small { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; opacity: .75; }
.paycard-field span { font-size: 13px; font-weight: 600; text-transform: uppercase; }
.paycard-net { font-weight: 800; font-style: italic; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.paycard-inactive { position: absolute; top: 14px; right: 14px; background: rgba(0,0,0,.4); padding: 2px 9px; border-radius: 999px; font-size: 10px; z-index: 2; }

.paycard-photo { background-image: var(--art); background-size: cover; background-position: center; background-repeat: no-repeat; }
/* Vertical/portrait card artwork — portrait tile, card fills it edge-to-edge (cover),
   no background fill, no cropping. Height is fixed by the shelf below, so it lines up
   with the landscape cards (just narrower). */
.paycard-photo.paycard-portrait { aspect-ratio: 1 / 1.586; }
/* On the detail page the card is the hero; keep a portrait one from getting oversized. */
.ps-preview .paycard-portrait { max-width: 240px; margin-inline: auto; }
.paycard-photo-number { position: absolute; left: 16px; bottom: 16px; z-index: 2; font-size: 15px; letter-spacing: .12em; font-family: "Consolas","SF Mono",monospace; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); background: rgba(0,0,0,.4); backdrop-filter: blur(3px); border-radius: 8px; padding: 5px 11px; }
/* Portrait cards are much smaller, so scale the overlaid number down to keep it in
   proportion (same bottom-left spot as the landscape cards). */
.paycard-portrait .paycard-photo-number { font-size: 9px; letter-spacing: .04em; left: 8px; bottom: 8px; padding: 2px 6px; border-radius: 5px; }

/* Fixed-height shelf so landscape + portrait cards line up on the same row
   (a portrait card keeps its shape and simply comes out narrower). */
.paycard-grid { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.paycard-grid .paycard { height: 202px; width: auto; max-width: none; }
@media (max-width: 600px) { .paycard-grid .paycard { height: 168px; } }

.bank-fam { margin-bottom: 26px; padding: 16px 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(99,102,241,.035); }
.bank-fam-hd { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; padding-left: 2px; }
.bank-fam-name { font-size: 15px; font-weight: 750; color: var(--text); }
.bank-fam-name::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 9px; vertical-align: middle; }
.bank-fam-count { font-size: 12px; color: var(--muted); }
.paycard-grid-nested { gap: 16px; padding-left: 18px; }
.paycard-add {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    aspect-ratio: 1.586 / 1; max-width: 380px; width: 100%; border-radius: 18px;
    border: 2px dashed var(--line); color: var(--muted); background: rgba(255,255,255,.5);
    font-weight: 600; transition: all .25s var(--ease);
}
.paycard-add:hover { border-color: var(--primary); color: var(--primary-d); background: #fff; transform: translateY(-4px); text-decoration: none; }
.paycard-add .plus { font-size: 36px; line-height: 1; }

/* Wallets & cash — compact list rows instead of full card visuals */
.ps-section-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 14px; }
.ps-section-head h2 { margin: 0; font-size: 16px; }
.ps-section-head .count { font-size: 12px; color: var(--muted); }
.ps-simple { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ps-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.ps-item:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); text-decoration: none; color: var(--text); }
.ps-item-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 19px; box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.ps-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ps-item-name { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-item-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ps-item-bal { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.ps-layout { display: flex; gap: 26px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.ps-preview { width: 380px; flex-shrink: 0; position: sticky; top: 24px; }
@media (max-width: 880px) { .ps-preview { width: 100%; position: static; } }

.reveal { font-family: "Consolas", monospace; letter-spacing: .06em; }
.reveal-btn { margin-left: 8px; }

/* ---- Avatars & vendor cards ------------------------------- */
.avatar-badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; overflow: hidden; flex-shrink: 0; box-shadow: 0 4px 12px -4px rgba(0,0,0,.28); }
.avatar-badge img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; font-size: 34px; margin: 0 auto; }

.vendor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vendor-card { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease); animation: fadeInUp .45s var(--ease) both; }
.vendor-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #d9deef; text-decoration: none; }
.vendor-card-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vendor-card-body strong { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vendor-card-spend { text-align: right; display: flex; flex-direction: column; }
.vendor-card-add { justify-content: center; color: var(--muted); border-style: dashed; gap: 8px; font-weight: 600; }
.vendor-card-add:hover { color: var(--primary-d); border-color: var(--primary); }
.vendor-card-add .plus { font-size: 24px; }

/* ---- New-transaction hub ---------------------------------- */
.hub-group-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 10px; font-weight: 700; }
.hub-group-label:first-of-type { margin-top: 8px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.hub-tile { display: flex; align-items: center; gap: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); animation: fadeInUp .4s var(--ease) both; }
.hub-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); text-decoration: none; }
.hub-ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; flex-shrink: 0; color: #fff; }
.hub-in { background: linear-gradient(135deg, #10b981, #34d399); }
.hub-out { background: linear-gradient(135deg, #ef4444, #f87171); }
.hub-move { background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.hub-tile-body { display: flex; flex-direction: column; min-width: 0; }
.hub-tile-body strong { color: var(--text); }
.hub-tile-body small { color: var(--muted); font-size: 12px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.tree-row { display: inline-flex; align-items: center; gap: 6px; }
.tree-toggle { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 11px; width: 20px; height: 20px; border-radius: 5px; transition: background .15s var(--ease), color .15s var(--ease); }
.tree-toggle:hover { background: var(--surface-2); color: var(--primary-d); }
.tree-spacer { display: inline-block; width: 20px; }
.child-count { font-size: 11px; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 8px; }
.vendor-head { display: flex; align-items: center; gap: 16px; }
.vendor-preview .avatar-lg { box-shadow: 0 10px 26px -8px rgba(0,0,0,.35); }

.mbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.mbar-label { width: 64px; font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.mbar-track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.mbar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); animation: growBar .8s var(--ease) both; }
.mbar-val { width: 92px; text-align: right; font-size: 13px; font-weight: 600; color: var(--red); flex-shrink: 0; font-variant-numeric: tabular-nums; }
@keyframes growBar { from { width: 0; } }
.mbar-fill.mbar-red   { background: linear-gradient(90deg, var(--red), #fb7185); }
.mbar-fill.mbar-green { background: linear-gradient(90deg, var(--green), #34d399); }
.mbar-val.mbar-val-pos { color: var(--green); }

/* ---- Dashboard analytics --------------------------------- */
.tile-sub  { margin-top: 5px; font-size: 12px; color: var(--muted); }
.tile-unit { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 2px; }

.chart { width: 100%; height: auto; display: block; margin: 6px 0 2px; overflow: visible; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-axis .yr { fill: var(--muted); opacity: .65; }
.chart-tag  { fill: var(--primary-d); font-size: 12px; font-weight: 700; }

.comp-row { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.comp-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.comp-chip strong { color: var(--text); }
.comp-chip .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot-banks { background: var(--primary); }
.dot-investments { background: var(--green); }
.dot-cash { background: var(--amber); }
.dot-wallets { background: var(--primary-2); }
.dot-creditcards { background: var(--red); }

.legend { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.legend .lg { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.legend .lg-in  { background: var(--green); }
.legend .lg-out { background: var(--red); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
/* grid siblings must not inherit the stacked-card top margin (it offsets the 2nd card) */
.grid2 .card + .card { margin-top: 0; }
.grid2 .mbar-label { width: 124px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 880px) { .grid2 { grid-template-columns: 1fr; } }

.dash-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 20px;
    padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.df-group { display: inline-flex; align-items: center; gap: 8px; }
.df-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.df-select, .df-date {
    font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; cursor: pointer;
}
.df-select:focus, .df-date:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.df-custom { gap: 6px; flex-wrap: wrap; }
.df-custom[hidden] { display: none; }
.df-date { max-width: 150px; }
.df-showing { margin-left: auto; font-size: 13px; color: var(--muted); }
.df-showing strong { color: var(--text); }
@media (max-width: 720px) { .df-showing { margin-left: 0; width: 100%; } }

.obligs { display: flex; flex-direction: column; gap: 10px; }
.oblig { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface-2); transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.oblig:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.oblig-k { font-size: 12.5px; color: var(--muted); }
.oblig-v { font-size: 21px; font-weight: 750; margin-top: 3px; letter-spacing: -.01em; }
.oblig-s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Searchable select (type-to-search combobox) ---------- */
.ss-wrap { position: relative; }
select.ss-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ss-input { width: 100%; cursor: text; background-image: none; }
.ss-wrap::after {
    content: '▾'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-size: 11px; pointer-events: none;
}
.ss-panel {
    display: none; position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
    max-height: 260px; overflow-y: auto; background: var(--surface);
    border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px;
}
.ss-wrap.open .ss-panel { display: block; }
/* Let an open dropdown escape the card's rounded-corner clip AND lift the whole
   card above later siblings (e.g. the KPI .tiles). Opening the dropdown means
   hovering the card, and .card:hover's transform creates a stacking context that
   would otherwise trap the panel's z-index below the tiles that follow it. */
.card:has(.ss-wrap.open) { overflow: visible; position: relative; z-index: 50; }
.ss-option { padding: 8px 11px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); }
.ss-option:hover, .ss-option.active { background: var(--surface-2); }
.ss-option.selected { font-weight: 600; color: var(--primary-d); }
.ss-empty { padding: 9px 11px; color: var(--muted); font-size: 13px; }

/* ---- Recurring schedules (renewals / instalments): upcoming as cards, paid
   history as a table, editing a paid one as a native-dialog card. Shared by
   Subscriptions and Loans & EMI. -------------------------------------------- */
.ren-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ren-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.ren-card-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.ren-card-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.ren-card-form .field { margin-bottom: 0; }
.ren-card-form .field-label { font-size: 11px; }

.ren-dialog { border: none; border-radius: var(--radius); padding: 0; width: 460px; max-width: 92vw;
    box-shadow: var(--shadow-lg); }
.ren-dialog::backdrop { background: rgba(15,23,42,.55); }
.ren-dialog-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.ren-dialog-hd h3 { margin: 0; font-size: 15px; }
.ren-dialog-x { background: none; border: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.ren-dialog-x:hover { color: var(--text); }
.ren-dialog-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.ren-dialog-form .field { margin-bottom: 0; }
.ren-dialog-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 4px; }

/* ---- Time module ------------------------------------------ */
.tm-datenav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.tm-datenav input[type=date] { min-width: 160px; }

/* scoreboard split bar + legend + per-activity bars */
.tm-splitbar { display: flex; height: 24px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.tm-splitbar span { display: block; height: 100%; }
.tm-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.tm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.tm-actbars { margin-top: 16px; display: flex; flex-direction: column; gap: 11px; }
.tm-actbar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.tm-actbar-head i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.tm-actbar-track { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.tm-actbar-track span { display: block; height: 100%; border-radius: 6px; }

/* two-column day layout: timeline + right rail */
.tm-cols { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.tm-timeline-card { flex: 1 1 520px; min-width: 300px; margin: 0; }
.tm-rail { flex: 1 1 320px; min-width: 280px; max-width: 440px; }

/* timeline blocks + gaps */
.tm-track { display: flex; flex-direction: column; gap: 6px; }
.tm-block { display: flex; gap: 12px; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.tm-block-rail { display: flex; flex-direction: column; justify-content: space-between; min-width: 50px; font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 600; }
.tm-block-body { flex: 1; min-width: 0; }
.tm-block-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tm-block-dur { font-weight: 700; white-space: nowrap; }
.tm-gap { display: flex; gap: 12px; align-items: center; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface-2); }
.tm-gap-rail { min-width: 50px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tm-gap-body { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tm-editd summary { cursor: pointer; color: var(--primary-d); font-size: 12.5px; margin-top: 8px; width: max-content; }
.tm-editd[open] summary { margin-bottom: 10px; }

/* shared inline forms (add / edit / manage rows) */
.tm-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.tm-form .field { margin-bottom: 0; }
.tm-form-add { display: block; }
.tm-form-add .field { margin-bottom: 14px; }
.tm-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tm-grow { flex: 1 1 auto; min-width: 150px; }
.tm-form-inline { flex: 1 1 auto; }
.tm-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.tm-dot { width: 14px; height: 14px; border-radius: 5px; flex: 0 0 auto; align-self: center; }
.tm-check { display: block; }
.tm-check .field-label { margin-bottom: 6px; }
.tm-check-row { display: flex; align-items: center; gap: 6px; min-height: 40px; }

/* finance anchors */
.tm-anchors { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tm-anchor { display: flex; justify-content: space-between; gap: 10px; padding: 8px; border-radius: 8px; color: var(--text); }
.tm-anchor:hover { background: var(--surface-2); }
.tm-anchor-amt { font-weight: 700; white-space: nowrap; }

/* ---- Locked (read-only) form field, e.g. an inactive payment source ---- */
.locked-field { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--line);
    border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---- Transactions status multi-filter --------------------- */
/* Status filter — toggle pills (the native checkbox is visually hidden). */
.status-filter { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 7px; max-width: 420px; }
.status-chip { display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
    padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease); user-select: none; }
.status-chip:hover { border-color: var(--primary); color: var(--text); }
.status-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.status-chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px -3px rgba(99,102,241,.55); }

/* Transaction type tabs (quick filter above the ledger table). */
.txn-tabs { display: flex; gap: 5px; overflow-x: auto; padding: 12px 14px; border-bottom: 1px solid var(--line); scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.txn-tabs::-webkit-scrollbar { height: 6px; }
.txn-tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.txn-tab { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 7px 14px;
    border-radius: 999px; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease); }
.txn-tab:hover { background: var(--surface-2); color: var(--text); }
.txn-tab.is-active { background: var(--primary); color: #fff; }

/* ---- Respect reduced-motion ------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Credentials vault ------------------------------------ */
.vault-wrap { max-width: 520px; margin: 0 auto; }
.vault-card { margin-top: 8px; }
.vault-hd { text-align: center; margin-bottom: 22px; }
.vault-hd h1 { margin: 6px 0 8px; font-size: 22px; }
.vault-hd p { margin: 0 auto; max-width: 44ch; font-size: 13.5px; line-height: 1.55; }
.vault-ico { font-size: 34px; line-height: 1; display: inline-block; }

.alert-warn { background: color-mix(in srgb, var(--fav) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--fav) 45%, var(--line)); color: var(--text); }
.alert-warn strong { color: #b8730a; }

/* password input + inline action buttons */
.pw-field { display: flex; gap: 8px; align-items: stretch; }
.pw-field input { flex: 1; min-width: 0; }
.pw-field .btn { flex: 0 0 auto; white-space: nowrap; }

/* strength meter */
.pw-meter { margin-top: 8px; height: 6px; background: var(--surface-2); border-radius: 999px; position: relative; overflow: hidden; }
.pw-meter-bar { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--line); transition: width .2s var(--ease), background .2s var(--ease); }
.pw-meter-label { position: absolute; right: 2px; top: 9px; font-size: 11px; }

/* category filter chips (reuses the pill look) */
.cat-chips { display: flex; flex-wrap: wrap; gap: 7px; padding-bottom: 14px; }
.cat-chip { font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.cat-chip:hover { border-color: var(--primary); color: var(--text); }
.cat-chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* list */
.cred-title { text-decoration: none; color: var(--text); display: inline-flex; align-items: center; gap: 4px; }
.cred-title:hover strong { text-decoration: underline; }
.cred-fav { color: var(--fav); }

/* detail rows */
.cred-detail { display: flex; flex-direction: column; gap: 4px; }
.cred-line { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.cred-line:last-child { border-bottom: 0; }
.cred-line-label { color: var(--muted); font-size: 12.5px; padding-top: 6px; }
.cred-line-value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cred-line-value--block { align-items: flex-start; flex-direction: column; }
.cred-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; background: var(--surface-2); padding: 6px 10px; border-radius: 8px; word-break: break-all; }
.cred-notes { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; margin: 0; width: 100%; max-width: 100%; }
.cred-secret { letter-spacing: .5px; }

@media (max-width: 560px) {
    .cred-line { grid-template-columns: 1fr; gap: 4px; }
    .cred-line-label { padding-top: 0; }
}

/* ---- Finance calculators ---------------------------------- */
.calc-tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
/* One consistent vertical rhythm between the panel's blocks (inputs / tiles / viz / table). */
.calc-panel { display: flex; flex-direction: column; gap: 20px; }
.calc-panel[hidden] { display: none; }   /* keep the hidden tab hidden — our display:flex must not beat [hidden] */
.calc-panel > .card + .card { margin-top: 0; }
.calc-tab { font-size: 14px; font-weight: 600; color: var(--muted); background: none; border: none; cursor: pointer; padding: 10px 16px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.calc-tab:hover { color: var(--text); }
.calc-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.calc-inputs { align-items: start; }
.input-affix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.input-affix input { border: none !important; background: transparent !important; border-radius: 0 !important; flex: 1; min-width: 0; }
.input-affix .affix { display: inline-flex; align-items: center; padding: 0 11px; color: var(--muted); font-weight: 600; font-size: 13px; background: color-mix(in srgb, var(--line) 30%, transparent); }
.input-affix .affix-r { order: 2; }
.input-affix .affix-sel { border: none; background: color-mix(in srgb, var(--line) 30%, transparent); border-radius: 0; width: auto; padding: 0 8px; color: var(--muted); font-weight: 600; }
.calc-slider { width: 100%; margin-top: 10px; accent-color: var(--primary); }

.calc-tiles { margin-bottom: 0; }
.calc-viz .card-body { display: grid; gap: 18px; }

.calc-comp-bar { display: flex; height: 30px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.calc-comp-bar .seg { display: block; height: 100%; transition: width .25s var(--ease); }
.seg-p { background: var(--calc-principal); } .seg-i { background: var(--calc-interest); }
.calc-comp-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.calc-comp-legend b { color: var(--text); font-weight: 650; margin-left: 3px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot-p { background: var(--calc-principal); } .dot-i { background: var(--calc-interest); }

.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg-toggle button { font-size: 12.5px; font-weight: 600; border: none; background: var(--surface-2); color: var(--muted); cursor: pointer; padding: 6px 14px; }
.seg-toggle button.is-active { background: var(--primary); color: #fff; }

.calc-table-wrap { max-height: 460px; overflow-y: auto; }
.calc-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* ---- Credentials detail refinements ----------------------- */
.cred-card { max-width: 720px; }
.cred-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cred-avatar { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; }
.cred-head-txt { min-width: 0; }
.cred-head-id { font-weight: 650; font-size: 15px; word-break: break-all; }
.cred-head-sub { font-size: 12.5px; margin-top: 2px; }
.cred-line-label { display: flex; align-items: center; gap: 7px; }
.cred-line-label svg { width: 15px; height: 15px; opacity: .55; flex: 0 0 auto; }
.cred-line-value { min-width: 0; }
.cred-url { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.cred-foot svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; opacity: .6; }
.cred-foot-lock { margin-left: auto; }
@media (max-width: 560px) { .cred-foot-lock { margin-left: 0; flex-basis: 100%; } }

/* ===== TIDEWATER component overrides (win via source order) ===== */
/* =====================================================================
   3. BASE
   ===================================================================== */
html { background: var(--surface-2); }
body {
  font-family: var(--font-family);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.025em; line-height: 1.2; }
h2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 700; }
a { color: var(--primary-d); text-decoration: none; font-weight: 600; }
a:hover { color: var(--primary-d); text-decoration: underline; text-underline-offset: 3px; }
code, kbd, pre, samp, .mono { font-family: var(--font-mono); font-size: .92em; }
::selection { background: var(--primary-bg); color: var(--text); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
hr { border: 0; border-top: 1px solid var(--line); }
.num, td.num, .value, .amt-pos, .amt-neg { font-variant-numeric: tabular-nums; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid var(--surface-2); }
::-webkit-scrollbar-track { background: transparent; }

/* =====================================================================
   4. SIDEBAR
   ===================================================================== */
.sidebar {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  color: var(--side-text);
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--grad-brand);
  color: #fff;
  font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 16px -6px rgba(43, 179, 163, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.nav-section {
  color: var(--side-muted);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--side-text);
  font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav-link.active {
  background: var(--side-active);
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(92, 199, 184, .18);
}
.nav-link.active svg, .nav-link.active .ico { color: var(--primary-2); }

/* =====================================================================
   5. PAGE HEAD
   ===================================================================== */
.page-head { gap: 16px; }
.page-head h1 { margin: 0; }
.page-head .muted, .page-head p { font-size: 13px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* =====================================================================
   6. CARDS
   ===================================================================== */
.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .card { border-color: var(--line); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 16px 18px; }
.card-pad { padding: 18px; }

/* card grids: holdings, debts, goals, module tiles, vendors */
.kind-card, .holding-card, .oblig, .vendor-card, .ren-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.kind-card:hover, .holding-card:hover, .oblig:hover, .vendor-card:hover, .ren-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in oklab, var(--primary) 40%, var(--line));
}

/* =====================================================================
   7. KPI TILES
   ===================================================================== */
.tiles { gap: 12px; }
.tile {
  position: relative;
  min-width: 0;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 14px;
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) var(--ease);
}
[data-theme="dark"] .tile { border-color: var(--line); }
.tile::before {                       /* top accent: short rounded pill */
  content: "";
  position: absolute; top: 12px; left: 18px;
  width: 26px; height: 4px; border-radius: 2px;
  background: var(--tile-accent, var(--grad-brand));
}
.tile .label {
  display: block;
  margin-top: 10px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .value {
  display: block;
  margin-top: 2px;
  font-size: clamp(19px, 1.2vw + 10px, 25px); font-weight: 800;
  letter-spacing: -.025em; line-height: 1.2;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
a.tile, .tile[onclick], .tile.clickable { cursor: pointer; color: inherit; text-decoration: none; }
a.tile:hover, .tile[onclick]:hover, .tile.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
/* optional per-tile accent: <div class="tile" style="--tile-accent: var(--green)"> */

/* =====================================================================
   8. METER BARS
   ===================================================================== */
.mbar { display: flex; align-items: center; gap: 10px; }
.mbar-track {
  flex: 1; height: 8px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.mbar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--grad-brand);
  transform-origin: left center;
  animation: tw-grow .8s var(--ease) both;
}
.mbar-green .mbar-fill { background: var(--green); }
.mbar-red .mbar-fill { background: var(--red); }
.mbar-val { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5ch; text-align: right; }

/* =====================================================================
   9. BADGES, AMOUNTS
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; line-height: 1.4;
  letter-spacing: .01em;
  white-space: nowrap;
  background: var(--badge-muted-bg); color: var(--badge-muted-fg);
}
.badge-income   { background: var(--badge-income-bg);   color: var(--badge-income-fg); }
.badge-expense  { background: var(--badge-expense-bg);  color: var(--badge-expense-fg); }
.badge-transfer { background: var(--badge-transfer-bg); color: var(--badge-transfer-fg); }
.badge-muted    { background: var(--badge-muted-bg);    color: var(--badge-muted-fg); }
.badge-auto     { background: var(--badge-auto-bg);     color: var(--badge-auto-fg); }

.amt-pos { color: var(--green-text); font-weight: 700; }
.amt-neg { color: var(--red-text); font-weight: 700; }
.muted { color: var(--muted); }

/* =====================================================================
   10. FORMS
   ===================================================================== */
.form-grid { gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 700; color: var(--text); }
.field-hint { font-size: 12px; color: var(--muted); }

input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="month"], input[type="search"], input[type="tel"], input[type="url"],
select, textarea, .input {
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--muted) 75%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in oklab, var(--primary) 35%, var(--line-strong)); }
input:focus, select:focus, textarea:focus, .input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
input[type="range"] { accent-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

.input-affix {
  display: flex; align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.input-affix:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.input-affix input { border: 0; box-shadow: none; border-radius: 0; flex: 1; min-width: 0; }
.input-affix input:focus { box-shadow: none; }
.affix {
  display: grid; place-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700; font-size: 13px;
}
.affix:first-child { border-right: 1px solid var(--line); }
.affix:last-child { border-left: 1px solid var(--line); }

.swatch {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch.active, .swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--primary); }

/* =====================================================================
   11. BUTTONS
   ===================================================================== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  overflow: hidden;
  background: var(--surface-2); color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), transform .12s var(--ease), color var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { background: var(--primary-d); color: var(--on-primary); }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-2); }
.btn-primary::after {                 /* shimmer sweep */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}
.btn-primary:hover::after { animation: tw-shimmer .9s var(--ease); }

.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-d); background: var(--surface); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: color-mix(in oklab, var(--red) 85%, #000); color: #fff; }
[data-theme="dark"] .btn-danger { color: #2a0b0a; }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-block { display: flex; width: 100%; }

/* =====================================================================
   12. DATA TABLES
   ===================================================================== */
.table-wrap {
  overflow-x: auto;
  border-radius: inherit;
}
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  padding: 10px 16px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
}
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th[data-sort], table.data th.sortable { cursor: pointer; user-select: none; }
table.data th[data-sort]:hover, table.data th.sortable:hover { color: var(--text); }
table.data th.sorted, table.data th[aria-sort="ascending"], table.data th[aria-sort="descending"] { color: var(--primary-d); }
table.data td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--dur) var(--ease); animation: tw-fade-up .35s var(--ease) both; }
table.data tbody tr:nth-child(1) { animation-delay: .00s; }
table.data tbody tr:nth-child(2) { animation-delay: .03s; }
table.data tbody tr:nth-child(3) { animation-delay: .06s; }
table.data tbody tr:nth-child(4) { animation-delay: .09s; }
table.data tbody tr:nth-child(5) { animation-delay: .12s; }
table.data tbody tr:nth-child(6) { animation-delay: .15s; }
table.data tbody tr:nth-child(n+7) { animation-delay: .18s; }
table.data tbody tr:hover { background: color-mix(in oklab, var(--primary) 5%, var(--surface)); }
table.data tfoot td { font-weight: 800; background: var(--surface-2); border-top: 1px solid var(--line); }

/* =====================================================================
   13. AVATAR HEADER, HUB TILES
   ===================================================================== */
.avatar-badge {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--grad-brand);
  color: #fff;
  font-weight: 800; font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), var(--shadow-sm);
}
.hub-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 700; font-size: 13px;
  text-decoration: none;
  transition: transform var(--dur) var(--spring), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.hub-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in oklab, var(--primary) 40%, var(--line)); text-decoration: none; color: var(--text); }
.hub-ico {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--primary-bg);
  color: var(--primary-d);
  font-size: 16px;
}
.hub-tile:hover .hub-ico { background: var(--grad-brand); color: #fff; }

/* =====================================================================
   14. PAYMENT CARD (skeuomorphic)
   Chip + sheen are pseudo-elements, so no markup changes needed.
   Vary faces with style="--face: var(--paycard-2)".
   ===================================================================== */
.paycard {
  position: relative;
  aspect-ratio: 1.586 / 1;
  padding: 20px 22px;
  border-radius: 18px;
  color: #f4fbfa;
  background: var(--face, var(--paycard-1));
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .18) inset,
    0 -1px 0 rgba(0, 0, 0, .25) inset,
    0 18px 36px -16px rgba(6, 30, 28, .55),
    0 4px 10px -4px rgba(6, 30, 28, .30);
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .35s var(--spring), box-shadow .35s var(--ease);
}
.paycard::before {                    /* sheen + fine texture */
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255, 255, 255, .22), transparent 55%),
    radial-gradient(90% 60% at 0% 100%, rgba(0, 0, 0, .25), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 6px);
}
.paycard::after {                     /* EMV chip */
  content: "";
  position: absolute; left: 22px; top: 56px;
  width: 42px; height: 32px;
  border-radius: 7px;
  background:
    linear-gradient(90deg, transparent 32%, rgba(90, 64, 20, .45) 32% 34%, transparent 34% 66%, rgba(90, 64, 20, .45) 66% 68%, transparent 68%),
    linear-gradient(0deg, transparent 30%, rgba(90, 64, 20, .45) 30% 33%, transparent 33% 67%, rgba(90, 64, 20, .45) 67% 70%, transparent 70%),
    linear-gradient(135deg, #f3dfa2 0%, #d4b264 45%, #f6e7b8 60%, #b8913f 100%);
  box-shadow: inset 0 0 0 1px rgba(90, 64, 20, .35), 0 1px 2px rgba(0, 0, 0, .25);
}
.paycard:hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 28px 50px -18px rgba(6,30,28,.6); }
.paycard, .paycard * { text-decoration: none; }
.paycard [class*="num"], .paycard .mono, .paycard code {
  font-family: var(--font-mono);
  font-size: 16px; font-weight: 500;
  letter-spacing: .14em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
  color: #fff;
}
.paycard [class*="name"], .paycard [class*="holder"] { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.paycard [class*="bank"], .paycard [class*="brand"] { font-weight: 800; font-size: 14px; letter-spacing: -.01em; }
.paycard .muted, .paycard small { color: rgba(244, 251, 250, .72); }

/* =====================================================================
   15. RENEWAL DIALOG / MODALS
   ===================================================================== */
.ren-dialog, dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 0;
  animation: tw-pop .28s var(--spring) both;
}
dialog::backdrop, .ren-backdrop, .modal-backdrop { background: rgba(8, 20, 19, .45); backdrop-filter: blur(3px); }

/* =====================================================================
   16. ALERTS
   ===================================================================== */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px; font-weight: 500;
  color: var(--text);
}
.alert-success { background: var(--green-bg); border-color: color-mix(in oklab, var(--green) 25%, transparent); color: var(--badge-income-fg); }
.alert-error   { background: var(--red-bg);   border-color: color-mix(in oklab, var(--red) 25%, transparent);   color: var(--badge-expense-fg); }
.alert-warn    { background: var(--amber-bg); border-color: color-mix(in oklab, var(--amber) 30%, transparent); color: var(--amber-text); }

/* =====================================================================
   17. AUTH
   ===================================================================== */
.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(60% 50% at 20% 20%, rgba(58, 168, 154, .35), transparent 60%),
    radial-gradient(50% 50% at 85% 80%, rgba(91, 127, 214, .25), transparent 60%),
    linear-gradient(160deg, var(--bg-2), var(--bg-1));
  background-size: 140% 140%, 140% 140%, 100% 100%;
  animation: tw-drift 18s ease-in-out infinite alternate;
}
.auth-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45);
  padding: 32px;
  animation: tw-pop .4s var(--spring) both;
}

/* =====================================================================
   18. SEARCHABLE SELECT PANEL
   ===================================================================== */
.ss-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: tw-pop .18s var(--ease) both;
}
.ss-panel [role="option"], .ss-panel li, .ss-panel .ss-opt {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
}
.ss-panel [role="option"]:hover, .ss-panel li:hover, .ss-panel .ss-opt:hover,
.ss-panel [aria-selected="true"], .ss-panel .active { background: var(--primary-bg); color: var(--primary-d); }

/* =====================================================================
   19. PILL FURNITURE
   ===================================================================== */
.status-chip, .cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.cat-chip { cursor: pointer; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.cat-chip:hover { border-color: var(--line-strong); }
.cat-chip.active { background: var(--primary-bg); border-color: color-mix(in oklab, var(--primary) 40%, transparent); color: var(--primary-d); }

/* tab-style pills — share one segmented look */
.txn-tab, .calc-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.txn-tab:hover, .calc-tab:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.txn-tab.active, .calc-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border-color: var(--line);
}
.seg-toggle {
  display: inline-flex; gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
}
.seg-toggle > * {
  padding: 6px 12px;
  border: 0; border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font: inherit; font-size: 12.5px; font-weight: 700;
  cursor: pointer;
}
.seg-toggle > .active, .seg-toggle > [aria-pressed="true"], .seg-toggle input:checked + label {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}

/* =====================================================================
   20. CHART HELPERS (for hand-drawn SVG)
   Use fill="var(--chart-1)" etc. in inline SVG, or these classes.
   ===================================================================== */
.chart-grid line, line.chart-grid { stroke: var(--chart-grid); }
.chart-axis text, text.chart-axis { fill: var(--chart-axis); font-size: 11px; font-family: var(--font-family); }
.s1 { fill: var(--chart-1); stroke: var(--chart-1); } .s2 { fill: var(--chart-2); stroke: var(--chart-2); }
.s3 { fill: var(--chart-3); stroke: var(--chart-3); } .s4 { fill: var(--chart-4); stroke: var(--chart-4); }
.s5 { fill: var(--chart-5); stroke: var(--chart-5); } .s6 { fill: var(--chart-6); stroke: var(--chart-6); }
.s7 { fill: var(--chart-7); stroke: var(--chart-7); } .s8 { fill: var(--chart-8); stroke: var(--chart-8); }

/* =====================================================================
   21. MOTION
   ===================================================================== */
@keyframes tw-fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes tw-pop     { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes tw-grow    { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes tw-shimmer { from { transform: translateX(-120%); } to { transform: translateX(120%); } }
@keyframes tw-drift   { from { background-position: 0% 0%, 100% 100%, 0 0; } to { background-position: 100% 60%, 0% 40%, 0 0; } }

.tile, .card, .kind-card, .holding-card, .oblig, .vendor-card, .hub-tile { animation: tw-fade-up .4s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .kind-card:hover, .holding-card:hover, .oblig:hover, .vendor-card:hover, .ren-card:hover,
  .tile:hover, .hub-tile:hover, .paycard:hover { transform: none !important; }
}

/* =====================================================================
   22. THEME TOGGLE (optional helper for Settings / sidebar footer)
   <button class="theme-toggle" onclick="twToggleTheme()">…</button>
   ===================================================================== */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, .08);
  background: transparent;
  color: var(--side-text);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--side-hover); color: #fff; }

/* ---- FIX: keep uploaded card artwork visible (Tidewater .paycard background
   shorthand, appended above, otherwise clobbers .paycard-photo's --art; and the
   themed chip/sheen pseudo-elements must not overlay a real photo). ---- */
.paycard.paycard-photo { background: var(--art) center / cover no-repeat; }
.paycard.paycard-photo::before, .paycard.paycard-photo::after { content: none; display: none; }

/* ---- FIX: card-number overlay fit. Tidewater's broad `.paycard [class*="num"]`
   also matches `.paycard-photo-number`, blowing it up (16px/.14em) and overflowing
   the artwork — badly on portrait cards. Restore the tuned sizes (higher specificity). ---- */
.paycard.paycard-photo .paycard-photo-number { font-family: "Consolas","SF Mono",monospace; font-size: 15px; letter-spacing: .12em; white-space: nowrap; }
.paycard.paycard-portrait .paycard-photo-number { font-size: 9px; letter-spacing: .04em; }
