@font-face {
    font-family: "Be Vietnam Pro";
    src: url("../fonts/be-vietnam-pro/BeVietnamPro-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Be Vietnam Pro";
    src: url("../fonts/be-vietnam-pro/BeVietnamPro-Medium.ttf") format("truetype");
    font-style: normal;
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Be Vietnam Pro";
    src: url("../fonts/be-vietnam-pro/BeVietnamPro-SemiBold.ttf") format("truetype");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Be Vietnam Pro";
    src: url("../fonts/be-vietnam-pro/BeVietnamPro-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Be Vietnam Pro";
    src: url("../fonts/be-vietnam-pro/BeVietnamPro-ExtraBold.ttf") format("truetype");
    font-style: normal;
    font-weight: 800;
    font-display: swap;
}

/* ============================================================
   Design tokens — Navy/grey corporate, Swiss minimalism
   Light is the default; [data-theme="dark"] overrides.
   ============================================================ */
:root {
    color-scheme: light;

    /* Brand navy scale */
    --navy-50: #eef2f8;
    --navy-100: #d9e2f0;
    --navy-200: #b3c4df;
    --navy-300: #7f9bc6;
    --navy-400: #4f70a5;
    --navy-500: #2f5185;
    --navy-600: #1f3d6b;
    --navy-700: #17365d;
    --navy-800: #122a48;
    --navy-900: #0d1e34;

    /* Neutral grey scale */
    --grey-0: #ffffff;
    --grey-25: #fbfcfe;
    --grey-50: #f5f7fa;
    --grey-100: #eef1f5;
    --grey-200: #e2e7ee;
    --grey-300: #cdd5e0;
    --grey-400: #9aa7b8;
    --grey-500: #6b7889;
    --grey-600: #4d5867;
    --grey-700: #37404d;
    --grey-800: #232a34;
    --grey-900: #141a22;

    /* Semantic feedback */
    --success: #1f7a4d;
    --success-surface: #e6f4ec;
    --success-border: #b7dfc8;
    --danger: #b3261e;
    --danger-surface: #fbeae9;
    --danger-border: #f0c4c1;
    --warning: #9a6a00;
    --warning-surface: #fdf3e0;

    /* Semantic surface tokens (light) */
    --canvas: var(--grey-50);
    --surface: var(--grey-0);
    --surface-soft: var(--grey-25);
    --surface-alt: var(--grey-100);
    --surface-inset: var(--grey-50);
    --sidebar-bg: var(--navy-800);
    --sidebar-fg: #d7deea;
    --sidebar-muted: #93a2ba;
    --sidebar-active-bg: rgba(255, 255, 255, 0.10);
    --sidebar-active-fg: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    --ink: var(--grey-900);
    --ink-strong: var(--navy-900);
    --muted: var(--grey-500);
    --muted-strong: var(--grey-600);

    --border: var(--grey-200);
    --border-strong: var(--grey-300);
    --ring: var(--navy-400);

    --accent: var(--navy-600);
    --accent-hover: var(--navy-700);
    --accent-fg: #ffffff;

    --shadow-xs: 0 1px 2px rgba(13, 30, 52, 0.06);
    --shadow-sm: 0 1px 3px rgba(13, 30, 52, 0.08), 0 1px 2px rgba(13, 30, 52, 0.04);
    --shadow-md: 0 6px 16px rgba(13, 30, 52, 0.10), 0 2px 6px rgba(13, 30, 52, 0.06);
    --shadow-lg: 0 18px 40px rgba(13, 30, 52, 0.16);

    /* Dense dashboard spacing (density 8/10) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;

    --sidebar-w: 264px;
    --topbar-h: 60px;

    --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring);

    --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "SFMono-Regular", ui-monospace, "Cascadia Code", "Consolas", monospace;

    --dur: 180ms;
    --ease: cubic-bezier(0.2, 0, 0.15, 1);
}

[data-theme="dark"] {
    color-scheme: dark;

    --canvas: #0b1220;
    --surface: #131b2b;
    --surface-soft: #16202f;
    --surface-alt: #1b2637;
    --surface-inset: #101828;
    --sidebar-bg: #0d1626;
    --sidebar-fg: #cbd5e6;
    --sidebar-muted: #7c8aa3;
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);
    --sidebar-active-fg: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.07);

    --ink: #eaeff7;
    --ink-strong: #f7fafd;
    --muted: #9aa7bb;
    --muted-strong: #b6c1d2;

    --border: #26314400;
    --border: #273248;
    --border-strong: #33415b;
    --ring: #6f9be0;

    --accent: #3f6fb5;
    --accent-hover: #4f80c8;
    --accent-fg: #ffffff;

    --success: #4cc38a;
    --success-surface: rgba(37, 122, 77, 0.18);
    --success-border: rgba(76, 195, 138, 0.35);
    --danger: #f06a63;
    --danger-surface: rgba(179, 38, 30, 0.20);
    --danger-border: rgba(240, 106, 99, 0.35);
    --warning: #e0a548;
    --warning-surface: rgba(154, 106, 0, 0.22);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.6);

    --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring);
}

/* Follow OS preference when the user hasn't picked a theme explicitly */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --canvas: #0b1220;
        --surface: #131b2b;
        --surface-soft: #16202f;
        --surface-alt: #1b2637;
        --surface-inset: #101828;
        --sidebar-bg: #0d1626;
        --sidebar-fg: #cbd5e6;
        --sidebar-muted: #7c8aa3;
        --sidebar-active-bg: rgba(255, 255, 255, 0.08);
        --sidebar-active-fg: #ffffff;
        --sidebar-border: rgba(255, 255, 255, 0.07);

        --ink: #eaeff7;
        --ink-strong: #f7fafd;
        --muted: #9aa7bb;
        --muted-strong: #b6c1d2;

        --border: #273248;
        --border-strong: #33415b;
        --ring: #6f9be0;

        --accent: #3f6fb5;
        --accent-hover: #4f80c8;
        --accent-fg: #ffffff;

        --success: #4cc38a;
        --success-surface: rgba(37, 122, 77, 0.18);
        --success-border: rgba(76, 195, 138, 0.35);
        --danger: #f06a63;
        --danger-surface: rgba(179, 38, 30, 0.20);
        --danger-border: rgba(240, 106, 99, 0.35);
        --warning: #e0a548;
        --warning-surface: rgba(154, 106, 0, 0.22);

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
        --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.6);
    }
}

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

