/* MSA Finance — 2026 UI */

:root {
    /* Vercel/Linear-neutral palette — clean, financial, no warmth */
    --bg: #F7F7F8;                /* cool off-white */
    --bg-2: #EFEFF1;
    --surface: #FFFFFF;
    --surface-2: #F4F4F5;         /* zinc-100 */
    --surface-3: #E4E4E7;         /* zinc-200 */
    --sidebar: #0A0A0A;           /* neutral near-black */
    --sidebar-hover: #1F1F22;

    --ink: #09090B;               /* zinc-950 */
    --ink-2: #27272A;             /* zinc-800 */
    --muted: #71717A;             /* zinc-500 */
    --muted-2: #A1A1AA;           /* zinc-400 */
    --line: rgba(9, 9, 11, 0.07);
    --line-strong: rgba(9, 9, 11, 0.13);

    /* Two accents: charcoal (CTA) + indigo (premium highlight) */
    --accent: #09090B;            /* CTA */
    --accent-ink: #FFFFFF;
    --highlight: #4F46E5;         /* indigo-600 — Linear-iris, premium */
    --highlight-2: #6366F1;       /* indigo-500 */
    --highlight-ink: #FFFFFF;
    --highlight-ring: rgba(79, 70, 229, 0.22);
    --highlight-soft: #EEF2FF;    /* indigo-50 */

    /* Semantic — clean financial */
    --pos: #16A34A;               /* emerald-600 */
    --pos-bg: #DCFCE7;            /* emerald-100 */
    --pos-line: #86EFAC;
    --neg: #DC2626;               /* red-600 */
    --neg-bg: #FEE2E2;
    --neg-line: #FCA5A5;
    --warn: #CA8A04;
    --warn-bg: #FEF9C3;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-2xl: 24px;

    /* Neutral shadows */
    --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.04);
    --shadow-md: 0 1px 3px rgba(9, 9, 11, 0.06), 0 6px 16px rgba(9, 9, 11, 0.05);
    --shadow-lg: 0 6px 12px rgba(9, 9, 11, 0.05), 0 16px 40px rgba(9, 9, 11, 0.08);
    --shadow-iris: 0 8px 24px -6px rgba(79, 70, 229, 0.45);

    --sidebar-w: 76px;

    /* Motion tokens — from Emil */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --dur-press: 130ms;
    --dur-fast: 180ms;
    --dur-med: 240ms;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
}

body { min-height: 100vh; }

/* ── Layout ─────────────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.side {
    background: var(--sidebar);
    color: #E5E7EB;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    gap: 8px;
}

.side .logo {
    width: 44px; height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #FFFFFF 0%, #E2E4EA 100%);
    color: #0F1115;
    display: grid; place-items: center;
    font-weight: 800; font-size: 18px;
    letter-spacing: -0.03em;
    margin-bottom: 22px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08);
}

.side .nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    width: 100%;
    align-items: center;
    padding: 0 12px;
}

.side .nav a,
.side .nav button {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: transparent;
    border: 0;
    color: #A5A2A0;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                transform var(--dur-press) var(--ease-out);
    position: relative;
    text-decoration: none;
    outline: none;
}

.side .nav a:hover,
.side .nav button:hover {
    background: var(--sidebar-hover);
    color: #FFFFFF;
}
.side .nav button:active { transform: scale(0.94); }
.side .nav button:focus-visible {
    box-shadow: 0 0 0 3px var(--highlight-ring);
}

.side .nav .nav-link.active {
    background: #FFFFFF;
    color: var(--ink);
    box-shadow: 0 6px 20px -6px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}
.side .nav .nav-link::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 50%;
    width: 3px; height: 22px;
    border-radius: 0 3px 3px 0;
    background: var(--highlight);
    box-shadow: 0 0 12px rgba(99,102,241,0.6);
    transform: translateY(-50%) scaleY(0.4);
    opacity: 0;
    transition: transform 220ms var(--ease-out), opacity 180ms var(--ease-out);
    transform-origin: left center;
}
.side .nav .nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
    opacity: 1;
}

.side .nav svg { width: 22px; height: 22px; stroke-width: 2; }

.side .foot {
    margin-top: auto;
    display: flex; flex-direction: column; gap: 8px; align-items: center;
}

.side .foot a {
    width: 48px; height: 48px;
    border-radius: 14px;
    color: #6B7280;
    display: grid; place-items: center;
    text-decoration: none;
    transition: all .15s ease;
}
.side .foot a:hover { background: var(--sidebar-hover); color: #FFFFFF; }
.side .foot svg { width: 22px; height: 22px; stroke-width: 2; }

/* ── Main ───────────────────────────────────────────────── */
.main {
    padding: 24px 32px 40px;
    max-width: 1600px;
    width: 100%;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.topbar .title {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0;
    color: var(--ink);
}

.topbar .sub {
    color: var(--muted);
    font-size: 13.5px;
    margin-top: 6px;
    letter-spacing: -0.005em;
}
.topbar .sub #fin-asof { color: var(--muted-2); }

.topbar .right {
    display: flex; align-items: center; gap: 10px;
}

.chip-user {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: transform var(--dur-press) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.chip-user:hover { box-shadow: var(--shadow-md); }
.chip-user:active { transform: scale(0.95); }
.chip-user .avatar {
    width: 30px; height: 30px; border-radius: 999px;
    background: linear-gradient(135deg, #0A0A0A, #3A3F4B);
    color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Section head ───────────────────────────────────────── */
.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 2px 14px;
    flex-wrap: wrap;
}
.section-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--ink);
}
.section-head p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.45;
    max-width: 640px;
}
.section-actions {
    display: flex; gap: 8px; align-items: center;
    flex-wrap: wrap;
}

