/* ============================================================================
   Design system — dark, glass, indigo/violet.
   One file, no CDN: the server may sit behind a firewall, so everything
   (fonts, icons, effects) is local or system-provided.

   Sections
     01  Tokens
     02  Reset & base
     03  Layout shells
     04  Typography & utilities
     05  Buttons
     06  Form controls
     07  Cards & panels
     08  Stats
     09  Badges & pills
     10  Tables
     11  Empty / loading / skeleton
     12  Search, pagination, segmented
     13  Modal & dialog
     14  Toast & alerts
     15  Avatar
     16  Auth pages
     17  Sidebar & topbar
     18  Animations
     19  Responsive
   ========================================================================== */

/* -- 01  Tokens ----------------------------------------------------------- */
:root {
    /* Backdrop layers, darkest → lightest */
    --bg-void: #05060a;
    --bg-base: #0a0b12;
    --bg-raised: #10121b;
    --bg-overlay: #151824;

    /* Glass surfaces */
    --surface: rgba(255, 255, 255, .035);
    --surface-hover: rgba(255, 255, 255, .06);
    --surface-strong: rgba(255, 255, 255, .08);
    --surface-sunken: rgba(0, 0, 0, .25);

    /* Hairlines */
    --border: rgba(255, 255, 255, .08);
    --border-strong: rgba(255, 255, 255, .14);
    --border-focus: rgba(129, 140, 248, .55);

    /* Ink */
    --text: #e9eaf2;
    --text-dim: #a9adc4;
    --text-muted: #6f7492;
    --text-faint: #4d5270;

    /* Accents */
    --accent: #6366f1;
    --accent-hi: #818cf8;
    --accent-lo: #4f46e5;
    --violet: #a855f7;
    --sky: #38bdf8;
    --accent-glow: rgba(99, 102, 241, .35);
    --grad-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
    --grad-sheen: linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,0) 60%);

    /* Semantics */
    --ok: #34d399;
    --ok-bg: rgba(52, 211, 153, .12);
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, .12);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, .12);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, .12);

    /* Radii */
    --r-xs: 8px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-pill: 999px;

    /* Shadow */
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-md: 0 8px 24px -8px rgba(0, 0, 0, .55);
    --sh-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
    --sh-glow: 0 10px 30px -10px var(--accent-glow);
    --sh-inset: inset 0 1px 0 rgba(255, 255, 255, .05);

    /* Motion */
    --t-fast: .12s cubic-bezier(.4, 0, .2, 1);
    --t: .2s cubic-bezier(.4, 0, .2, 1);
    --t-slow: .35s cubic-bezier(.4, 0, .2, 1);

    /* Type */
    --font: "Inter", "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
            "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, "SF Mono",
                 Menlo, Consolas, monospace;

    /* Metrics */
    --sidebar-w: 248px;
    --topbar-h: 62px;
}

/* -- 02  Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "tnum" 0;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

/* The ambient light that makes the whole product feel like an app, not a page. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(900px 500px at 12% -8%, rgba(99, 102, 241, .16), transparent 60%),
        radial-gradient(800px 500px at 92% 4%, rgba(168, 85, 247, .13), transparent 60%),
        radial-gradient(1000px 700px at 50% 110%, rgba(56, 189, 248, .07), transparent 60%);
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 650;
    letter-spacing: -.02em;
    color: #fff;
}

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-hi); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: #a5b4fc; }

code, pre, .mono { font-family: var(--font-mono); font-variant-ligatures: none; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

::selection { background: rgba(99, 102, 241, .35); color: #fff; }

:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Scrollbars — thin, dark, unobtrusive. */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: var(--r-pill);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .22); background-clip: content-box; }