html {
    scroll-behavior: smooth;
    background: var(--canvas);
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button,
a,
input,
select,
summary {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

[hidden] {
    display: none !important;
}

svg {
    display: block;
    flex: none;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4 {
    margin: 0;
    color: var(--ink-strong);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-wrap: balance;
}

h1 { font-size: clamp(24px, 3vw, 30px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-weight: 650; }

p { margin: 0; }

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.lede,
.section-description {
    color: var(--muted);
    text-wrap: pretty;
}

.section-description {
    margin-top: 4px;
    font-size: 14px;
}

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.92em;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: var(--radius-sm);
    font-weight: 600;
    transform: translateY(-160%);
    transition: transform var(--dur) var(--ease);
}

.skip-link:focus {
    transform: translateY(0);
    text-decoration: none;
}

/* ============================================================
   App shell — sidebar + topbar + content
   ============================================================ */
body:not(.auth-body) {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-sidebar {
    grid-column: 1;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-5) var(--space-4);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto;
    z-index: 60;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px var(--space-5);
    color: #fff;
}

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

.sidebar-brand .brand-mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(140deg, var(--navy-400), var(--navy-600));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    flex: none;
}

.sidebar-brand .brand-mark span {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
}

.sidebar-brand strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand small {
    display: block;
    font-size: 11px;
    color: var(--sidebar-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav-label {
    padding: var(--space-4) 8px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a:focus-visible {
    outline: 2px solid var(--navy-200);
    outline-offset: -2px;
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    opacity: 0.85;
}

.sidebar-nav a[aria-current="location"] {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-fg);
    font-weight: 600;
    box-shadow: inset 2px 0 0 var(--navy-300);
}

.sidebar-nav a[aria-current="location"] svg { opacity: 1; }

.sidebar-foot {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.sidebar-foot .header-action { margin: 0; }

.sidebar-foot .button {
    width: 100%;
    justify-content: center;
}

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--sidebar-fg);
    cursor: pointer;
    transition: background var(--dur) var(--ease);
}

.sidebar-close:hover { background: rgba(255, 255, 255, 0.08); }
.sidebar-close:focus-visible { outline: 2px solid var(--navy-200); outline-offset: -2px; }

.sidebar-secure {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    font-size: 11.5px;
    color: var(--sidebar-muted);
}

/* Topbar */
.app-main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar-h);
    padding: 0 clamp(var(--space-4), 3vw, var(--space-7));
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-right: auto;
}

.topbar-title strong {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-title span {
    font-size: 12px;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Hamburger — mobile only */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.sidebar-toggle:hover { background: var(--surface-alt); }
.sidebar-toggle:focus-visible { box-shadow: var(--focus-ring); }
.sidebar-toggle svg { width: 20px; height: 20px; }

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.theme-toggle:hover { background: var(--surface-alt); }
.theme-toggle:focus-visible { box-shadow: var(--focus-ring); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
}

/* Sidebar scrim (mobile) */
.sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(9, 15, 26, 0.5);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
}

/* Content region */
.page-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: clamp(var(--space-5), 3vw, var(--space-7)) clamp(var(--space-4), 3vw, var(--space-7)) var(--space-8);
}

/* ============================================================
   Page heading
   ============================================================ */
.page-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-5);
    scroll-margin-top: calc(var(--topbar-h) + var(--space-4));
}

