/* ==========================================================================
   Virtual Meeting — design foundation (Dialtone Technologies brand)
   Tokens, base elements and shared components. Page-specific layout lives in
   wwwroot/css/*.css. Everything here reads from the tokens below so light and
   dark mode stay in sync; avoid hard-coded colours in components.

   Brand palette: Deep Navy #0F172A (primary), Signal Blue #3B82F6 (secondary),
   Quantum Cyan #06B6D4 (accent, never for text), Cloud White #F8FAFC
   (background), Slate Ink #1E293B (text). Manrope for headings, Inter for body.
   Radius: 12px buttons and inputs, 18px cards, pill badges. 4px spacing unit.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
    color-scheme: light;

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-heading: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;

    /* Type scale: 16px base, 1.25 ratio */
    --fs-xs: 0.64rem;    /* 10.2px */
    --fs-sm: 0.8rem;     /* 12.8px */
    --fs-base: 1rem;     /* 16px */
    --fs-lg: 1.25rem;    /* 20px */
    --fs-xl: 1.563rem;   /* 25px */
    --fs-2xl: 1.953rem;  /* 31.2px */
    --fs-3xl: 2.441rem;  /* 39.1px */
    --fs-4xl: 3.052rem;  /* 48.8px */
    --fs-5xl: 3.815rem;  /* 61px */

    /* Brand palette */
    --navy: #0f172a;
    --slate-ink: #1e293b;
    --signal-blue: #3b82f6;
    --signal-blue-strong: #2563eb;
    --quantum-cyan: #06b6d4;
    --violet-pulse: #7c3aed;
    --cloud-white: #f8fafc;

    --bg: #f8fafc;
    --bg-subtle: #f1f5f9;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --surface-hover: #e9eef5;

    --text: #1e293b;
    --text-2: #334155;
    --text-3: #64748b;
    --text-4: #94a3b8;

    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Interactive accent (Signal Blue). --brand is the fill, --brand-ink is text-safe. */
    --brand: #3b82f6;
    --brand-ink: #2563eb;
    --brand-soft: #eff6ff;
    --brand-glow: rgba(59, 130, 246, 0.28);

    /* Accent (Quantum Cyan): live states, speaking rings, highlights. Not for text. */
    --accent: #06b6d4;
    --accent-ink: #0e7490;
    --accent-soft: #ecfeff;

    --primary-bg: #0f172a;
    --primary-bg-hover: #1e293b;
    --primary-fg: #f8fafc;

    --secondary-bg: #2563eb;
    --secondary-bg-hover: #1d4ed8;
    --secondary-fg: #ffffff;

    --success: #16a34a;
    --success-ink: #15803d;
    --success-soft: #f0fdf4;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fef5f5;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --info: #0369a1;
    --info-soft: #f0f9ff;

    --focus: #2563eb;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.16);

    --header-height: 64px;
    --container: 1200px;
    --gutter: clamp(16px, 4vw, 32px);

    --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #1e2025;
        --bg-subtle: #191b1f;
        --surface: #25282e;
        --surface-muted: #2c3038;
        --surface-hover: #353a44;

        --text: #f7f7f8;
        --text-2: #d5d8de;
        --text-3: #a3aab6;
        --text-4: #7c8492;

        --border: rgba(255, 255, 255, 0.09);
        --border-strong: rgba(255, 255, 255, 0.18);

        --brand: #7992ce;
        --brand-ink: #9fb2e0;
        --brand-soft: rgba(121, 146, 206, 0.16);
        --brand-glow: rgba(121, 146, 206, 0.35);

        --accent-ink: #67e8f9;
        --accent-soft: rgba(6, 182, 212, 0.14);

        --primary-bg: #7992ce;
        --primary-bg-hover: #93a8db;
        --primary-fg: #0f172a;

        --secondary-bg: #60a5fa;
        --secondary-bg-hover: #93c5fd;
        --secondary-fg: #0f172a;

        --success: #22c55e;
        --success-ink: #4ade80;
        --success-soft: rgba(34, 197, 94, 0.14);
        --danger: #f87171;
        --danger-hover: #fca5a5;
        --danger-soft: rgba(248, 113, 113, 0.14);
        --warning: #fbbf24;
        --warning-soft: rgba(251, 191, 36, 0.14);
        --info: #38bdf8;
        --info-soft: rgba(56, 189, 248, 0.14);

        --focus: #9fb2e0;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
        --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-height) + 16px);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    color: var(--text);
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