/* -- 03  Layout shells ---------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    padding: 26px 32px 56px;
    max-width: 1480px;
    width: 100%;
    animation: rise var(--t-slow) both;
}

.page-head { margin-bottom: 24px; }
.page-title { font-size: 1.6rem; font-weight: 680; letter-spacing: -.03em; margin: 0 0 6px; }
.page-sub { color: var(--text-muted); font-size: .9rem; margin: 0; max-width: 78ch; }

.stack { display: flex; flex-direction: column; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }

/* -- 04  Typography & utilities ------------------------------------------- */
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); font-size: .84em; letter-spacing: -.01em; }
.tiny { font-size: .78rem; }
.small { font-size: .85rem; }
.strong { font-weight: 620; }
.upper { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 640; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.grad-text {
    background: var(--grad-accent);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.row-end { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.fill { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 28px; height: 28px; }

/* -- 05  Buttons ---------------------------------------------------------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: .875rem;
    font-weight: 560;
    line-height: 1.2;
    letter-spacing: -.01em;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--t-fast), border-color var(--t-fast),
                transform var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
    user-select: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary {
    background: var(--grad-accent);
    color: #fff;
    box-shadow: var(--sh-glow), var(--sh-inset);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 14px 34px -10px var(--accent-glow), var(--sh-inset); color: #fff; }

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-dim);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

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

.btn-danger {
    background: var(--danger-bg);
    border-color: rgba(248, 113, 113, .28);
    color: #fca5a5;
}
.btn-danger:hover { background: rgba(248, 113, 113, .2); border-color: rgba(248, 113, 113, .5); color: #fecaca; }

.btn-ok {
    background: var(--ok-bg);
    border-color: rgba(52, 211, 153, .3);
    color: #6ee7b7;
}
.btn-ok:hover { background: rgba(52, 211, 153, .2); color: #a7f3d0; }

.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: var(--r-xs); gap: 6px; }
.btn-lg { padding: 12px 22px; font-size: .95rem; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; }
.btn-icon.btn-sm { padding: 4px; }

/* Loading: label fades, spinner takes the middle, width never jumps. */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

/* -- 06  Form controls ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label {
    font-size: .8rem;
    font-weight: 580;
    color: var(--text-dim);
    letter-spacing: -.005em;
}
.field .hint { font-size: .78rem; color: var(--text-muted); line-height: 1.5; }
.field .err { font-size: .78rem; color: var(--danger); }

.input, .select, textarea.input {
    width: 100%;
    padding: 10px 13px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: .875rem;
    line-height: 1.4;
    transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
    -webkit-appearance: none;
    appearance: none;
}

.input::placeholder { color: var(--text-faint); }
.input:hover, .select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, textarea.input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, .35);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}
.input.is-invalid { border-color: rgba(248, 113, 113, .6); }
.input:disabled { opacity: .55; cursor: not-allowed; }

/* Native select needs its own chevron once appearance is stripped. */
.select {
    padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236f7492' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    cursor: pointer;
}
.select option { background: var(--bg-overlay); color: var(--text); }

.input-icon { position: relative; display: block; }
.input-icon > .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
}
.input-icon .input { padding-left: 36px; }
.input-affix { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

.input-mono { font-family: var(--font-mono); letter-spacing: .06em; }

/* Password reveal: one button, two icons, CSS decides which is on show. */
[data-reveal] .i-off { display: none; }
[data-reveal].revealed .i-on { display: none; }
[data-reveal].revealed .i-off { display: inline-block; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .84rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}
.check input[type=checkbox] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: var(--surface-sunken);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.check input[type=checkbox]:checked {
    background: var(--accent) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 5'/%3E%3C/svg%3E") center/12px no-repeat;
    border-color: var(--accent);
}

/* -- 07  Cards & panels --------------------------------------------------- */
.card {
    position: relative;
    background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md), var(--sh-inset);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-head-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-title { font-size: .98rem; font-weight: 620; letter-spacing: -.015em; }
.card-sub { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot {
    padding: 13px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, .16);
}

.card-ico {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: var(--r-sm);
    background: rgba(99, 102, 241, .14);
    border: 1px solid rgba(99, 102, 241, .22);
    color: var(--accent-hi);
}

.card-hover { transition: border-color var(--t), transform var(--t), box-shadow var(--t); }
.card-hover:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--sh-lg); }

/* Inset well for keys, snippets, callouts */
.well {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
}
.well-accent {
    background: linear-gradient(135deg, rgba(99, 102, 241, .1), rgba(168, 85, 247, .06));
    border-color: rgba(129, 140, 248, .25);
}

/* Definition rows inside cards */
.dl { display: flex; flex-direction: column; }
.dl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
}
.dl-row:last-child { border-bottom: 0; padding-bottom: 0; }
.dl-row:first-child { padding-top: 0; }
.dl-row dt, .dl-key { color: var(--text-muted); }
.dl-row dd, .dl-val { margin: 0; text-align: right; color: var(--text); }