.page-heading-copy { max-width: 62ch; }
.page-heading-copy .lede { margin-top: 8px; font-size: 15px; }

.page-heading-note {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    font-size: 13px;
    color: var(--muted);
}

.page-heading-note strong { color: var(--ink-strong); font-size: 13px; }

.live-mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--success);
}

.live-mark > span[aria-hidden] {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-surface);
}

/* ============================================================
   Buttons
   ============================================================ */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
        color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.button:hover { text-decoration: none; }
.button:active { transform: translateY(1px); }
.button:focus-visible { box-shadow: var(--focus-ring); }

.button-primary {
    background: var(--accent);
    color: var(--accent-fg);
    box-shadow: var(--shadow-xs);
}

.button-primary:hover { background: var(--accent-hover); }

.button-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border-strong);
}

.button-secondary:hover {
    background: var(--surface-alt);
    border-color: var(--muted);
}

.button-on-dark {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.24);
}

.button-on-dark:hover { background: rgba(255, 255, 255, 0.24); }

.button-small {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 13px;
}

.button-block { width: 100%; }

.button:disabled,
.button.is-loading {
    cursor: not-allowed;
    opacity: 0.62;
}

.button.is-loading {
    position: relative;
    color: transparent !important;
}

.button.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: var(--radius-full);
    color: var(--accent-fg);
    animation: button-spin 0.6s linear infinite;
}

.button-secondary.is-loading::after,
.button-on-dark.is-loading::after { color: var(--ink); }