h1 { font-size: clamp(var(--fs-xl), 1.2rem + 1.4vw, var(--fs-2xl)); letter-spacing: -0.025em; line-height: 1.15; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-base); font-weight: 600; }

p {
    margin: 0;
    text-wrap: pretty;
}

a {
    color: inherit;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--brand-ink);
    text-decoration-color: currentColor;
}

img,
svg,
video {
    display: block;
    max-width: 100%;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

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

code,
kbd {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

kbd {
    padding: 0.1em 0.4em;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface-muted);
}

::selection {
    background: var(--brand-glow);
    color: inherit;
}

:focus {
    outline: none;
}

/* Blazor's FocusOnNavigate moves focus to the page heading for screen readers; don't draw a ring around it. */
h1:focus,
h1:focus-visible {
    outline: none;
    box-shadow: none;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--brand-glow);
}

.icon {
    flex: none;
}

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

.skip-link {
    position: absolute;
    left: 12px;
    top: -100px;
    z-index: 1000;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--primary-bg);
    color: var(--primary-fg);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
    color: var(--primary-fg);
}

.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }

.stack { display: grid; gap: var(--stack-gap, 16px); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, 8px); }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--brand-ink);
    font-family: var(--font-heading);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.4;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: calc(var(--container) + var(--gutter) * 2);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.app-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-subtle);
}

.app-main {
    flex: 1;
    padding-block: clamp(24px, 4vw, 40px) 64px;
}

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

.page-header__copy {
    display: grid;
    gap: 6px;
    max-width: 640px;
}

.page-header__copy p {
    color: var(--text-3);
}

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Brand & app header
   -------------------------------------------------------------------------- */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}

.brand:hover {
    color: var(--text);
}

/* The Dialtone wordmark. The light variant is for dark surfaces (dark mode, the meeting room). */
.brand__logo {
    flex: none;
    width: auto;
    height: 32px;
}

.brand__logo--light {
    display: none;
}

@media (prefers-color-scheme: dark) {
    .brand__logo--dark { display: none; }
    .brand__logo--light { display: block; }
}

.brand--on-dark .brand__logo--dark { display: none; }
.brand--on-dark .brand__logo--light { display: block; }

.brand__product {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding-left: 12px;
    border-left: 1px solid var(--border-strong);
    color: var(--text);
    font-family: var(--font-heading);
    font-size: var(--fs-base);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
}

/* Compact keypad mark, used where the full wordmark doesn't fit (the in-call top bar). */
.brand__mark {
    display: block;
    flex: none;
    width: 32px;
    height: 32px;
}

@media (max-width: 420px) {
    .brand__logo {
        height: 26px;
    }

    .brand__product {
        padding-left: 10px;
        font-size: var(--fs-sm);
    }
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
}

.app-header__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: var(--header-height);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 16px;
}