.td-muted { color: var(--muted) !important; }

/* ── Buttons ────────────────────────────────────────────── */
.btn-x {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition: transform var(--dur-press) var(--ease-out),
                background var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    box-shadow: 0 1px 2px rgba(23,24,28,0.10), inset 0 1px 0 rgba(255,255,255,0.08);
    line-height: 1;
    text-decoration: none;
    outline: none;
}
.btn-x:hover { background: #22242B; color: var(--accent-ink); box-shadow: 0 4px 12px rgba(23,24,28,0.16), inset 0 1px 0 rgba(255,255,255,0.08); }
.btn-x:active { transform: scale(0.97); }
.btn-x:focus-visible { box-shadow: 0 0 0 3px var(--highlight-ring); }
.btn-x svg { width: 16px; height: 16px; stroke-width: 2.2; }

.btn-x.ghost {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
}
.btn-x.ghost:hover { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-md); }

.btn-icon {
    width: 40px; height: 40px;
    padding: 0;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    display: inline-grid; place-items: center;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out),
                transform var(--dur-press) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    box-shadow: var(--shadow-sm);
    outline: none;
}
.btn-icon:hover { background: var(--surface-2); box-shadow: var(--shadow-md); }
.btn-icon:active { transform: scale(0.94); }
.btn-icon:focus-visible { box-shadow: 0 0 0 3px var(--highlight-ring); }
.btn-icon svg { width: 18px; height: 18px; stroke-width: 2; transition: transform 220ms var(--ease-out); }
.btn-icon.spinning svg { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
    display: inline-flex;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 20px;
    gap: 2px;
    box-shadow: var(--shadow-sm);
}
.tabs button {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 9px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
    letter-spacing: -0.005em;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active {
    background: var(--ink);
    color: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.tabs button svg { width: 16px; height: 16px; stroke-width: 2; }

/* ── Cards / Panels ─────────────────────────────────────── */
.card-x {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.card-x.tight { padding: 16px 18px; }
.card-x.bare { padding: 0; overflow: hidden; }

.card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 14px;
}
.card-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.card-head .sub {
    color: var(--muted);
    font-size: 12.5px;
    margin-top: 3px;
    font-weight: 400;
    line-height: 1.45;
}

/* ── Accounts grid ──────────────────────────────────────── */
.acct-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.acct-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out);
    display: flex; flex-direction: column;
    min-height: 168px;
    position: relative;
    overflow: hidden;
}
@media (hover: hover) and (pointer: fine) {
    .acct-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 32px -8px rgba(23,24,28,0.12), 0 2px 6px rgba(23,24,28,0.05);
        border-color: var(--line-strong);
    }
}

