@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fredoka:wght@500;600;700&family=Shrikhand&family=Pacifico&family=Bungee&family=Righteous&family=Major+Mono+Display&display=swap');

/* Optional self-hosted brand faces. Only use local() so missing files under
   /public/fonts never 404 in DevTools. Drop licensed files into /public/fonts
   and restore url('/fonts/…') sources when you have them.
   Wordmarks fall back to Shrikhand (loaded from Google Fonts above). */
@font-face {
    font-family: 'Griaste';
    src: local('Griaste');
    font-display: optional;
}
@font-face {
    font-family: 'Flying Bird';
    src: local('Flying Bird'), local('FlyingBird');
    font-display: optional;
}
@font-face {
    font-family: 'Tamaen';
    src: local('Tamaen');
    font-display: optional;
}

/* ---------------------------------------------------------------------------
   Minimal dark theme. Flat surfaces, hairline borders, one quiet accent,
   no gradients, no shadows, no decoration that doesn't carry information.
--------------------------------------------------------------------------- */

:root {
    /* shadcn/ui "dashboard-05" — neutral zinc surfaces on a near-black
       background with a single green primary. Hairline borders, muted panels,
       gentle 1px shadows; no gradients or glow bleed. */
    --bg: #09090b;             /* zinc-950 — app background */
    --surface: #0f0f11;        /* card surface */
    --surface-2: #18181b;      /* zinc-900 — muted / secondary */
    --surface-3: #27272a;      /* zinc-800 — hover / inputs */
    --border: #232326;         /* hairline */
    --border-strong: #3f3f46;  /* zinc-700 */
    --text: #fafafa;           /* zinc-50 */
    --text-muted: #a1a1aa;     /* zinc-400 */
    --text-faint: #71717a;     /* zinc-500 */
    --accent: #5ee88a;         /* primary green */
    --accent-2: #37c96b;
    --accent-ink: #05200e;     /* ink on green */
    --cream: #5ee88a;
    --focus: #5ee88a;
    --success: #4ade80;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #60a5fa;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --font-display: 'Griaste', 'Shrikhand', cursive;
    --radius: 12px;
    --radius-sm: 8px;
    --ease: cubic-bezier(.22, 1, .3, 1);
    /* shadcn-flat elevation — barely-there 1px shadows */
    --hard: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px -1px rgba(0, 0, 0, 0.5);
    --hard-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --hard-light: 0 1px 3px rgba(94, 232, 138, 0.16);
    --glow: 0 0 0 1px rgba(94, 232, 138, 0.28);
    --sidebar-w: 256px;
}