.app-nav a {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.app-nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.app-nav a.active,
.app-nav a[aria-current="page"] {
    color: var(--brand-ink);
    background: var(--brand-soft);
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Account menu (works without JS through <details>) */
.account-menu {
    position: relative;
}

.account-menu > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    cursor: pointer;
    list-style: none;
    transition: border-color 0.15s var(--ease);
}

.account-menu > summary::-webkit-details-marker {
    display: none;
}

.account-menu > summary:hover {
    border-color: var(--border-strong);
}

.account-menu > summary svg {
    width: 16px;
    height: 16px;
    color: var(--text-3);
    transition: transform 0.15s var(--ease);
}

.account-menu[open] > summary svg {
    transform: rotate(180deg);
}

.avatar {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-size: var(--fs-sm);
    font-weight: 600;
}

.account-menu__name {
    max-width: 160px;
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    display: grid;
    min-width: 240px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.account-menu__identity {
    display: grid;
    gap: 2px;
    padding: 8px 10px 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.account-menu__identity strong {
    font-size: 0.875rem;
    font-weight: 600;
}

.account-menu__identity span {
    overflow: hidden;
    color: var(--text-3);
    font-size: var(--fs-sm);
    text-overflow: ellipsis;
}

.account-menu__panel a,
.account-menu__panel button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
}

.account-menu__panel a:hover,
.account-menu__panel button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.account-menu__panel form {
    margin: 4px 0 0;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

.account-menu__panel form button {
    color: var(--danger);
}

@media (max-width: 720px) {
    .app-nav {
        display: none;
    }

    .account-menu__name {
        display: none;
    }
}

/* Mobile nav strip shown under the header on small screens */
.app-subnav {
    display: none;
}

@media (max-width: 720px) {
    .app-subnav {
        display: flex;
        gap: 4px;
        overflow-x: auto;
        padding: 0 var(--gutter) 10px;
        scrollbar-width: none;
    }

    .app-subnav::-webkit-scrollbar {
        display: none;
    }

    .app-subnav a {
        flex: none;
        padding: 6px 12px;
        border-radius: var(--radius-pill);
        color: var(--text-3);
        font-size: 0.875rem;
        font-weight: 500;
        text-decoration: none;
    }

    .app-subnav a.active {
        background: var(--brand-soft);
        color: var(--brand-ink);
    }
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--text);
    --btn-border: var(--border-strong);
    --btn-bg-hover: var(--surface-hover);

    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid var(--btn-border);
    border-radius: var(--radius);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:hover {
    background: var(--btn-bg-hover);
    color: var(--btn-fg);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    box-shadow: none;
    pointer-events: none;
}

.btn svg {
    flex: none;
    width: 18px;
    height: 18px;
}

.btn--primary {
    --btn-bg: var(--primary-bg);
    --btn-fg: var(--primary-fg);
    --btn-border: var(--primary-bg);
    --btn-bg-hover: var(--primary-bg-hover);
}

/* Signal Blue: the main call-to-action inside a flow, such as Join meeting. */
.btn--brand,
.btn--secondary {
    --btn-bg: var(--secondary-bg);
    --btn-fg: var(--secondary-fg);
    --btn-border: var(--secondary-bg);
    --btn-bg-hover: var(--secondary-bg-hover);
}

.btn--ghost {
    --btn-bg: transparent;
    --btn-border: transparent;
    box-shadow: none;
}

.btn--danger {
    --btn-bg: var(--danger);
    --btn-fg: #ffffff;
    --btn-border: var(--danger);
    --btn-bg-hover: var(--danger-hover);
}

.btn--danger-quiet {
    --btn-fg: var(--danger);
    --btn-bg-hover: var(--danger-soft);
}

.btn--sm {
    min-height: 32px;
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 0.875rem;
}

.btn--sm svg {
    width: 16px;
    height: 16px;
}

.btn--lg {
    min-height: 48px;
    padding: 12px 24px;
    font-size: 1rem;
}

.btn--block {
    width: 100%;
}

.btn--icon {
    width: 40px;
    padding: 0;
}

.btn--icon.btn--sm {
    width: 32px;
}

.btn.is-busy {
    color: transparent;
    pointer-events: none;
}

.btn.is-busy::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--btn-fg);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@media (pointer: coarse) {
    .btn {
        min-height: 44px;
    }

    .btn--sm {
        min-height: 44px;
    }

    .btn--icon {
        width: 44px;
    }
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 3px;
}

.link-button:hover {
    color: var(--brand-ink);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.field + .field,
.field + .check,
.check + .field,
.form-grid + .field,
.field + .form-grid {
    margin-top: 16px;
}

.field__label,
.field > label {
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
}

.field__optional {
    color: var(--text-3);
    font-weight: 400;
}

.field__hint {
    color: var(--text-3);
    font-size: var(--fs-sm);
    line-height: 1.45;
}

.field__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field__row a {
    font-size: var(--fs-sm);
}

.input {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem; /* 16px avoids iOS zoom on focus */
    line-height: 1.4;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
    appearance: none;
}

.input::placeholder {
    color: var(--text-4);
}

.input:hover {
    border-color: color-mix(in srgb, var(--text) 30%, transparent);
}

.input:focus,
.input:focus-visible {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-glow);
}

.input:disabled,
.input[readonly] {
    background: var(--surface-muted);
    color: var(--text-3);
}

textarea.input {
    min-height: 96px;
    resize: vertical;
}

select.input {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23888' d='m7.4 9.4 4.6 4.6 4.6-4.6L18 10.8l-6 6-6-6z'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 18px;
}

.input.invalid,
.input[aria-invalid="true"] {
    border-color: var(--danger);
}

.input.invalid:focus {
    box-shadow: 0 0 0 4px var(--danger-soft);
}

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

.validation-message,
.field__error {
    color: var(--danger);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.validation-errors {
    display: grid;
    gap: 4px;
    margin: 0 0 16px;
    padding: 12px 16px 12px 32px;
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 0.875rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    padding: 0;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Checkbox & radio */
.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9375rem;
}

.check input[type="checkbox"],
.check input[type="radio"],
input[type="checkbox"].check__box {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    accent-color: var(--brand-ink);
    cursor: pointer;
}

.check__text {
    display: grid;
    gap: 2px;
}

.check__text small {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

/* Switch: <label class="switch"><input type="checkbox" role="switch"><span class="switch__track"></span> Text</label> */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch__track {
    position: relative;
    flex: none;
    width: 44px;
    height: 26px;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
    transition: background-color 0.2s var(--ease);
}

.switch__track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s var(--ease);
}

.switch input:checked + .switch__track {
    background: var(--secondary-bg);
}

.switch input:checked + .switch__track::after {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch__track {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--brand-glow);
}

.switch input:disabled + .switch__track {
    opacity: 0.5;
}

/* Segmented control */
.segmented {
    display: inline-flex;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar {
    display: none;
}

.segmented button,
.segmented a {
    display: inline-flex;
    flex: 1 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-3);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented button:hover,
.segmented a:hover {
    color: var(--text);
}

.segmented [aria-pressed="true"],
.segmented [aria-selected="true"],
.segmented [aria-current="page"],
.segmented .is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.segmented__count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--surface-hover);
    color: var(--text-3);
    font-size: var(--fs-sm);
    line-height: 20px;
    text-align: center;
}

.segmented--block {
    display: flex;
    width: 100%;
}

.segmented--block button {
    flex: 1 1 0;
}

/* --------------------------------------------------------------------------
   Cards & surfaces
   -------------------------------------------------------------------------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.card__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card__header > div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.card__header h2 {
    font-size: var(--fs-lg);
}

.card__header p {
    color: var(--text-3);
    font-size: 0.875rem;
}

.card__body {
    padding: 24px;
}

.card__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
    .card__header,
    .card__body,
    .card__footer {
        padding-inline: 16px;
    }

    .card__body {
        padding-block: 20px;
    }
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.badge--live {
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.badge--live::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-accent 2s infinite;
}

.badge--success { background: var(--success-soft); color: var(--success-ink); }

.badge--scheduled { background: var(--info-soft); color: var(--info); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }

.badge svg {
    width: 12px;
    height: 12px;
}

/* --------------------------------------------------------------------------
   Alerts, toasts
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface-muted);
    color: var(--text-2);
    font-size: 0.9375rem;
}

.alert svg {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.alert__body {
    display: grid;
    flex: 1;
    gap: 2px;
    min-width: 0;
}

.alert__body strong {
    color: inherit;
    font-weight: 600;
}

.alert--success { background: var(--success-soft); color: var(--success-ink); }
.alert--info { background: var(--info-soft); color: var(--info); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--error { background: var(--danger-soft); color: var(--danger); }

.alert a {
    color: inherit;
    font-weight: 600;
}

.toast-region {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 200;
    display: grid;
    justify-items: center;
    gap: 8px;
    width: min(calc(100% - 32px), 440px);
    transform: translateX(-50%);
    pointer-events: none;
}

/* Reset UA popover styles; the region is a manual popover so it can sit in the top layer. */
.toast-region[popover] {
    inset: auto;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    margin: 0;
    padding: 0;
    border: 0;
    overflow: visible;
    background: transparent;
    color: inherit;
}

.toast-region[popover]:not(:popover-open) {
    display: grid;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    width: fit-content;
    max-width: 100%;
    padding: 10px 10px 10px 16px;
    border-radius: var(--radius);
    background: var(--primary-bg);
    color: var(--primary-fg);
    font-size: 0.9375rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in 0.25s var(--ease);
}

.toast svg {
    flex: none;
    width: 18px;
    height: 18px;
}

.toast--success svg { color: var(--accent); }
.toast--error svg { color: var(--danger); }

.toast button {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-left: 4px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    opacity: 0.7;
}

.toast button:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--primary-fg) 14%, transparent);
}

