/* ==========================================================================
   Client portal design system — v1
   Fonts: "Sora" (display) + "Inter" (text) + "JetBrains Mono" (numbers/code)
   ========================================================================== */

:root {
    --font-display: "Sora", "Inter", system-ui, sans-serif;
    --font-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --bg: #f5f6fa;
    --bg-elev: #ffffff;
    --bg-soft: #f8f9fc;
    --bg-muted: #eef0f6;
    --line: #e6e8f0;
    --line-strong: #d5d9e6;

    --ink: #0f1222;
    --ink-2: #3a3f55;
    --ink-3: #6b7089;
    --ink-4: #9aa0b8;

    --brand: #5b5bd6;
    --brand-2: #7c5cff;
    --brand-ink: #3f3fb8;
    --brand-soft: #eeeefc;
    --brand-soft-2: #e3e3fb;
    --brand-grad: linear-gradient(135deg, #5b5bd6 0%, #7c5cff 55%, #a855f7 100%);

    --lime: #c5f35b;
    --lime-ink: #3f5a00;

    --ok: #16a34a;      --ok-soft: #e8f8ee;   --ok-ink: #14532d;
    --warn: #d97706;    --warn-soft: #fff4e0; --warn-ink: #7c3e00;
    --bad: #dc2626;     --bad-soft: #fdeaea;  --bad-ink: #7f1d1d;
    --info: #0284c7;    --info-soft: #e6f4fd; --info-ink: #0c4a6e;

    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    --shadow-sm: 0 1px 2px rgba(15, 18, 34, .05);
    --shadow: 0 1px 2px rgba(15, 18, 34, .04), 0 8px 24px -12px rgba(15, 18, 34, .18);
    --shadow-lg: 0 12px 40px -12px rgba(15, 18, 34, .25);
    --glow: 0 10px 30px -10px rgba(91, 91, 214, .55);

    --sidebar-w: 256px;
    --topbar-h: 64px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-text);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--ink);
    letter-spacing: -0.015em;
    margin: 0;
    line-height: 1.2;
}

h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; }

p { margin: 0; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
small, .small { font-size: 12.5px; }
.muted { color: var(--ink-3); }
.faint { color: var(--ink-4); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

::selection { background: var(--brand-soft-2); color: var(--brand-ink); }

/* ----- App shell ---------------------------------------------------------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .22s ease;
}

body.nav-collapsed .app { grid-template-columns: 76px 1fr; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #0f1222;
    color: #c7cbe0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar::before {
    content: "";
    position: absolute;
    inset: -40% -40% auto;
    height: 60%;
    background: radial-gradient(closest-side, rgba(124, 92, 255, .35), transparent 70%);
    pointer-events: none;
}

.sidebar-brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 18px 14px;
    color: #fff;
    text-decoration: none;
    min-height: var(--topbar-h);
}

.sidebar-brand:hover { text-decoration: none; }

.logo-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--brand-grad);
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    box-shadow: var(--glow);
    flex-shrink: 0;
}


img.logo-mark {
    background: none;
    box-shadow: none;
    border-radius: 8px;
    object-fit: contain;
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.logo-text small {
    display: block;
    font-family: var(--font-text);
    font-weight: 500;
    font-size: 11px;
    color: #8b90ab;
    letter-spacing: .02em;
    margin-top: 1px;
}

.nav {
    position: relative;
    padding: 6px 12px 12px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #6a6f8c;
    padding: 14px 10px 6px;
    white-space: nowrap;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 10px;
    color: #b5bad3;
    font-weight: 500;
    font-size: 13.5px;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease;
    position: relative;
}

.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(124, 92, 255, .18); color: #fff; }
.nav a.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--lime);
}
.nav a .nav-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
    padding: 2px 7px;
    color: #d7daea;
}

.sidebar-foot {
    position: relative;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.credit-box {
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 12px;
    padding: 12px;
    color: #fff;
}

.credit-box .cb-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #9fa4c0;
    white-space: nowrap;
}

.credit-box .cb-num {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin: 4px 0 8px;
    white-space: nowrap;
}

.credit-box .bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.credit-box .bar i { display: block; height: 100%; background: var(--lime); border-radius: 999px; }

.credit-box .btn { width: 100%; margin-top: 10px; }

body.nav-collapsed .logo-text,
body.nav-collapsed .nav-label,
body.nav-collapsed .nav a span,
body.nav-collapsed .nav a .nav-count,
body.nav-collapsed .credit-box { display: none; }
body.nav-collapsed .nav a { justify-content: center; padding: 11px 0; }
body.nav-collapsed .nav a.active::before { display: none; }
body.nav-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }

/* ----- Topbar ------------------------------------------------------------- */

.main { min-width: 0; display: flex; flex-direction: column; }
.nav-scrim { display: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 28px;
    background: rgba(245, 246, 250, .85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    color: var(--ink-2);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    transition: .15s ease;
    flex-shrink: 0;
    padding: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-sm); }

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); text-decoration: none; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .cur { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    text-decoration: none;
}
.pill:hover { border-color: var(--line-strong); text-decoration: none; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(197, 243, 91, .35); }
.pill b { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

.user-menu { position: relative; }
.user-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--bg-elev); cursor: pointer; font: inherit; color: var(--ink);
}
.user-btn:hover { border-color: var(--line-strong); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand-grad); color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: 12px; font-family: var(--font-display); flex-shrink: 0;
}
.user-btn .name { font-size: 13px; font-weight: 600; max-width: 140px; }
.user-btn svg { width: 14px; height: 14px; color: var(--ink-4); }

.menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50;
}
.menu.open { display: block; }
.menu a, .menu button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; border-radius: 8px; border: 0; background: none;
    font: inherit; font-size: 13px; color: var(--ink-2); text-align: left; cursor: pointer; text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--bg-muted); color: var(--ink); text-decoration: none; }
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu .menu-head b { display: block; font-size: 13px; }
.menu .menu-head span { font-size: 12px; color: var(--ink-3); }
.menu .danger { color: var(--bad); }
.menu svg { width: 16px; height: 16px; }

/* ----- Page ---------------------------------------------------------------- */

.page { padding: 26px 28px 60px; max-width: 1440px; width: 100%; }
.page.narrow { max-width: 980px; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
    margin-bottom: 22px; flex-wrap: wrap;
}
.page-head .eyebrow {
    font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
    color: var(--brand); margin-bottom: 6px;
}
.page-head p { color: var(--ink-3); margin-top: 6px; max-width: 640px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.page-footer { margin-top: auto; padding: 18px 28px; font-size: 12.5px; color: var(--ink-4); border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ----- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px; border-radius: 10px;
    font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
    white-space: nowrap; transition: .15s ease; color: #fff;
    background: var(--brand);
}
.btn:hover { text-decoration: none; filter: brightness(1.06); transform: translateY(-1px); box-shadow: var(--glow); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

.btn-grad { background: var(--brand-grad); }
.btn-dark { background: var(--ink); }
.btn-dark:hover { box-shadow: 0 10px 30px -10px rgba(15, 18, 34, .6); }
.btn-lime { background: var(--lime); color: var(--lime-ink); }
.btn-lime:hover { box-shadow: 0 10px 30px -10px rgba(197, 243, 91, .9); }
.btn-ghost { background: var(--bg-elev); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover { background: var(--brand-soft-2); box-shadow: none; }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.btn-danger { background: var(--bad); }
.btn-danger-soft { background: var(--bad-soft); color: var(--bad-ink); }
.btn-danger-soft:hover { box-shadow: none; background: #fbd5d5; }
.btn-link { background: none; color: var(--brand-ink); padding: 0 4px; height: auto; }
.btn-link:hover { box-shadow: none; transform: none; text-decoration: underline; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 14.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ----- Cards ---------------------------------------------------------------- */

.card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.card-body { padding: 22px; }
.card-body.tight { padding: 14px 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--line); background: var(--bg-soft); border-radius: 0 0 var(--r-lg) var(--r-lg); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.card + .card { margin-top: 20px; }
.card.flush { overflow: hidden; }

.card-hero {
    position: relative; overflow: hidden;
    background: #12152a;
    color: #fff; border-radius: var(--r-xl); padding: 30px 32px;
    border: 1px solid rgba(255, 255, 255, .05);
    box-shadow: var(--shadow-lg);
}
.card-hero::before {
    content: ""; position: absolute; inset: 0;
    background:
        radial-gradient(600px 220px at 85% -20%, rgba(124, 92, 255, .55), transparent 70%),
        radial-gradient(300px 200px at 10% 120%, rgba(197, 243, 91, .18), transparent 70%);
    pointer-events: none;
}
.card-hero > * { position: relative; }
.card-hero h1 { color: #fff; font-size: 26px; }
.card-hero p { color: #b9bdd6; margin-top: 8px; max-width: 620px; }
.card-hero .btn-ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .16); color: #fff; }

/* ----- Stats --------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat .stat-label { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.stat .stat-icon {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand-ink);
}
.stat .stat-icon svg { width: 17px; height: 17px; }
.stat .stat-icon.lime { background: #f1fbd3; color: var(--lime-ink); }
.stat .stat-icon.ok { background: var(--ok-soft); color: var(--ok-ink); }
.stat .stat-icon.warn { background: var(--warn-soft); color: var(--warn-ink); }
.stat .stat-icon.info { background: var(--info-soft); color: var(--info-ink); }
.stat .stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.stat .stat-foot { font-size: 12px; color: var(--ink-4); display: flex; gap: 6px; align-items: center; }
.stat .stat-foot .up { color: var(--ok); font-weight: 600; }
.stat .stat-foot .down { color: var(--bad); font-weight: 600; }

/* ----- Grid helpers --------------------------------------------------------- */

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.grid-side { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid-main > *, .grid-side > * { min-width: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 22px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 22px; }
.hide { display: none !important; }

/* ----- Badges --------------------------------------------------------------- */

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    background: var(--bg-muted); color: var(--ink-2); white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.plain::before { display: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge-bad { background: var(--bad-soft); color: var(--bad-ink); }
.badge-info { background: var(--info-soft); color: var(--info-ink); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge-dark { background: var(--ink); color: #fff; }
.badge-lime { background: #f1fbd3; color: var(--lime-ink); }
.badge.pulse::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--bg-muted); color: var(--ink-2); font-family: var(--font-mono); }

/* ----- Tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table td.truncate { max-width: 220px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
    text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-3); padding: 12px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfe; }
.table .t-title { font-weight: 600; color: var(--ink); }
.table .t-sub { font-size: 12px; color: var(--ink-4); margin-top: 2px; }
.table .t-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.table .t-right { text-align: right; }
.table.compact td { padding: 10px 14px; }
.table.compact th { padding: 9px 14px; }

/* ----- Forms ---------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--ink-4); }
.field .req { color: var(--bad); }
.input, .select, .textarea,
input[type="text"].input, input[type="email"].input, input[type="password"].input, input[type="number"].input, input[type="url"].input, input[type="date"].input, input[type="time"].input, input[type="datetime-local"].input {
    width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--ink);
    font: inherit; font-size: 13.5px; outline: none; transition: .15s ease;
}
.textarea { height: auto; min-height: 110px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 91, 214, .16); }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-muted); color: var(--ink-3); }
.select {
    appearance: none; -webkit-appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7089' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center;
}
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--bad); }
.field-error { font-size: 12px; color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }

.check, .radio { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; cursor: pointer; }
.check input, .radio input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex-shrink: 0; }
.check span small, .radio span small { display: block; color: var(--ink-4); font-size: 12px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; transition: .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

.input-group { display: flex; }
.input-group .input { border-radius: 10px 0 0 10px; }
.input-group .btn { border-radius: 0 10px 10px 0; height: 40px; }

.option-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.option-card { position: relative; display: block; cursor: pointer; }
.option-card input { position: absolute; opacity: 0; inset: 0; }
.option-card .oc {
    border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; background: var(--bg-elev);
    transition: .15s ease; height: 100%;
}
.option-card .oc b { display: block; font-size: 13.5px; }
.option-card .oc small { color: var(--ink-4); font-size: 12px; }
.option-card input:checked + .oc { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px rgba(91, 91, 214, .14); }
.option-card:hover .oc { border-color: var(--brand); }

/* ----- Alerts --------------------------------------------------------------- */

.alert {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: 13.5px; margin-bottom: 18px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert b { display: block; margin-bottom: 2px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-ok { background: var(--ok-soft); border-color: #bfe9cf; color: var(--ok-ink); }
.alert-bad { background: var(--bad-soft); border-color: #f6c6c6; color: var(--bad-ink); }
.alert-warn { background: var(--warn-soft); border-color: #f8dcb0; color: var(--warn-ink); }
.alert-info { background: var(--info-soft); border-color: #bfe0f5; color: var(--info-ink); }

/* ----- Empty state ---------------------------------------------------------- */

.empty { text-align: center; padding: 48px 24px; color: var(--ink-3); }
.empty .empty-icon {
    width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
    background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center;
}
.empty .empty-icon svg { width: 26px; height: 26px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 380px; margin: 0 auto 16px; }

/* ----- Progress / meters ---------------------------------------------------- */

.progress { height: 8px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--brand-grad); transition: width .4s ease; }
.progress.ok i { background: var(--ok); }
.progress.warn i { background: var(--warn); }
.progress.bad i { background: var(--bad); }
.progress.lg { height: 12px; }

.ring { --p: 0; --c: var(--brand); width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--bg-muted) 0); }
.ring::before { content: ""; position: absolute; width: 50px; height: 50px; border-radius: 50%; background: var(--bg-elev); }
.ring { position: relative; }
.ring b { position: relative; font-family: var(--font-display); font-size: 15px; }

/* ----- Tabs / steps --------------------------------------------------------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button {
    padding: 10px 14px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-3);
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs .active { color: var(--brand-ink); border-bottom-color: var(--brand); }

.seg { display: inline-flex; background: var(--bg-muted); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a, .seg button { padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-3); border: 0; background: none; cursor: pointer; text-decoration: none; white-space: nowrap; }
.seg .active { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-sm); }

.steps { display: flex; gap: 8px; align-items: center; margin-bottom: 24px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--ink-4); }
.step i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; background: var(--bg-muted); color: var(--ink-3); border: 1px solid var(--line); }
.step.active { color: var(--ink); }
.step.active i { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(91, 91, 214, .15); }
.step.done i { background: var(--ok); color: #fff; border-color: var(--ok); }
.step-line { flex: 1; min-width: 24px; height: 1px; background: var(--line-strong); }

/* ----- Lists ---------------------------------------------------------------- */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .li-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--bg-muted); display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; }
.list-item .li-icon svg { width: 17px; height: 17px; }
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; font-size: 13.5px; }
.list-item .li-sub { font-size: 12px; color: var(--ink-4); }

.action-tile {
    display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 14px;
    border: 1px solid var(--line); background: var(--bg-elev); text-decoration: none; color: var(--ink); transition: .15s ease;
}
.action-tile:hover { border-color: var(--brand); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-1px); }
.action-tile .at-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; flex-shrink: 0; }
.action-tile .at-icon svg { width: 19px; height: 19px; }
.action-tile .at-icon.lime { background: #f1fbd3; color: var(--lime-ink); }
.action-tile .at-icon.ok { background: var(--ok-soft); color: var(--ok-ink); }
.action-tile .at-icon.info { background: var(--info-soft); color: var(--info-ink); }
.action-tile b { display: block; font-size: 13.5px; }
.action-tile small { color: var(--ink-4); font-size: 12px; }
.action-tile .arrow { margin-left: auto; color: var(--ink-4); }
.action-tile .arrow svg { width: 16px; height: 16px; }

/* ----- Key-value ------------------------------------------------------------ */

.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.kv.stack { grid-template-columns: 1fr; gap: 2px 0; }
.kv.stack dt { font-size: 12px; }
.kv.stack dd { text-align: left; margin-bottom: 10px; }

/* ----- Timeline / logs ------------------------------------------------------ */

.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 6px 0 14px 30px; font-size: 13px; }
.tl-item::before { content: ""; position: absolute; left: 4px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-elev); border: 2px solid var(--ink-4); }
.tl-item.ok::before { border-color: var(--ok); background: var(--ok); }
.tl-item.bad::before { border-color: var(--bad); background: var(--bad); }
.tl-item.warn::before { border-color: var(--warn); background: var(--warn); }
.tl-item.running::before { border-color: var(--brand); background: var(--brand); animation: pulse 1.2s infinite; }
.tl-item .tl-time { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); }
.tl-item .tl-type { font-weight: 600; color: var(--ink); }
.tl-item .tl-msg { color: var(--ink-2); }

.log-box {
    background: #0f1222; color: #d7daea; border-radius: 12px; padding: 14px 16px;
    font-family: var(--font-mono); font-size: 12px; line-height: 1.6; max-height: 420px; overflow: auto;
}
.log-box .ok { color: #9ae6b4; } .log-box .bad { color: #fca5a5; } .log-box .warn { color: #fcd38d; } .log-box .dim { color: #7b809c; }

/* ----- Misc ----------------------------------------------------------------- */

.divider { height: 1px; background: var(--line); margin: 18px 0; }
.kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; background: var(--bg-soft); }
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); animation: toastin .2s ease; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } }

.modal-back { position: fixed; inset: 0; background: rgba(15, 18, 34, .5); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; z-index: 80; padding: 20px; }
.modal-back.open { display: flex; }
.modal { background: var(--bg-elev); border-radius: 16px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.modal .card-head, .modal .card-body, .modal .card-foot { padding-left: 22px; padding-right: 22px; }

.article-prose { font-size: 15.5px; line-height: 1.75; color: #23273a; max-width: 760px; }
.article-prose h1 { font-size: 30px; margin: 0 0 16px; }
.article-prose h2 { font-size: 22px; margin: 32px 0 10px; }
.article-prose h3 { font-size: 17px; margin: 24px 0 8px; }
.article-prose p { margin: 0 0 14px; }
.article-prose ul, .article-prose ol { margin: 0 0 14px; padding-left: 22px; }
.article-prose li { margin-bottom: 4px; }
.article-prose img { max-width: 100%; height: auto; border-radius: 12px; margin: 10px 0 18px; }
.article-prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0 18px; }
.article-prose th, .article-prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.article-prose th { background: var(--bg-soft); }
.article-prose a { text-decoration: underline; }

/* ----- Scrollbar ------------------------------------------------------------ */

* { scrollbar-width: thin; scrollbar-color: #c9cde0 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #c9cde0; border-radius: 999px; }
.sidebar * { scrollbar-color: rgba(255, 255, 255, .12) transparent; }

/* ----- Responsive ----------------------------------------------------------- */

@media (max-width: 1180px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main, .grid-side { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    body.nav-collapsed .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 60;
        transform: translateX(-100%); transition: transform .22s ease; height: 100vh;
    }
    body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
    body.nav-collapsed .logo-text, body.nav-collapsed .nav-label, body.nav-collapsed .nav a span, body.nav-collapsed .credit-box { display: revert; }
    body.nav-collapsed .nav a { justify-content: flex-start; padding: 9px 10px; }
    .nav-scrim { position: fixed; inset: 0; background: rgba(15, 18, 34, .45); z-index: 55; display: none; }
    body.nav-open .nav-scrim { display: block; }
    .topbar { padding: 0 16px; }
    .page { padding: 18px 16px 50px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .user-btn .name { display: none; }
    .crumbs .hide-sm { display: none; }
    .card-hero { padding: 24px 20px; }
}

@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; }
    .card-head, .card-body, .card-pad { padding-left: 16px; padding-right: 16px; }
    .pill .pill-label { display: none; }
}

@media print {
    .sidebar, .topbar, .page-footer, .page-actions { display: none !important; }
    .app { grid-template-columns: 1fr; }
}