.acct-card .row1 {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 14px;
}
.acct-card .name-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acct-card .icon-wrap {
    width: 36px; height: 36px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    display: grid; place-items: center;
    color: var(--ink);
    flex-shrink: 0;
}
.acct-card .icon-wrap svg { width: 16px; height: 16px; stroke-width: 2; }
.acct-card .icon-wrap .glyph {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--ink);
}
.acct-card .name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-card .cur {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 3px 7px;
    border-radius: 6px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.acct-card .bal {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.05;
    color: var(--ink);
    margin-top: auto;
}
.acct-card > svg { display: block; width: 100%; height: 28px; margin: 12px 0 6px; }
.acct-card .sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}
.acct-card.total {
    background: #0A0A0A;
    color: #FFFFFF;
    border-color: transparent;
    box-shadow: 0 12px 32px -8px rgba(9,9,11,0.35), var(--shadow-iris);
    position: relative;
    overflow: hidden;
}
.acct-card.total::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg, rgba(99,102,241,0.9), rgba(255,255,255,0.06) 45%, transparent 70%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
}
.acct-card.total::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(80% 60% at 100% 0%, rgba(99,102,241,0.28), transparent 60%),
        radial-gradient(60% 40% at 0% 100%, rgba(99,102,241,0.12), transparent 60%);
    pointer-events: none;
}
.acct-card.total .name,
.acct-card.total .bal { color: #FFFFFF; position: relative; z-index: 1; }
.acct-card.total .cur {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.14);
    position: relative; z-index: 1;
}
.acct-card.total .sub { color: rgba(255,255,255,0.55); position: relative; z-index: 1; }
.acct-card.total .icon-wrap {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.14);
    color: #FFFFFF;
    position: relative; z-index: 1;
}

/* ── KPI tiles ──────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
@media (max-width: 900px) { .kpi-grid { grid-template-columns: 1fr; } }

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 18px 22px;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 6px;
    min-height: 108px;
}
.tile .k {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0.01em;
    display: flex; align-items: center; gap: 8px;
}
.tile .k .badge-dot {
    width: 8px; height: 8px; border-radius: 999px;
    background: var(--muted);
}
.tile.pos .k .badge-dot { background: var(--pos); }
.tile.neg .k .badge-dot { background: var(--neg); }
.tile .v {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.05;
    color: var(--ink);
    margin-top: 6px;
}
.tile .v.pos { color: var(--pos); }
.tile .v.neg { color: var(--neg); }
.tile .m { font-size: 12.5px; color: var(--muted); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ── Flow chart panel ───────────────────────────────────── */
.plot {
    position: relative;
    overflow-x: auto;
    padding: 4px 0;
}
.plot svg { display: block; }
.legend {
    display: inline-flex; gap: 14px; align-items: center;
    font-size: 12px; color: var(--muted);
}
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .dot.pos { background: var(--pos); }
.legend .dot.neg { background: var(--neg); }