/* --------------------------------------------------------------------------
   Dialog (native <dialog>, opened with showModal)
   -------------------------------------------------------------------------- */
.dialog {
    width: min(calc(100% - 32px), 480px);
    max-height: calc(100dvh - 48px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}

.dialog--wide {
    width: min(calc(100% - 32px), 640px);
}

.dialog[open] {
    animation: dialog-in 0.2s var(--ease);
}

.dialog::backdrop {
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.dialog__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 24px 0;
}

.dialog__header > div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.dialog__header h2 {
    font-size: 1.25rem;
    overflow-wrap: anywhere;
}

.dialog__body {
    display: grid;
    gap: 16px;
    padding: 16px 24px 24px;
    color: var(--text-2);
}

.dialog__footer {
    display: flex;
    flex-wrap: wrap-reverse;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
}

.dialog__close {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: -6px -8px 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
}

.dialog__close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.dialog__close svg {
    width: 20px;
    height: 20px;
}

@media (max-width: 560px) {
    .dialog {
        width: 100%;
        max-width: 100%;
        max-height: calc(100dvh - 24px);
        margin: auto 0 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .dialog__header,
    .dialog__body,
    .dialog__footer {
        padding-inline: 16px;
    }

    .dialog__footer .btn {
        flex: 1 1 auto;
    }
}

/* --------------------------------------------------------------------------
   Empty states, skeletons, tables, description lists
   -------------------------------------------------------------------------- */
.empty-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 48px 24px;
    text-align: center;
}

.empty-state__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    background: var(--brand-soft);
    color: var(--brand-ink);
}