/* ---------------------------------------------------------------------------
   Product logo lockups — one Authsy mark + wordmark (Griaste) constant across
   the suite, with each product's name set in the fun Fredoka face and its own
   accent. Use: <span class="plogo plogo-keys"> … </span>.
--------------------------------------------------------------------------- */
.plogo { --pa: var(--accent); display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.plogo .plogo-mark {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--pa);
    color: #0a0f0a; border: 0;
    font-family: 'Griaste', 'Shrikhand', cursive;
    font-size: 20px; line-height: 1;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--pa) 40%, transparent), 0 6px 16px -8px var(--pa);
}
.plogo .plogo-mark svg { width: 20px; height: 20px; }
.plogo-text { display: flex; flex-direction: column; gap: 2px; line-height: 1; min-width: 0; }
.plogo .plogo-authsy {
    font-family: 'Griaste', 'Shrikhand', cursive;
    font-weight: 400; font-size: 19px; letter-spacing: .01em; color: var(--text); line-height: 1;
}
.plogo .plogo-product {
    font-family: 'Fredoka', 'Inter', sans-serif;
    font-weight: 600; font-size: 13px; letter-spacing: .01em;
    color: var(--pa); line-height: 1; white-space: nowrap; text-transform: none;
}
/* horizontal one-liner variant (Authsy · Product on a single row) */
.plogo-inline .plogo-text { flex-direction: row; align-items: baseline; gap: 7px; }
.plogo-inline .plogo-product { font-size: 17px; }
/* size modifiers */
.plogo-lg .plogo-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 26px; }
.plogo-lg .plogo-authsy { font-size: 25px; }
.plogo-lg .plogo-product { font-size: 17px; }
/* per-product accents + each product name in its own display font */
.plogo-authsy-brand { --pa: #5ee88a; --pf: 'Fredoka', sans-serif; }
.plogo-licensing    { --pa: #5ee88a; --pf: 'Flying Bird', 'Pacifico', cursive; }
.plogo-keys         { --pa: #fbbf24; --pf: 'Bungee', 'Fredoka', sans-serif; }
.plogo-pay          { --pa: #38bdf8; --pf: 'Tamaen', 'Righteous', sans-serif; }
.plogo-decompiler,
.plogo-rodecomp     { --pa: #4ea1ff; --pf: 'Major Mono Display', 'Fredoka', monospace; }
/* the product name adopts the product's own face; the Authsy wordmark stays Griaste */
.plogo .plogo-product { font-family: var(--pf, 'Fredoka', sans-serif); }
/* small optical-size nudges so the very different faces sit on one baseline */
.plogo-licensing .plogo-product { font-size: 16px; font-weight: 400; }
.plogo-lg.plogo-licensing .plogo-product { font-size: 21px; }
.plogo-keys .plogo-product { font-size: 12px; letter-spacing: 0; }
.plogo-lg.plogo-keys .plogo-product { font-size: 15px; }
.plogo-pay .plogo-product { font-size: 14px; }
.plogo-lg.plogo-pay .plogo-product { font-size: 18px; }
.plogo-decompiler .plogo-product { font-size: 12px; letter-spacing: -.02em; }
.plogo-lg.plogo-decompiler .plogo-product { font-size: 15px; }

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

html, body {
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

::selection { background: #333; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--accent);
    border-color: transparent;
    color: var(--accent-ink);
    font-weight: 600;
    box-shadow: var(--hard-sm);
}
.btn-primary:hover { background: #74ee9c; }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { border-color: var(--danger); background: transparent; }
.btn-warning { color: var(--warning); border-color: var(--border-strong); }
.btn-warning:hover { border-color: var(--warning); background: transparent; }
.btn-success { color: var(--success); border-color: var(--border-strong); }
.btn-success:hover { border-color: var(--success); background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; border-color: var(--border-strong); }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent-2); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 500; color: var(--text-muted); font-size: 12px; margin-bottom: 14px; }
.label-hint { font-weight: 400; color: var(--text-faint); }
input, select, textarea {
    width: 100%;
    margin-top: 6px;
    padding: 8px 11px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    transition: border-color .12s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94, 232, 138, 0.18); }
input::placeholder { color: var(--text-faint); }
select option { background: var(--surface); color: var(--text); }
textarea { font-family: var(--font-mono); font-size: 12px; resize: vertical; line-height: 1.6; }
.value-cell {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.form-row { display: flex; gap: 12px; }
.form-row label { flex: 1; }

/* ---------- Auth screen ---------- */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    background:
        radial-gradient(130% 70% at 50% -10%, rgba(94, 232, 138, 0.1), transparent 55%),
        var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    padding: 38px 34px 30px;
    box-shadow: 0 40px 90px -34px rgba(0, 0, 0, 0.92), 0 0 0 1px rgba(255, 255, 255, 0.03);
    overflow: hidden;
}
/* hairline emerald accent along the top edge */
.auth-card::before {
    content: '';
    position: absolute; top: 0; left: 22%; right: 22%; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: .8;
}
.auth-brand { text-align: center; margin-bottom: 26px; }
/* the ⬡ logo box is retired; keep the rule harmless if markup still has it */
.auth-logo { display: none; }
.auth-brand h1 {
    font-family: 'Griaste', 'Shrikhand', cursive;
    font-weight: 400;
    font-size: 46px;
    letter-spacing: .01em;
    line-height: 1;
    position: relative;
    display: inline-block;
}
.auth-brand h1::after {
    content: '';
    position: absolute; right: -12px; bottom: 8px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 14px 2px rgba(94, 232, 138, 0.6);
}
.auth-brand p { color: var(--text-muted); margin-top: 12px; line-height: 1.55; font-size: 13px; }
/* segmented-pill tab switch */
.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 24px;
}
.auth-tab {
    flex: 1;
    padding: 9px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: color .15s ease, background .15s ease;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { color: var(--accent-ink); background: var(--accent); }
.auth-fineprint { color: var(--text-faint); font-size: 11px; line-height: 1.5; margin-top: 14px; text-align: center; }
.auth-error { margin-top: 14px; color: var(--danger); text-align: center; font-weight: 500; }

/* ---------- Portal layout — shadcn "dashboard-05" left sidebar + inset main ---------- */
.portal {
    display: flex;
    flex-direction: row;
    height: 100vh;
}
/* Collapsible left rail. Fixed width, hairline right border, muted surface. */
.sidebar {
    flex: none;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 14px 12px;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}
/* Brand block — logo puck + wordmark, top of the rail. */
.brand-wrapper { display: flex; align-items: center; gap: 10px; padding: 8px 8px 14px; flex: none; }
.brand-mark {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid transparent;
    background: var(--accent);
    border-radius: 9px;
    font-size: 15px;
    color: var(--accent-ink);
}
.brand-name {
    font-family: 'Griaste', 'Shrikhand', cursive;
    font-weight: 400;
    font-size: 22px;
    letter-spacing: .01em;
    line-height: 1;
}
.brand-tag {
    font-family: var(--font-mono);
    font-size: 8.5px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    align-self: center;
}
/* Vertical nav list. */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 4px 0;
}
.nav-item-return {
    margin-top: 6px;
    color: var(--text-faint);
}
.nav-item-return:hover { color: var(--text); }
/* category headings between nav groups (shadcn sidebar group labels) */
.nav-group-label {
    padding: 14px 10px 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-faint);
}
/* shadcn nav row: icon + label, subtle rounded, muted → active = secondary fill */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    text-decoration: none;
    transition: color .15s ease, background .15s ease;
}
.nav-item .nav-ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.nav-item .nav-ico svg { width: 16px; height: 16px; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
/* active = foreground text on a muted secondary surface (shadcn sidebar item) */
.nav-item.active { color: var(--text); background: var(--surface-3); font-weight: 550; }
.nav-item.active .nav-ico { color: var(--accent); }
.sidebar-nav.fx-navpill-on .nav-item.active { background: transparent; border-color: transparent; }
/* Footer — user profile block pinned to the bottom of the rail. */
.sidebar-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex: none;
    margin-top: auto;
    padding: 10px 8px 4px;
    border-top: 1px solid var(--border);
}
.tenant-chip { display: flex; flex-direction: column; gap: 1px; padding: 0; text-align: left; min-width: 0; flex: 1; order: 2; }
.tenant-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-plan { color: var(--text-faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* avatar puck to the left of the name */
.sidebar-footer::before {
    content: '';
    width: 32px; height: 32px; flex: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(150deg, var(--accent), var(--accent-2));
    order: 1;
}
.sidebar-footer .btn { order: 3; }

.main {
    flex: 1;
    overflow-y: auto;
    padding: 0 32px 64px;
    background-color: var(--bg);
}
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 18px 0 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.section-head h2 {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 20px;
    letter-spacing: -.02em;
    line-height: 1.2;
    color: var(--text);
}
.section-sub { color: var(--text-muted); }
.section-note { color: var(--text-muted); line-height: 1.6; margin-bottom: 18px; max-width: 720px; }
.section-note code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text);
    background: var(--surface-2);
    border-radius: 4px;
    padding: 1px 5px;
}
.section-note strong { color: var(--text); font-weight: 600; }

/* ---------- Panels & tables ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--hard-sm);
}
.panel-head { margin: 0 0 16px; }
.panel-head h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.panel-head .label-hint { display: block; margin-top: 4px; font-weight: 400; }
.panel-head-row .label-hint::before, .panel-head .label-hint::before { content: none; }
.panel-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.url-cell {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.url-cell:hover { color: var(--text); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 6px 14px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.table tbody td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }
.table .empty { color: var(--text-faint); text-align: center; padding: 36px 10px; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.key-cell { font-family: var(--font-mono); font-size: 12px; cursor: pointer; }
.key-cell:hover { color: #ffffff; }

/* Status — soft tinted pills. */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: capitalize;
    color: var(--text-muted);
    padding: 3px 10px 3px 8px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-faint);
    flex: none;
}
.badge-active    { color: var(--success); background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.25); }
.badge-active::before    { background: var(--success); }
.badge-suspended { color: var(--warning); background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.25); }
.badge-suspended::before { background: var(--warning); }
.badge-revoked   { color: var(--danger); background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.25); }
.badge-revoked::before   { background: var(--danger); }
.badge-expired::before   { background: var(--text-faint); }
.badge-archived::before  { background: var(--text-faint); }
.badge-client    { color: var(--info); background: rgba(96, 165, 250, 0.1); border-color: rgba(96, 165, 250, 0.25); }
.badge-client::before    { background: var(--info); }
.badge-manage    { color: #a78bfa; background: rgba(167, 139, 250, 0.1); border-color: rgba(167, 139, 250, 0.25); }
.badge-manage::before    { background: #a78bfa; }
.badge-type { color: var(--text-muted); background: transparent; border-color: transparent; padding-left: 0; }
.badge-type::before { display: none; }

/* ---------- Stats — shadcn KPI cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    box-shadow: var(--hard-sm);
    transition: border-color .2s ease, box-shadow .2s ease;
    overflow: hidden;
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card.featured { border-color: rgba(94, 232, 138, 0.4); }
/* header row: label on the left, muted icon top-right (shadcn card action) */
.stat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.stat-label { order: 1; flex: 1; min-width: 0; color: var(--text-muted); font-size: 13px; font-weight: 500; }
.stat-ico {
    order: 2;
    width: 30px; height: 30px;
    flex: none;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.stat-card.featured .stat-ico { background: rgba(94, 232, 138, 0.12); border-color: rgba(94, 232, 138, 0.3); color: var(--accent); }
.stat-ico svg { width: 16px; height: 16px; }
.stat-value {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    font-size: 32px;
    font-weight: 700;
    margin: 2px 0 12px;
    letter-spacing: -.03em;
    line-height: 1.05;
    color: var(--text);
}
.stat-limit { color: var(--text-faint); font-size: 12px; margin-top: 8px; }
.meter { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 100px; transition: width .3s ease; }
.meter-fill.warn { background: var(--warning); }
.meter-fill.crit { background: var(--danger); }

/* ---------- LuaU obfuscator (Key System) ---------- */
.obf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.obf-grid textarea { font-size: 11.5px; line-height: 1.5; white-space: pre; overflow: auto; }
@media (max-width: 900px) { .obf-grid { grid-template-columns: 1fr; } }

/* ---------- Filters & pager ---------- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { width: auto; margin-top: 0; min-width: 160px; border-radius: 100px; padding-left: 16px; padding-right: 16px; background: var(--surface); }
.filter-bar input[type="search"] { flex: 1; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 12px; color: var(--text-faint); }

/* ---------- Secret row / plans ---------- */
.secret-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.secret-value {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 9px 12px;
    flex: 1;
    min-width: 240px;
    overflow-x: auto;
    white-space: nowrap;
}
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.plan-card {
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    padding: 16px;
    background: var(--surface);
    box-shadow: var(--hard-sm);
}
.plan-card.current { border-color: rgba(94, 232, 138, 0.45); box-shadow: var(--glow); }
.plan-price { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.plan-current-tag { color: var(--accent); }
.plan-name { font-weight: 600; font-size: 14px; }
.plan-price { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0; }
.plan-price small { font-size: 11px; color: var(--text-faint); font-weight: 400; }
.plan-feats { list-style: none; color: var(--text-muted); line-height: 1.9; }
.plan-current-tag { color: var(--text-muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Modals ---------- */
.modal {
    /* The global `* { margin:0 }` reset strips the UA dialog's margin:auto,
       which is what centres a showModal() dialog — restore it here. */
    margin: auto;
    position: fixed;
    inset: 0;
    border: 2px solid #4a4a4a;
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    padding: 24px;
    width: min(480px, calc(100vw - 32px));
    box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: modal-pop .16s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes modal-pop {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Entrance motion (login / reload) ---------- */
@keyframes fade-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* Auth screen rises in on load / when returning to it. */
.auth-screen:not(.hidden) .auth-card { animation: fade-rise .5s cubic-bezier(.2, .8, .25, 1) both; }
.auth-screen:not(.hidden) .auth-brand { animation: fade-rise .5s cubic-bezier(.2, .8, .25, 1) .06s both; }
.auth-screen:not(.hidden) .auth-form { animation: fade-in .6s ease .12s both; }

/* Portal shell animates in after sign-in / on reload. */
.portal:not(.hidden) .sidebar { animation: slide-in-left .45s cubic-bezier(.2, .8, .25, 1) both; }
.portal:not(.hidden) .nav-item { animation: fade-rise .4s ease both; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(1) { animation-delay: .10s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(2) { animation-delay: .14s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(3) { animation-delay: .18s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(4) { animation-delay: .22s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(5) { animation-delay: .26s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(6) { animation-delay: .30s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(7) { animation-delay: .34s; }
.portal:not(.hidden) .sidebar-nav .nav-item:nth-child(8) { animation-delay: .38s; }
.portal:not(.hidden) .main { animation: fade-in .5s ease .1s both; }

/* Section content: header + cards stagger in when a section becomes active. */
.section:not(.hidden) > .section-head { animation: fade-rise .4s ease both; }
.section:not(.hidden) .stat-card { animation: pop-in .42s cubic-bezier(.2, .8, .25, 1) both; }
.section:not(.hidden) .stat-grid .stat-card:nth-child(2) { animation-delay: .06s; }
.section:not(.hidden) .stat-grid .stat-card:nth-child(3) { animation-delay: .12s; }
.section:not(.hidden) .stat-grid .stat-card:nth-child(4) { animation-delay: .18s; }
.section:not(.hidden) .stat-grid .stat-card:nth-child(5) { animation-delay: .24s; }
.section:not(.hidden) .panel { animation: fade-rise .45s ease .08s both; }

@media (prefers-reduced-motion: reduce) {
    .auth-screen .auth-card, .auth-brand, .auth-form,
    .portal .sidebar, .portal .nav-item, .portal .main,
    .section > .section-head, .section .stat-card, .section .panel,
    .modal { animation: none !important; }
}
.modal h3 { font-family: var(--font-sans); font-weight: 700; font-size: 22px; letter-spacing: -.02em; }
.modal-wide { width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0, 0, 0, 0.7); }
.modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; letter-spacing: -.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-actions-split { justify-content: space-between; }
.modal-actions-split > div { display: flex; gap: 8px; flex-wrap: wrap; }
.key-list {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px;
    max-height: 240px;
    overflow: auto;
    line-height: 1.9;
    user-select: all;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}
.detail-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.detail-item .k { color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.detail-item .v { font-weight: 600; margin-top: 3px; word-break: break-all; }

/* ---------- Toasts ---------- */
.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}
.toast {
    background: var(--surface);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-weight: 500;
    font-size: 12px;
    max-width: 360px;
    animation: toast-in .15s ease;
    box-shadow: var(--hard-sm);
}
.toast.error { color: var(--danger); }
.toast.success { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Charts ---------- */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-fig { margin: 0; }
.chart-fig figcaption { color: var(--text-muted); font-size: 12px; font-weight: 500; margin-bottom: 8px; }
.chart svg { display: block; width: 100%; height: 120px; }
.chart-empty {
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-faint);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
    background: repeating-linear-gradient(-45deg, transparent 0 7px, rgba(255, 255, 255, 0.012) 7px 14px);
}
.chart-empty svg { width: 20px; height: 20px; color: var(--accent); opacity: .8; }

/* ---------- Overview: onboarding + resources ---------- */
.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; align-items: start; }
.checklist { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    transition: border-color .12s ease, transform .12s ease;
}
.check-item:hover { border-color: var(--border-strong); transform: translateX(2px); }
.check-mark {
    width: 22px; height: 22px;
    flex: none;
    display: grid; place-items: center;
    border-radius: 999px;
    border: 2px solid var(--border-strong);
    color: var(--text-faint);
    font-size: 12px;
}
.check-item.done .check-mark { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check-body { flex: 1; }
.check-title { font-weight: 600; font-size: 13px; }
.check-item.done .check-title { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--text-faint); }
.check-sub { color: var(--text-faint); font-size: 11px; margin-top: 1px; }
.check-item .btn { flex: none; }
.res-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.res-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.res-link:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.res-link svg { width: 16px; height: 16px; flex: none; color: var(--accent); }
.res-link .res-arrow { margin-left: auto; color: var(--text-faint); }
.chart-tooltip {
    position: fixed;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 12px;
    pointer-events: none;
    z-index: 500;
    white-space: nowrap;
}
.chart-tooltip strong { display: block; }

/* ---------- Security / team rows ---------- */
.security-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; color: var(--text-muted); }
.security-row strong { color: var(--text); font-weight: 600; }

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

@media (max-width: 800px) {
    .sidebar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
    .sidebar-nav { order: 3; width: 100%; margin: 0; justify-content: flex-start; }
    .brand-wrapper { flex: 1; }
    .main { padding: 20px 16px 48px; }
    .form-row { flex-direction: column; gap: 0; }
    .tenant-chip { max-width: 120px; }
}

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

/* ---------- Hand-drawn icon treatment ----------
   A subtle turbulence displacement makes the geometric line icons read as
   sketched by hand. Filter def lives inline in each portal page (#handdrawn). */
.nav-ico,
.stat-ico svg,
.product-ico svg,
.res-link svg,
.section-head h2 + * svg { filter: url(#handdrawn); }
@media (prefers-reduced-motion: reduce) { .nav-ico, .stat-ico svg, .product-ico svg, .res-link svg { filter: none; } }

/* ---------- Social login ---------- */
.social-sep { display: flex; align-items: center; gap: 10px; color: var(--text-faint); font-size: 11px; margin: 4px 0 14px; }
.social-sep::before, .social-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.social-btns { display: flex; flex-direction: column; gap: 10px; }
.social-btn { gap: 8px; text-decoration: none; }