.fin-tip {
    position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s;
    background: #0F1115;
    color: #FFFFFF;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
    padding: 10px 12px;
    font-size: 12px;
    min-width: 170px;
    z-index: 5;
}
.fin-tip.on { opacity: 1; }
.fin-tip .text-muted { color: #9CA3AF !important; }
.fin-tip .pos { color: #34D399 !important; }
.fin-tip .neg { color: #F87171 !important; }

/* ── Ranked bars ────────────────────────────────────────── */
.ranked-row {
    display: grid;
    grid-template-columns: minmax(160px, 220px) 1fr auto;
    gap: 14px; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.ranked-row:last-child { border-bottom: 0; }
.ranked-row .small { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.ranked-track {
    height: 8px;
    background: #EDEEF1;
    border-radius: 999px;
    overflow: hidden;
}
.ranked-fill {
    height: 100%;
    background: linear-gradient(90deg, #F87171 0%, var(--neg) 100%);
    border-radius: 999px;
}
.ranked-row .num { font-size: 13.5px; font-weight: 600; color: var(--ink); }

/* ── Tables ─────────────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    background: var(--surface);
    margin: 0;
    color: var(--ink-2);
}
.table thead th,
.table th {
    text-align: left;
    padding: 12px 14px;
    background: var(--surface-2) !important;
    border-bottom: 1px solid var(--line);
    border-top: 0;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--muted) !important;
}
.table thead.table-dark th {
    background: var(--surface-2) !important;
    color: var(--muted) !important;
    border-bottom: 1px solid var(--line);
}
.table th.text-end,
.table td.text-end { text-align: right; }
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    border-top: 0;
    color: var(--ink-2);
    vertical-align: middle;
    transition: background-color 120ms var(--ease-out);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table.table-hover tbody tr:hover td,
.table tbody tr:hover td { background: var(--surface-2); }
.table code {
    font-family: var(--font-mono);
    font-size: 11.5px;
    background: var(--surface-2);
    color: var(--ink);
    padding: 2px 6px;
    border-radius: 5px;
    border: 1px solid var(--line);
}
.op-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-2);
    white-space: nowrap;
}
.lead-ref {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-2);
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table-wrap .table-scroll { overflow-x: auto; }

/* Bootstrap badge overrides (used by finance.js) */
.badge {
    display: inline-flex; align-items: center;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11.5px;
}
.badge.bg-success { background: var(--pos-bg) !important; color: var(--pos) !important; }
.badge.bg-warning { background: var(--warn-bg) !important; color: var(--warn) !important; }
.badge.bg-secondary { background: var(--surface-2) !important; color: var(--muted) !important; border: 1px solid var(--line); }
.badge.bg-light { background: var(--surface-2) !important; color: var(--muted) !important; border: 1px solid var(--line); }

/* ── Filters row ────────────────────────────────────────── */
.filter-row {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    margin-bottom: 16px;
}
.field {
    display: flex; flex-direction: column; gap: 6px;
    min-width: 140px;
}
.field.wide { min-width: 220px; flex: 1; }
.field.field-sm { min-width: 130px; max-width: 170px; }
.field.field-btn { min-width: auto; justify-content: flex-end; }
.field.field-btn button { height: 40px; }
.field label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
}
.field input,
.field select {
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    min-width: 100px;
    width: 100%;
}
.field input::placeholder { color: var(--muted-2); }
.field input:hover,
.field select:hover { border-color: rgba(23, 24, 28, 0.22); }
.field input:focus,
.field select:focus {
    border-color: var(--highlight-2);
    box-shadow: 0 0 0 3px var(--highlight-ring);
}
.field select { appearance: none; -webkit-appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%236B7280' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* ── Empty state ────────────────────────────────────────── */
.empty {
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-xl);
    padding: 40px;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
    font-size: 14px;
}

/* ── Info banner ────────────────────────────────────────── */
.info {
    background: linear-gradient(180deg, #F9FAFB 0%, #F3F4F6 100%);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--muted);
    display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 16px;
}
.info svg { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; margin-top: 2px; color: var(--ink); }

/* ── Modal overrides ────────────────────────────────────── */
.modal-content {
    border: 0;
    border-radius: var(--r-xl);
    box-shadow: 0 24px 64px rgba(0,0,0,0.15);
    background: var(--surface);
    font-family: var(--font-sans);
}
/* Override Bootstrap default slow ease-in on modal enter */
.modal.fade .modal-dialog {
    transition: transform var(--dur-med) var(--ease-out), opacity var(--dur-med) var(--ease-out);
    transform: translateY(-8px) scale(0.98);
    opacity: 0;
}
.modal.show .modal-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
}
.modal-backdrop.fade { transition: opacity 200ms var(--ease-out); }
.modal-backdrop.show { opacity: 0.42; }
.modal-header {
    border-bottom: 1px solid var(--line);
    padding: 20px 24px;
}
.modal-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.015em;
}
.modal-body { padding: 22px 24px; }
.modal-footer { border-top: 1px solid var(--line); padding: 16px 24px; gap: 8px; }
.modal-body .form-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
}
.modal-body .form-control,
.modal-body .form-select {
    height: 42px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    font-family: inherit;
    font-size: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: none;
}
.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: var(--highlight-2);
    box-shadow: 0 0 0 3px var(--highlight-ring);
    outline: none;
}
.modal-body input[type="date"].form-control,
.modal-body input[type="datetime-local"].form-control,
.modal-body input[type="time"].form-control {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    line-height: 40px;
}
.modal-body .form-text { font-size: 12px; color: var(--muted); margin-top: 5px; }

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
    border: 0;
    transition: transform var(--dur-press) var(--ease-out),
                background-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    outline: none;
}
.modal-footer .btn-primary:active,
.modal-footer .btn-secondary:active { transform: scale(0.97); }
.modal-footer .btn-primary:focus-visible,
.modal-footer .btn-secondary:focus-visible { box-shadow: 0 0 0 3px var(--highlight-ring); }

.modal-footer .btn-primary { background: var(--ink); color: #fff; }
.modal-footer .btn-primary:hover { background: #1F232B; }
.modal-footer .btn-secondary {
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line-strong);
}
.modal-footer .btn-secondary:hover { background: #EDEEF1; }

.modal-body .alert-danger {
    background: var(--neg-bg);
    color: var(--neg);
    border: 0;
    border-radius: 10px;
    font-size: 13px;
    padding: 10px 12px;
}

.alert.alert-light {
    background: linear-gradient(180deg, #F9FAFB 0%, #F3F4F6 100%);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--muted);
}

/* Inline action buttons inside operations table (from finance.js) */
.btn.btn-sm.btn-outline-success,
.btn.btn-sm.btn-outline-danger,
.op-post, .op-del {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: all .12s ease;
    padding: 0;
    color: var(--ink);
    font-weight: 700;
}
.btn.btn-sm.btn-outline-success,
.op-post { color: var(--pos); }
.btn.btn-sm.btn-outline-success:hover,
.op-post:hover { background: var(--pos-bg); border-color: var(--pos); color: var(--pos); }
.btn.btn-sm.btn-outline-danger,
.op-del { color: var(--neg); }
.btn.btn-sm.btn-outline-danger:hover,
.op-del:hover { background: var(--neg-bg); border-color: var(--neg); color: var(--neg); }

/* ── Login screen ───────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 600px at 90% -10%, rgba(15,17,21,0.06), transparent),
        radial-gradient(900px 500px at -10% 110%, rgba(15,17,21,0.05), transparent),
        var(--bg);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px 30px;
    box-shadow: var(--shadow-lg);
}
.login-card .brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 6px;
}
.login-card .brand .mark {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0F1115 0%, #3A3F4B 100%);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.login-card .brand .txt { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.login-card .brand .txt .muted { color: var(--muted); font-weight: 500; }
.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 20px 0 6px;
}
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .field input { width: 100%; height: 44px; }
.login-card .submit {
    margin-top: 8px;
    width: 100%;
    height: 46px;
    border: 0; border-radius: 12px;
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    font-size: 14.5px;
    cursor: pointer;
    transition: background .15s ease;
}
.login-card .submit:hover { background: #1F232B; }
.login-card .error {
    background: var(--neg-bg);
    color: var(--neg);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* Utility for JS toggling: preserve Bootstrap d-none */
.d-none { display: none !important; }

/* ── Hero balance ───────────────────────────────────────── */
.hero-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 32px;
    align-items: stretch;
    background:
        radial-gradient(120% 100% at 100% 0%, rgba(79,70,229,0.06), transparent 60%),
        var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-2xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.hero-main { min-width: 0; }
.hero-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    display: flex; gap: 10px; align-items: center;
}
.hero-hint {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    font-size: 12px;
    color: var(--muted-2);
}
.hero-value {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.02;
    color: var(--ink);
    margin: 10px 0 14px;
}
.hero-unit {
    font-size: 32px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: -0.02em;
    margin-left: 4px;
}
.hero-net {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px 6px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--muted);
}
.hero-net.pos { background: var(--pos-bg); color: var(--pos); border-color: transparent; }
.hero-net.neg { background: var(--neg-bg); color: var(--neg); border-color: transparent; }
.hero-net-num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.hero-net-lbl { color: currentColor; opacity: 0.7; font-weight: 500; }
.hero-arrow { display: inline-flex; width: 18px; height: 18px; }
.hero-arrow svg { width: 100%; height: 100%; }

.hero-meta {
    display: flex; flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding-left: 32px;
    border-left: 1px solid var(--line);
    min-width: 220px;
}
.hero-meta .meta-row {
    display: flex; justify-content: space-between; gap: 24px;
    font-size: 13px;
    padding: 6px 0;
}
.hero-meta .meta-k { color: var(--muted); }
.hero-meta .meta-v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-meta .meta-v.mono { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }

@media (max-width: 900px) {
    .hero-card { grid-template-columns: 1fr; gap: 20px; padding: 22px 22px; }
    .hero-meta { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
    .hero-value { font-size: 42px; }
    .hero-unit { font-size: 24px; }
}

/* ── Strip label — thin section divider ─────────────────── */
.strip-label {
    display: flex; align-items: center; gap: 14px;
    margin: 8px 2px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-weight: 600;
}
.strip-label .strip-line {
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* ── Illustrated empty state ────────────────────────────── */
.empty-illustrated {
    grid-column: 1 / -1;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 44px 24px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-xl);
    background: var(--surface);
    gap: 12px;
    color: var(--muted);
}
.empty-illustrated.compact { padding: 32px 20px; }
.empty-illustrated > svg {
    width: 56px; height: 56px;
    color: var(--muted-2);
    margin-bottom: 4px;
}
.empty-illustrated .empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.empty-illustrated .empty-sub {
    font-size: 13px;
    color: var(--muted);
    max-width: 400px;
    line-height: 1.5;
}
.empty-illustrated .empty-actions {
    margin-top: 8px;
    display: flex; gap: 8px;
}

.empty-inline {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 4px;
    color: var(--muted);
}
.empty-inline > svg {
    width: 40px; height: 40px;
    color: var(--muted-2);
    flex-shrink: 0;
}
.empty-inline-title {
    font-size: 13.5px; font-weight: 600; color: var(--ink); letter-spacing: -0.005em;
}
.empty-inline-sub {
    font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.5;
}

/* Spark empty */
.spark-empty { display: block; width: 100%; height: 28px; margin: 12px 0 6px; }

/* ── Reveal animations ──────────────────────────────────── */
@keyframes reveal-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
/* Only animate on first paint — protected by data-first attribute on grid parent */
[data-first="1"].acct-grid > .acct-card,
[data-first="1"].kpi-grid > .tile {
    animation: reveal-up 320ms var(--ease-out) both;
}
[data-first="1"].acct-grid > .acct-card:nth-child(1),
[data-first="1"].kpi-grid > .tile:nth-child(1) { animation-delay: 0ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(2),
[data-first="1"].kpi-grid > .tile:nth-child(2) { animation-delay: 30ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(3),
[data-first="1"].kpi-grid > .tile:nth-child(3) { animation-delay: 60ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(4) { animation-delay: 90ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(5) { animation-delay: 120ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(6) { animation-delay: 150ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(7) { animation-delay: 180ms; }
[data-first="1"].acct-grid > .acct-card:nth-child(8) { animation-delay: 210ms; }

/* Hero fade-in on first render only */
[data-first="1"] > .hero-card {
    animation: hero-in 320ms var(--ease-out) both;
}
@keyframes hero-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Ranked fill grows on first paint */
[data-first="1"] .ranked-fill {
    animation: rank-grow 520ms var(--ease-out) both;
    transform-origin: left center;
}
@keyframes rank-grow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
    [data-first="1"].acct-grid > .acct-card,
    [data-first="1"].kpi-grid > .tile,
    [data-first="1"] > .hero-card,
    [data-first="1"] .ranked-fill { animation: none; }
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Custom scrollbar (WebKit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15, 17, 21, 0.15); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(15, 17, 21, 0.25); }

/* Small responsive tweaks */
@media (max-width: 720px) {
    .main { padding: 16px 18px 32px; }
    .app-shell { grid-template-columns: 64px 1fr; }
    :root { --sidebar-w: 64px; }
    .topbar .title { font-size: 22px; }
    .tabs { flex-wrap: wrap; }
}