@keyframes button-spin {
    to { transform: rotate(360deg); }
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

/* ============================================================
   Stat cards
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card-featured {
    background: linear-gradient(150deg, var(--navy-700), var(--navy-900));
    border-color: var(--navy-700);
    color: #eef2f8;
}

.stat-kicker {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.stat-card-featured .stat-kicker { color: var(--navy-200); }

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.stat-card-featured .stat-label { color: var(--navy-100); }

.stat-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ink-strong);
    font-variant-numeric: tabular-nums;
}

.stat-card-featured .stat-value { color: #fff; }

.stat-note {
    font-size: 12.5px;
    color: var(--muted);
}

.stat-card-featured .stat-note { color: var(--navy-200); }

/* ============================================================
   Sections & panels
   ============================================================ */
.admin-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    scroll-margin-top: calc(var(--topbar-h) + var(--space-4));
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
}

.panel {
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel-soft {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    background: var(--surface-soft);
}

.panel h3 { color: var(--ink-strong); }

.bento-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: var(--space-4);
    align-items: start;
}

.nested-grid {
    grid-template-columns: minmax(260px, 340px) 1fr;
}

/* ============================================================
   Forms
   ============================================================ */
.stack-form,
.compact-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-strong);
}

.field label span[aria-hidden] { color: var(--danger); }

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    min-height: 42px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.field input::placeholder { color: var(--grey-400); }

.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--muted); }

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 28%, transparent);
}

.field small {
    font-size: 12px;
    color: var(--muted);
}

.field-error {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--danger);
}

.field-wide { grid-column: 1 / -1; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-4);
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.check-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
}

.check-field input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--accent);
    flex: none;
}

.inline-form { display: inline-flex; }

.compact-form {
    gap: var(--space-3);
}

.reset-panel {
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: var(--surface-inset);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

.security-panel { max-width: 620px; }

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

/* ============================================================
   Messages
   ============================================================ */
.message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
}

.message-success {
    background: var(--success-surface);
    border-color: var(--success-border);
    color: var(--success);
}

.message-error {
    background: var(--danger-surface);
    border-color: var(--danger-border);
    color: var(--danger);
}

.message::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: currentColor;
    flex: none;
}

/* ============================================================
   Tables
   ============================================================ */
.table-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead th {
    position: sticky;
    top: 0;
    padding: 12px 16px;
    background: var(--surface-alt);
    color: var(--muted-strong);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover { background: var(--surface-soft); }

.cell-title {
    display: block;
    font-weight: 600;
    color: var(--ink-strong);
}

.cell-meta {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: currentColor;
    flex: none;
}

.badge-neutral {
    background: var(--surface-alt);
    color: var(--muted-strong);
    border-color: var(--border);
    font-family: var(--font-mono);
}

.badge-neutral::before { display: none; }

.badge-active {
    background: var(--success-surface);
    color: var(--success);
    border-color: var(--success-border);
}

.badge-inactive {
    background: var(--surface-alt);
    color: var(--muted);
    border-color: var(--border);
}

/* ============================================================
   Empty states
   ============================================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--space-7) var(--space-5);
    text-align: center;
    color: var(--muted);
}

.empty-state strong {
    color: var(--ink-strong);
    font-size: 15px;
}

.compact-empty {
    padding: var(--space-5);
    text-align: left;
    background: var(--surface-inset);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

/* ============================================================
   Server monitor
   ============================================================ */
.server-monitor {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-6);
    background: linear-gradient(155deg, var(--navy-800), var(--navy-900));
    border: 1px solid var(--navy-700);
    border-radius: var(--radius-lg);
    color: #e6ecf5;
    box-shadow: var(--shadow-md);
}

.monitor-heading .eyebrow { color: var(--navy-200); }
.monitor-heading h2 { color: #fff; }
.monitor-heading .section-description { color: var(--navy-200); }

.monitor-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.monitor-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--navy-100);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: var(--radius-full);
    background: var(--grey-400);
    flex: none;
    transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.status-dot.is-online {
    background: #46d38a;
    box-shadow: 0 0 0 4px rgba(70, 211, 138, 0.22);
}

.status-dot.is-offline {
    background: #f06a63;
    box-shadow: 0 0 0 4px rgba(240, 106, 99, 0.22);
}