.empty-state__icon svg {
    width: 24px;
    height: 24px;
}

.empty-state p {
    max-width: 360px;
    color: var(--text-3);
    font-size: 0.9375rem;
}

.empty-state .btn {
    margin-top: 8px;
}

.skeleton {
    display: block;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-muted) 0%, var(--surface-hover) 50%, var(--surface-muted) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--text-3);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

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

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover td {
    background: var(--bg-subtle);
}

.details-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.details-list > div {
    display: grid;
    grid-template-columns: minmax(96px, 140px) 1fr;
    gap: 12px;
    font-size: 0.9375rem;
}

.details-list dt {
    color: var(--text-3);
}

.details-list dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Blazor framework UI
   -------------------------------------------------------------------------- */
#blazor-error-ui {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 12px;
    width: min(calc(100% - 32px), 520px);
    padding: 12px 12px 12px 16px;
    border-radius: var(--radius);
    background: var(--danger);
    color: #ffffff;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
}

/* Blazor shows this element by setting display:block inline. */
#blazor-error-ui[style*="block"] {
    display: flex !important;
}

#blazor-error-ui .reload {
    margin-left: auto;
    color: #ffffff;
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    font-size: 1.25rem;
    line-height: 1;
}

#blazor-error-ui .dismiss:hover {
    background: rgba(255, 255, 255, 0.15);
}

.blazor-error-boundary {
    padding: 16px;
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger);
}

.blazor-error-boundary::after {
    content: "Something went wrong while showing this section. Reload the page to try again.";
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 var(--brand-glow); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes pulse-accent {
    0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.45); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

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