/* -- 08  Stats ------------------------------------------------------------ */
.stat {
    position: relative;
    padding: 18px 20px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015));
    box-shadow: var(--sh-md), var(--sh-inset);
    overflow: hidden;
    transition: border-color var(--t), transform var(--t);
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat::after {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-hi), transparent);
    opacity: .5;
}
.stat-k {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: .74rem;
    font-weight: 620;
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 10px;
}
.stat-v {
    font-size: 1.85rem;
    font-weight: 660;
    line-height: 1.1;
    letter-spacing: -.03em;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.stat-v small { font-size: .95rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0; margin-left: .32em; }
.stat-f { margin-top: 7px; font-size: .8rem; color: var(--text-muted); }
.stat-ok::after   { background: linear-gradient(90deg, transparent, var(--ok), transparent); }
.stat-warn::after { background: linear-gradient(90deg, transparent, var(--warn), transparent); }
.stat-bad::after  { background: linear-gradient(90deg, transparent, var(--danger), transparent); }

/* Thin progress meter used inside stats/cards */
.meter { height: 6px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .07); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--grad-accent); transition: width var(--t-slow); }
.meter-ok > i { background: linear-gradient(90deg, #10b981, #34d399); }
.meter-warn > i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.meter-bad > i { background: linear-gradient(90deg, #ef4444, #f87171); }

/* -- 09  Badges & pills --------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: .74rem;
    font-weight: 590;
    line-height: 1.5;
    letter-spacing: -.005em;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge-ok      { background: var(--ok-bg);     color: #6ee7b7; border-color: rgba(52, 211, 153, .22); }
.badge-danger  { background: var(--danger-bg); color: #fca5a5; border-color: rgba(248, 113, 113, .22); }
.badge-warn    { background: var(--warn-bg);   color: #fcd34d; border-color: rgba(251, 191, 36, .22); }
.badge-info    { background: var(--info-bg);   color: #93c5fd; border-color: rgba(96, 165, 250, .22); }
.badge-accent  { background: rgba(99, 102, 241, .14); color: #a5b4fc; border-color: rgba(129, 140, 248, .26); }
.badge-neutral { background: var(--surface); color: var(--text-muted); border-color: var(--border); }

.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-ok .dot { box-shadow: 0 0 8px currentColor; animation: pulse 2.4s ease-in-out infinite; }

/* -- 10  Tables ----------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }

table.tbl {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .86rem;
}

table.tbl th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    padding: 11px 14px;
    background: var(--bg-raised);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 640;
    text-transform: uppercase;
    letter-spacing: .07em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

table.tbl th.sortable { cursor: pointer; user-select: none; transition: color var(--t-fast); }
table.tbl th.sortable:hover { color: var(--text-dim); }
table.tbl th .sort-ind { margin-left: 5px; opacity: .35; font-size: .8em; }
table.tbl th.sorted { color: var(--accent-hi); }
table.tbl th.sorted .sort-ind { opacity: 1; }

table.tbl td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    vertical-align: middle;
    color: var(--text-dim);
}
table.tbl tbody tr { transition: background var(--t-fast); }
table.tbl tbody tr:hover td { background: rgba(255, 255, 255, .035); color: var(--text); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl td.actions { text-align: right; white-space: nowrap; }
table.tbl td .row-tight { justify-content: flex-end; }

/* Click-to-rename cell */
.editable-name {
    cursor: text;
    padding: 2px 5px;
    margin: -2px -5px;
    border-radius: 6px;
    border-bottom: 1px dashed transparent;
    color: var(--text);
    font-weight: 550;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.editable-name:hover { background: var(--surface); border-bottom-color: var(--accent-hi); color: #fff; }

/* Row actions stay quiet until the row is under the cursor — Linear-style. */
table.tbl .on-hover { opacity: 0; transition: opacity var(--t-fast); }
table.tbl tr:hover .on-hover, table.tbl tr:focus-within .on-hover { opacity: 1; }

/* Log viewer keeps its own scroll so the page never grows to 200 rows tall. */
.log-scroll { max-height: calc(100vh - 300px); min-height: 240px; overflow-y: auto; }
.log-scroll table.tbl td:last-child { color: var(--text-dim); }

/* -- 11  Empty / loading / skeleton --------------------------------------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 46px 24px;
    gap: 6px;
}
.empty-ico {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-faint);
    margin-bottom: 8px;
}
.empty h4 { font-size: .95rem; font-weight: 600; color: var(--text-dim); }
.empty p { font-size: .84rem; color: var(--text-muted); max-width: 42ch; margin: 0; }
.empty .btn { margin-top: 12px; }

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .18);
    border-top-color: var(--accent-hi);
    border-radius: 50%;
    animation: spin .65s linear infinite;
    flex: none;
}
.spinner-lg { width: 30px; height: 30px; border-width: 3px; }

.loading-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 42px;
    color: var(--text-muted);
    font-size: .85rem;
}

.skel {
    height: 12px;
    border-radius: var(--r-xs);
    background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.11) 37%, rgba(255,255,255,.05) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
}
.skel-row { display: flex; gap: 14px; padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.05); }
.skel-row .skel:nth-child(1) { flex: 2; }
.skel-row .skel:nth-child(2) { flex: 3; }
.skel-row .skel:nth-child(3) { flex: 1.4; }
.skel-row .skel:nth-child(4) { flex: 1; }

/* -- 12  Search, pagination, segmented ------------------------------------ */
.searchbox { position: relative; min-width: 210px; }
.searchbox .icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
}
.searchbox input {
    width: 100%;
    padding: 8px 32px 8px 34px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: .84rem;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.searchbox input::placeholder { color: var(--text-faint); }
.searchbox input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .14);
}
.searchbox .clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: grid;
    place-items: center;
}
.searchbox .clear:hover { color: var(--text); background: var(--surface); }

.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.segmented button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: .8rem;
    font-weight: 550;
    padding: 5px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
    white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-strong); color: #fff; box-shadow: var(--sh-sm); }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    font-size: .82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.pager-btns { display: flex; align-items: center; gap: 4px; }
.pager-btns button {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 560;
    border-radius: var(--r-xs);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.pager-btns button:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.pager-btns button.active { background: rgba(99, 102, 241, .18); border-color: rgba(129, 140, 248, .3); color: #c7d2fe; }
.pager-btns button:disabled { opacity: .3; cursor: default; }

/* -- 13  Modal & dialog --------------------------------------------------- */
.modal-scrim {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(3, 4, 8, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fade var(--t) both;
}
.modal {
    width: 100%;
    max-width: 470px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    animation: pop var(--t) both;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-head {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 20px 22px 0;
}
.modal-head .card-ico { margin-top: 1px; }
.modal-head h3 { font-size: 1.02rem; }
.modal-head .modal-x {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: grid;
    place-items: center;
}
.modal-head .modal-x:hover { color: var(--text); background: var(--surface); }
.modal-body { padding: 14px 22px 20px; overflow-y: auto; color: var(--text-dim); font-size: .88rem; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, .2);
}
.modal-danger .card-ico { background: var(--danger-bg); border-color: rgba(248, 113, 113, .26); color: #fca5a5; }

/* -- 14  Toast & alerts --------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--r-md);
    font-size: .85rem;
    border: 1px solid transparent;
    animation: rise var(--t) both;
}
.alert .icon { margin-top: 2px; flex: none; }
.alert-ok     { background: var(--ok-bg);     color: #a7f3d0; border-color: rgba(52, 211, 153, .25); }
.alert-danger { background: var(--danger-bg); color: #fecaca; border-color: rgba(248, 113, 113, .25); }
.alert-warn   { background: var(--warn-bg);   color: #fde68a; border-color: rgba(251, 191, 36, .25); }
.alert-info   { background: var(--info-bg);   color: #bfdbfe; border-color: rgba(96, 165, 250, .25); }

.toast-host {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 250px;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--sh-lg);
    font-size: .85rem;
    color: var(--text);
    animation: slide-in var(--t) both;
}
.toast .icon { flex: none; margin-top: 2px; }
.toast-ok .icon { color: var(--ok); }
.toast-danger .icon { color: var(--danger); }
.toast-info .icon { color: var(--info); }
.toast .toast-x {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}
.toast .toast-x:hover { color: var(--text); }

/* Blazor's own reconnect/error strip — styled instead of the default yellow bar,
   and hidden by default here (globally) so every layout gets the same behaviour. */
#blazor-error-ui {
    display: none;
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 400;
    padding: 12px 18px;
    background: var(--bg-overlay);
    border: 1px solid rgba(248, 113, 113, .4);
    border-radius: var(--r-md);
    box-shadow: var(--sh-lg);
    color: #fecaca;
    font-size: .85rem;
}
#blazor-error-ui a { color: #fff; text-decoration: underline; margin-left: 10px; cursor: pointer; }
#blazor-error-ui .dismiss { cursor: pointer; }

#components-reconnect-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    place-items: center;
    background: rgba(3, 4, 8, .8);
    backdrop-filter: blur(6px);
    color: var(--text);
    font-size: .9rem;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: grid; }

.blazor-error-boundary {
    background: var(--danger-bg);
    border: 1px solid rgba(248, 113, 113, .3);
    border-radius: var(--r-md);
    padding: 14px 18px;
    color: #fecaca;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

.validation-message { color: var(--danger); font-size: .8rem; }
.invalid { border-color: rgba(248, 113, 113, .6) !important; }

/* -- 15  Avatar ----------------------------------------------------------- */
.avatar {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 13px;
    font-weight: 640;
    font-size: .85rem;
    letter-spacing: -.02em;
    color: #fff;
    background: var(--grad-accent);
    box-shadow: var(--sh-inset), 0 6px 18px -8px var(--accent-glow);
    text-transform: uppercase;
    user-select: none;
}
.avatar-sm { width: 28px; height: 28px; border-radius: 9px; font-size: .72rem; }
.avatar-lg { width: 56px; height: 56px; border-radius: 18px; font-size: 1.2rem; }
.avatar-xl { width: 76px; height: 76px; border-radius: 24px; font-size: 1.7rem; }
.avatar-ring { box-shadow: 0 0 0 3px rgba(99, 102, 241, .18), 0 10px 30px -10px var(--accent-glow); }

.avatar .status {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2.5px solid var(--bg-base);
    background: var(--text-faint);
}
.avatar .status.on { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.avatar .status.off { background: var(--text-faint); }
.avatar-lg .status, .avatar-xl .status { width: 16px; height: 16px; }

/* -- 16  Auth pages ------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 34px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-lg), var(--sh-inset);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    animation: rise var(--t-slow) both;
}
.auth-card-wide { max-width: 470px; }

.auth-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 26px;
}
.auth-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--grad-accent);
    color: #fff;
    box-shadow: 0 10px 26px -10px var(--accent-glow), var(--sh-inset);
}
.auth-wordmark { font-size: .98rem; font-weight: 660; letter-spacing: -.02em; color: #fff; }
.auth-wordmark small { display: block; font-size: .72rem; font-weight: 500; color: var(--text-muted); letter-spacing: .04em; }

.auth-card h1 { font-size: 1.45rem; letter-spacing: -.03em; margin-bottom: 6px; }
.auth-card .auth-sub { color: var(--text-muted); font-size: .875rem; margin-bottom: 22px; }
.auth-foot {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: .83rem;
    color: var(--text-muted);
}

/* Download / setup card — same family as the auth card, wider. */
.dl-card {
    width: 100%;
    max-width: 620px;
    padding: 34px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-lg), var(--sh-inset);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    animation: rise var(--t-slow) both;
}
.dl-card h1 { font-size: 1.6rem; margin-bottom: 6px; }

/* ── FAQ ──────────────────────────────────────────────────────────────────
   Accordion rather than a wall of text: someone arriving with one problem
   should see eight headings, not eight answers. */
.faq { max-width: 720px; }
.faq-list { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }
.faq-list details {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: rgba(255, 255, 255, .02);
    transition: border-color var(--t-fast), background var(--t-fast);
}
.faq-list details[open] { background: rgba(255, 255, 255, .04); border-color: var(--border-strong); }
.faq-list summary {
    cursor: pointer;
    padding: 14px 16px;
    font-size: .94rem;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.faq-list summary::-webkit-details-marker { display: none; }
/* Chevron drawn in CSS so the page needs no icon component inside <summary>. */
.faq-list summary::before {
    content: "";
    width: 6px; height: 6px; flex: none;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: rotate(-45deg);
    transition: transform var(--t-fast);
}
.faq-list details[open] summary::before { transform: rotate(45deg); }
.faq-list summary:hover { color: var(--accent); }
.faq-list details > :not(summary) { padding: 0 16px; margin: 0 0 12px; }
.faq-list details p, .faq-list details ol { color: var(--text-secondary); font-size: .88rem; line-height: 1.55; }
.faq-list details ol { padding-left: 34px; }
.faq-list details li { margin-bottom: 6px; }
.dl-steps { margin-top: 26px; display: flex; flex-direction: column; gap: 18px; }
.dl-step { display: flex; gap: 14px; align-items: flex-start; }
.dl-step b { font-size: .92rem; font-weight: 600; color: var(--text); }
.dl-step p { margin: 4px 0 0; }
.dl-num {
    width: 26px;
    height: 26px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(99, 102, 241, .16);
    border: 1px solid rgba(129, 140, 248, .28);
    color: #c7d2fe;
    font-size: .78rem;
    font-weight: 650;
}

/* The invite key is the hero of registration — it gets its own treatment. */
.invite-field { position: relative; }
.invite-field .input {
    font-family: var(--font-mono);
    font-size: 1.02rem;
    letter-spacing: .16em;
    text-align: center;
    text-transform: uppercase;
    padding: 14px 13px;
    background: linear-gradient(135deg, rgba(99, 102, 241, .12), rgba(168, 85, 247, .08));
    border: 1px solid rgba(129, 140, 248, .35);
    border-radius: var(--r-md);
    color: #e0e7ff;
}
.invite-field .input::placeholder { letter-spacing: .16em; color: rgba(199, 210, 254, .3); }
.invite-field .input:focus {
    border-color: var(--accent-hi);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .18), 0 10px 30px -14px var(--accent-glow);
}
.invite-note {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin-top: 10px;
    padding: 11px 13px;
    border-radius: var(--r-sm);
    background: rgba(99, 102, 241, .07);
    border: 1px solid rgba(129, 140, 248, .18);
    font-size: .79rem;
    color: var(--text-dim);
    line-height: 1.5;
}
.invite-note .icon { color: var(--accent-hi); margin-top: 1px; flex: none; }

/* Account hero — the identity block at the top of the client area. */
.hero {
    position: relative;
    padding: 26px 28px;
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    background:
        radial-gradient(600px 200px at 0% 0%, rgba(99, 102, 241, .16), transparent 70%),
        linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015));
    box-shadow: var(--sh-md), var(--sh-inset);
    overflow: hidden;
}
.hero-id { display: flex; align-items: center; gap: 18px; }
.hero-name { font-size: 1.35rem; letter-spacing: -.03em; word-break: break-all; }
.hero-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.hero-meta > div { display: flex; flex-direction: column; gap: 3px; }
.hero-meta b { font-size: .9rem; font-weight: 570; color: var(--text); }

/* Activity feed */
.act { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.act li {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 0;
    font-size: .85rem;
    color: var(--text-dim);
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.act li:last-child { border-bottom: 0; padding-bottom: 0; }
.act li:first-child { padding-top: 0; }
.act-ico {
    width: 26px;
    height: 26px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Inline key chip */
.keycell {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--r-xs);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    color: var(--sky);
    font-size: .78rem;
}

/* -- 17  Sidebar & topbar ------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    background: rgba(8, 9, 15, .72);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 60;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px 20px;
}
.brand-mark {
    width: 32px;
    height: 32px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--grad-accent);
    color: #fff;
    box-shadow: 0 8px 20px -8px var(--accent-glow), var(--sh-inset);
}
.brand-name { font-size: .9rem; font-weight: 650; color: #fff; letter-spacing: -.015em; line-height: 1.2; }
.brand-name small { display: block; font-size: .68rem; font-weight: 500; color: var(--text-muted); letter-spacing: .05em; text-transform: uppercase; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    padding: 14px 12px 6px;
    font-size: .68rem;
    font-weight: 640;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-faint);
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 11px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: .875rem;
    font-weight: 520;
    text-decoration: none;
    transition: background var(--t-fast), color var(--t-fast);
}
.nav-link .icon { color: currentColor; opacity: .9; }
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, .2), rgba(99, 102, 241, .05));
    color: #fff;
    font-weight: 570;
}
.nav-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-hi);
    box-shadow: 0 0 12px var(--accent);
}
.nav-link .nav-tail { margin-left: auto; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 11, 18, .7);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.topbar-crumb { font-size: .84rem; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.topbar-crumb b { color: var(--text); font-weight: 560; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.userchip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: .82rem;
    color: var(--text-dim);
}

.sidebar-toggle { display: none; }

/* Live pill in the topbar / sidebar */
.livepill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: .76rem;
    color: var(--text-dim);
}
.livepill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2.4s ease-in-out infinite; }
.livepill.off .dot { background: var(--text-faint); box-shadow: none; animation: none; }

/* -- 18  Animations ------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* -- 19  Responsive ------------------------------------------------------- */
@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-content { padding: 22px 22px 48px; }
    .topbar { padding: 0 22px; }
}

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform var(--t);
        box-shadow: var(--sh-lg);
        background: var(--bg-raised);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(3, 4, 8, .6);
    }
    .sidebar-toggle { display: inline-flex; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
    .app-content { padding: 18px 16px 40px; }
    .topbar { padding: 0 16px; }
    .page-title { font-size: 1.3rem; }
    .auth-card { padding: 26px 22px; }
    .card-body { padding: 16px; }
    .dl-row { flex-direction: column; align-items: flex-start; gap: 3px; }
    .dl-row dd, .dl-val { text-align: left; }
}