.server-monitor.is-stale { opacity: 0.94; }

.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--space-4);
}

.monitor-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: var(--space-4);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-md);
}

.monitor-card-primary { min-height: 118px; }

.monitor-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--navy-200);
}

.monitor-card strong {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.monitor-card small { font-size: 12px; color: var(--navy-200); }

.monitor-card progress {
    width: 100%;
    height: 6px;
    border: none;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
}

.monitor-card progress::-webkit-progress-bar {
    background: transparent;
}

.monitor-card progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--navy-300), #6fd0a0);
    border-radius: var(--radius-full);
    transition: width var(--dur) var(--ease);
}

.monitor-card progress::-moz-progress-bar {
    background: linear-gradient(90deg, var(--navy-300), #6fd0a0);
    border-radius: var(--radius-full);
}

.monitor-card dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin: 0;
}

.monitor-card dl div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.monitor-card dt {
    font-size: 11px;
    color: var(--navy-200);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.monitor-card dd {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-3);
    max-width: 1320px;
    margin: 0 auto;
    padding: var(--space-4) clamp(var(--space-4), 3vw, var(--space-7));
    font-size: 13px;
    color: var(--muted);
}

/* ============================================================
   Auth page (login) — centered, split panel
   ============================================================ */
.auth-body {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(47, 81, 133, 0.18), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(31, 61, 107, 0.16), transparent 55%),
        var(--canvas);
}

.auth-main {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: clamp(var(--space-5), 5vw, var(--space-8));
}

.auth-panel {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    width: min(960px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-intro {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: clamp(var(--space-6), 4vw, var(--space-8));
    background: linear-gradient(160deg, var(--navy-700), var(--navy-900));
    color: #e6ecf5;
}

.brand-auth { color: #fff; }
.brand-auth:hover { text-decoration: none; }

.auth-intro .brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(140deg, var(--navy-400), var(--navy-600));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.auth-intro .brand-mark span { font-size: 16px; font-weight: 800; color: #fff; }
.auth-intro .brand strong { display: block; font-size: 16px; color: #fff; }
.auth-intro .brand small { display: block; font-size: 12px; color: var(--navy-200); }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.auth-story .eyebrow { color: var(--navy-200); }
.auth-story h1 { color: #fff; margin-bottom: 10px; }
.auth-story .lede { color: var(--navy-100); }

.auth-proof {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: var(--navy-200);
}

.auth-form-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding: clamp(var(--space-6), 4vw, var(--space-8));
    justify-content: center;
}

.auth-form-heading .eyebrow { color: var(--accent); }
.auth-form-heading h2 { color: var(--ink-strong); }

.auth-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.auth-note span[aria-hidden] { color: var(--success); }

/* ============================================================
   Legacy top-header fallback (kept for safety, hidden in shell)
   ============================================================ */
.site-header { display: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    body:not(.auth-body) {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(84vw, var(--sidebar-w));
        transform: translateX(-102%);
        transition: transform var(--dur) var(--ease);
        box-shadow: var(--shadow-lg);
    }

    body.sidebar-open .app-sidebar { transform: translateX(0); }

    body.sidebar-open .sidebar-scrim {
        display: block;
        opacity: 1;
    }

    .app-main { grid-column: 1; }

    .sidebar-toggle { display: inline-flex; }
    .sidebar-close { display: inline-flex; }
}

@media (max-width: 860px) {
    .bento-grid,
    .nested-grid {
        grid-template-columns: 1fr;
    }

    .page-heading { align-items: flex-start; }
    .page-heading-note { width: 100%; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }

    .auth-panel { grid-template-columns: 1fr; }
    .auth-intro { display: none; }

    .stat-value { font-size: 26px; }
    .monitor-card strong { font-size: 21px; }

    .page-shell { padding-left: var(--space-4); padding-right: var(--space-4); }
}

/* ============================================================
   Motion preferences
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
