/*
 * PokerEngine Admin SPA stylesheet.
 *
 * Tokens mirror design-system/pokerengine-admin/MASTER.md exactly.
 * Page-specific overrides (login full-page card, tables data-grid)
 * live in the same file under the `[data-state]` attribute scope on
 * #admin-app so the SPA bootstrap can switch between modes without
 * an extra stylesheet load.
 *
 * Anti-patterns enforced (per MASTER.md "Anti-Patterns"):
 *   - No light mode default — admin is dark-only by brand decision.
 *   - Gold reserved for primary CTAs + focus states only.
 *   - No emojis as icons (SVG Heroicons stroke-1.5 inline in admin.js).
 *   - cursor: pointer on every clickable element.
 *   - 180ms transitions on color/border/box-shadow only — never on size.
 *   - prefers-reduced-motion honoured at the bottom of the file.
 */

:root {
    /* Color palette — PokerEngine brand (MASTER.md §Color Palette) */
    --color-background: #0B0B14;
    --color-surface: #14141F;
    --color-border: #2A2A3F;
    --color-accent: #F5C842;
    --color-accent-hover: #FFD55A;
    --color-text: #FFFFFF;
    --color-text-secondary: #9CA3AF;
    --color-text-muted: #6B7280;
    --color-success: #10B981;
    --color-danger: #EF4444;
    --color-warning: #F59E0B;
    --color-ring: #F5C842;

    /* Typography */
    --font-sans: "Poppins", system-ui, sans-serif;
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 24px;
    --text-2xl: 32px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-base: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 0 3px rgba(245, 200, 66, 0.25);

    --sidebar-width: 240px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-background);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button { font-family: inherit; }

/* ───────────────────────── Logo (split-color) ─────────────────────────── */

.logo {
    font-family: var(--font-sans);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.01em;
    line-height: 1;
}
.logo-accent { color: var(--color-accent); }

/* ───────────────────────── Buttons ─────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: var(--text-base);
    border: 0;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
    line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 0; box-shadow: var(--shadow-glow); }

.btn--primary {
    background: var(--color-accent);
    color: #14141F;
    font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: var(--color-accent-hover); }

.btn--secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn--secondary:hover:not(:disabled) {
    background: var(--color-surface);
    border-color: var(--color-text-muted);
}

.btn--danger {
    background: var(--color-danger);
    color: #FFFFFF;
    font-weight: 600;
}
.btn--danger:hover:not(:disabled) { background: #DC2626; }

.btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
}
.btn--icon:hover:not(:disabled) {
    border-color: var(--color-border);
    color: var(--color-text);
}

/* ───────────────────────── Inputs ──────────────────────────────────────── */

.field { display: block; margin-bottom: var(--space-base); }
.field__label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
}
.field__hint {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}
.field__error {
    display: block;
    font-size: var(--text-sm);
    color: var(--color-danger);
    margin-top: var(--space-xs);
    min-height: 1em;
}

.input,
.select {
    width: 100%;
    background: var(--color-background);
    color: var(--color-text);
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}
.input::placeholder { color: var(--color-text-muted); }
.input:focus,
.select:focus {
    outline: 0;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-glow);
}
.input[aria-invalid="true"],
.select[aria-invalid="true"] { border-color: var(--color-danger); }

/* Polished select chrome. The native OS
   chevron differs across Chrome / Safari / Firefox and clashes with
   the rest of the admin's hand-painted controls. Replace it with a
   single inline-SVG chevron in the accent colour so every dropdown in
   the admin (Settings tournament layouts, Bots persona, Bot schedules
   assigned table) inherits a coherent look. */
.select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5l5-5' stroke='%23d4af37' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 8px;
    cursor: pointer;
}
.select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-base);
}
.checkbox-row input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--color-accent);
    cursor: pointer;
}

/* ───────────────────────── Boot loader / login ─────────────────────────── */

.boot-loader {
    min-height: 100vh;
    display: grid;
    place-items: center;
    text-align: center;
    gap: var(--space-base);
}
.boot-loader__hint {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin: var(--space-md) 0 0;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-base);
}
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-xl);
    width: 100%;
    max-width: 400px;
}
.login-card .logo { font-size: var(--text-2xl); display: block; text-align: center; }
.login-card__subtitle {
    margin: var(--space-base) 0 var(--space-xl);
    text-align: center;
    color: var(--color-text-secondary);
    font-size: var(--text-lg);
    font-weight: 400;
}
.login-card .btn { width: 100%; margin-top: var(--space-sm); }

/* ───────────────────────── Dashboard shell ─────────────────────────────── */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    /* Height (not just min-height) so
       .main becomes the scroll container (overflow:auto inside .main).
       Without this, body scrolls and sticky elements inside .main
       never engage. */
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: var(--space-lg) var(--space-base);
    display: flex;
    flex-direction: column;
    gap: var(--space-base);
}
.sidebar__brand {
    font-size: var(--text-xl);
    margin-bottom: var(--space-lg);
}
.sidebar__nav { display: flex; flex-direction: column; gap: var(--space-xs); flex: 1; }

/* Nav items are <button> elements — explicit reset of browser-default
 * background / border so the at-rest state is transparent. Without this
 * Chrome / Safari render a light gray button face that clashes with
 * the dark sidebar surface. */
.sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 10px var(--space-md);
    background: transparent;
    color: var(--color-text-secondary);
    font: inherit;
    font-weight: 500;
    text-align: left;
    border: 0;
    border-left: 3px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.sidebar__link:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
}
.sidebar__link[aria-current="page"] {
    color: var(--color-text);
    border-left-color: var(--color-accent);
    background: rgba(245, 200, 66, 0.06);
}
.sidebar__link:focus-visible {
    outline: 0;
    box-shadow: var(--shadow-glow);
}

/* Footer block: stacked "Logged in as / <username>" pair above a
 * dedicated Sign out button. Replaces the prior single combined
 * button (which rendered "Sign out admin" inline and looked broken). */
.sidebar__footer {
    margin-top: auto;
    padding: var(--space-base) 0 0;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--space-md);
}
.user-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.user-name {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: 500;
}
.signout-button {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 8px var(--space-base);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.signout-button:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}
.signout-button:focus-visible {
    outline: 0;
    box-shadow: var(--shadow-glow);
}

.main {
    padding: var(--space-xl);
    overflow: auto;
    min-width: 0;
}
.main__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-base);
}
.main__title { font-size: var(--text-2xl); font-weight: 700; margin: 0; }

.banner {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: var(--color-warning);
    padding: var(--space-md) var(--space-base);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: var(--text-sm);
}

/* ───────────────────────── Drawer (mobile sidebar) ─────────────────────── */

.drawer-toggle {
    display: none;
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
}

@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }
    .drawer-toggle { display: inline-flex; align-items: center; gap: var(--space-sm); }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 280px;
        max-width: 80vw;
        z-index: 80;
        transform: translateX(-110%);
        transition: transform 200ms ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar[data-open="true"] { transform: translateX(0); }
    .sidebar-scrim {
        position: fixed; inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 70;
    }
    .main { padding: var(--space-lg) var(--space-base); }
}

/* ───────────────────────── Data table ──────────────────────────────────── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* `.card` keeps `overflow: hidden` for
 * radius corners, so the DataTable lives inside a `.card--scroll`
 * variant that allows horizontal scroll on narrow viewports. The
 * data-table itself has a min-width so 6 columns stay readable; on
 * mobile the user pans horizontally instead of seeing truncated cells. */
.card--scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
}
.data-table thead th {
    text-align: left;
    color: var(--color-text-muted);
    font-weight: 500;
    padding: 12px var(--space-base);
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
}
.data-table tbody td {
    color: var(--color-text);
    padding: 14px var(--space-base);
    border-bottom: 1px solid var(--color-border);
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.data-table .actions-cell { text-align: right; white-space: nowrap; }
.data-table .actions-cell .btn--icon { margin-left: var(--space-xs); }
.data-table .muted { color: var(--color-text-muted); }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 500;
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}
.chip--accent {
    color: var(--color-accent);
    border-color: rgba(245, 200, 66, 0.3);
    background: rgba(245, 200, 66, 0.06);
}
.chip--ok {
    color: #5fbf5f;
    border-color: rgba(95, 191, 95, 0.3);
    background: rgba(95, 191, 95, 0.08);
}
.chip--muted {
    color: var(--color-text-muted);
    border-color: rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}
/* Status dot prefix on chips (e.g. "● Active now") */
.chip--with-dot::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    margin-right: 6px;
    flex-shrink: 0;
}

/* ───────────────────────── Bot schedules editor ─────────────────────────── */

/* Section grouping with subtle divider between subsections (Mode / Custom /
   Vacation / Pin). First section never has a top divider. */
.schedule-section {
    padding-top: var(--space-base);
    margin-top: var(--space-base);
    border-top: 1px solid var(--color-border);
}
.schedule-section:first-child {
    padding-top: 0;
    margin-top: 0;
    border-top: 0;
}
.schedule-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}
.schedule-section__title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}
.schedule-section__hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-md);
    line-height: 1.5;
}

/* Preset card grid — auto-fit avoids modal horizontal overflow (5 cards × min-width vs 520px modal). */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-sm);
}

.preset-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: var(--space-md);
    min-height: 76px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--color-text);
    transition: border-color 180ms ease, background-color 180ms ease;
}
.preset-card:hover { border-color: var(--color-text-muted); }
.preset-card:focus-visible { outline: 0; box-shadow: var(--shadow-glow); }
.preset-card--selected {
    border-color: rgba(245, 200, 66, 0.45);
    background: rgba(245, 200, 66, 0.06);
}
.preset-card__icon {
    color: var(--color-text-muted);
    transition: color 180ms ease;
}
.preset-card--selected .preset-card__icon { color: var(--color-accent); }
.preset-card__label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.25;
}
.preset-card__hint {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.3;
}
.preset-card__check {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    color: var(--color-accent);
    opacity: 0;
    transition: opacity 180ms ease;
}
.preset-card--selected .preset-card__check { opacity: 1; }

/* Custom pattern day rows */
.schedule-days {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 var(--space-sm);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.schedule-day-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--color-border);
}
.schedule-day-row:last-child { border-bottom: 0; }
.schedule-day__rail {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 96px;
    flex-shrink: 0;
}
.schedule-day__dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--color-border);
    transition: background-color 180ms ease;
    flex-shrink: 0;
}
.schedule-day__dot--active { background: var(--color-success); }
.schedule-day__label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}
.schedule-day__ranges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    flex: 1;
}
.schedule-day__off {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-style: italic;
}

.schedule-range-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px 2px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.schedule-range-pill .input {
    width: 78px;
    padding: 2px 4px;
    font-size: var(--text-xs);
    background: transparent;
    border: 0;
    color: var(--color-text);
}
.schedule-range-pill .input:focus {
    box-shadow: none;
    border: 0;
    outline: 0;
}
.schedule-range-pill__sep {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}
.schedule-range-pill__remove {
    background: transparent;
    border: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 4px;
    font-size: 16px;
    line-height: 1;
    transition: color 180ms ease;
    border-radius: var(--radius-sm);
}
.schedule-range-pill__remove:hover { color: var(--color-danger); }
.schedule-range-pill__remove:focus-visible { outline: 0; box-shadow: var(--shadow-glow); }

.schedule-add-range {
    background: transparent;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color 180ms ease, color 180ms ease;
    font-family: inherit;
}
.schedule-add-range:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.schedule-add-range:focus-visible { outline: 0; box-shadow: var(--shadow-glow); }
.schedule-add-range:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* iOS-style toggle switch — 44px tap target via vertical padding */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
    padding: 12px 0;
}
.toggle-switch__input {
    /* sr-only checkbox containing-block:
       position absolute MUST coexist with top:0 + left:0 inside a
       position-relative parent OR focus auto-scroll hijacks the page. */
    position: absolute;
    top: 0; left: 0;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.toggle-switch__track {
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    position: relative;
    transition: background-color 200ms ease, border-color 200ms ease;
    flex-shrink: 0;
}
.toggle-switch__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--color-text-muted);
    border-radius: 50%;
    transition: transform 200ms ease, background-color 200ms ease;
}
.toggle-switch__input:checked ~ .toggle-switch__track {
    background: rgba(245, 200, 66, 0.2);
    border-color: rgba(245, 200, 66, 0.5);
}
.toggle-switch__input:checked ~ .toggle-switch__track .toggle-switch__thumb {
    transform: translateX(16px);
    background: var(--color-accent);
}
.toggle-switch__input:focus-visible ~ .toggle-switch__track {
    box-shadow: var(--shadow-glow);
}
.toggle-switch__label {
    font-size: var(--text-sm);
    color: var(--color-text);
    line-height: 1.3;
}

/* Persona generator toolbar — sits above the day grid in the
   custom section. Buttons are smaller than preset cards (single
   row icon + label) to clearly read as "secondary action" vs
   the schedule mode primary radio above. */
.persona-toolbar {
    margin-bottom: var(--space-md);
}
.persona-toolbar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    gap: var(--space-sm);
}
.persona-toolbar__title {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
/* Persona toolbar — auto-fit wraps 5 buttons to 2 rows in 520px modal. */
.persona-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
}
.persona-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--color-text);
    transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}
.persona-btn:hover {
    border-color: var(--color-text-muted);
    background: rgba(255, 255, 255, 0.03);
}
.persona-btn:active { transform: scale(0.98); }
.persona-btn:focus-visible { outline: 0; box-shadow: var(--shadow-glow); }
.persona-btn__icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
    transition: color 180ms ease;
}
.persona-btn:hover .persona-btn__icon { color: var(--color-accent); }
.persona-btn__body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.persona-btn__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.persona-btn__hint {
    font-size: 10px;
    color: var(--color-text-muted);
    line-height: 1.2;
}
.persona-clear {
    background: transparent;
    border: 0;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color 180ms ease, background-color 180ms ease;
    font-family: inherit;
}
.persona-clear:hover {
    color: var(--color-danger);
    background: rgba(239, 68, 68, 0.06);
}
.persona-clear:focus-visible { outline: 0; box-shadow: var(--shadow-glow); }

/* Mobile : day rail wraps above ranges if narrow */
@media (max-width: 480px) {
    .schedule-day-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-xs);
    }
    .schedule-day__rail { min-width: 0; }
}

.empty-state {
    padding: var(--space-2xl) var(--space-base);
    text-align: center;
    color: var(--color-text-secondary);
}

/* ───────────────────────── Modal ───────────────────────────────────────── */

.modal-root { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
.modal-root[aria-hidden="false"] { pointer-events: auto; }

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    padding: var(--space-base);
    overflow-y: auto;
}
.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
}
.modal--narrow { max-width: 400px; }
.modal__title {
    font-weight: 700;
    font-size: var(--text-xl);
    margin: 0 0 var(--space-lg);
}
.modal__body { color: var(--color-text-secondary); margin-bottom: var(--space-lg); }
.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-base);
}
@media (max-width: 540px) {
    .field-row { grid-template-columns: 1fr; gap: 0; }
}

/* ───────────────────────── Toast ───────────────────────────────────────── */

.toast-stack {
    position: fixed;
    top: var(--space-base);
    right: var(--space-base);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 200;
    pointer-events: none;
    max-width: calc(100vw - var(--space-xl));
}
.toast {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-accent);
    border-radius: var(--radius-md);
    padding: 12px var(--space-base);
    box-shadow: var(--shadow-md);
    font-size: var(--text-sm);
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    min-width: 240px;
    max-width: 360px;
    animation: toast-in 180ms ease;
}
.toast--success { border-left-color: var(--color-success); }
.toast--danger  { border-left-color: var(--color-danger); }
.toast--warning { border-left-color: var(--color-warning); }
.toast__close {
    margin-left: auto;
    background: transparent;
    color: var(--color-text-muted);
    border: 0;
    font: inherit;
    cursor: pointer;
    padding: 0 var(--space-xs);
}

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

/* ───────────────────────── Settings view ───────────────────────────────── */

.settings-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-base);
    max-width: 720px;
}

.settings-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-base);
    padding-top: var(--space-base);
    border-top: 1px solid var(--color-border);
}

.field--toggle {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
}

/* ─── Settings tab bar ──────────────────────────────────────────────────
   Sober admin tablist pinned to the top of the settings card. Active tab
   marked by a gold inset underline (no layout shift); inactive tabs read
   muted, lift to primary text on hover. On narrow viewports the strip
   scrolls horizontally rather than wrapping into the form. Scoped to
   `.settings-tabs*` so it cannot collide with other admin surfaces. */
.settings-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-base);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    scrollbar-width: thin;
}
.settings-tab {
    appearance: none;
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.2;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    white-space: nowrap;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    box-shadow: inset 0 -2px 0 transparent;
    transition: color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
@media (hover: hover) {
    .settings-tab:hover {
        color: var(--color-text);
        background: var(--surface-hover, var(--color-background));
    }
}
.settings-tab:focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}
.settings-tab[aria-selected="true"] {
    color: var(--color-text);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--color-accent);
}
.settings-tabpanel {
    display: flex;
    flex-direction: column;
    gap: var(--space-base);
}
.settings-tabpanel[hidden] {
    display: none;
}
.settings-tabpanel:focus {
    outline: none;
}
/* The panel's first section sits directly under the tab bar — drop its
   redundant leading divider so the card reads cleanly. */
.settings-tabpanel > .form-section:first-child {
    border-top: 0;
    padding-top: 0;
}
/* Neutral scaffold panels (Licence & Modules, Monitoring) — no controls. */
.form-section--scaffold {
    color: var(--color-text-muted);
}
/* Only General carries the branding live-preview; every other tab is
   full-width with the preview hidden. */
.settings-page__layout:not([data-active-tab="general"]) {
    grid-template-columns: minmax(0, 1fr);
}
.settings-page__layout:not([data-active-tab="general"]) .settings-page__preview {
    display: none;
}
@media (prefers-reduced-motion: reduce) {
    .settings-tab { transition: none; }
}

/* ── Gameplay + Players & Auth: full-width multi-column field layout ──
   These two "classic" tabs carry no live preview, so the form should use
   the whole content width (like the Updates/Backups/Emails module tabs)
   instead of the 720px reading column it inherits from `.settings-form`.
   Section titles, hints, callouts and action rows stay full-width band
   headers; the actual fields flow into a responsive auto-fit grid
   (~2-3 columns on wide desktop, collapsing cleanly to 1 column on narrow
   viewports) to cut vertical scroll. Layout-only — no field name/id,
   validation, payload key, label, toggle or order change. */
.settings-page__layout[data-active-tab="gameplay"] .settings-form,
.settings-page__layout[data-active-tab="players"] .settings-form {
    max-width: none;
}
.settings-page__layout[data-active-tab="gameplay"] .form-section,
.settings-page__layout[data-active-tab="players"] .form-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
    column-gap: var(--space-lg);
    row-gap: var(--space-base);
}
/* Default every direct child to span the full row (titles, hints,
   callouts, the SMTP test action row + its status, the Google secret
   block) so they read as band headers above the field grid… */
.settings-page__layout[data-active-tab="gameplay"] .form-section > *,
.settings-page__layout[data-active-tab="players"] .form-section > * {
    grid-column: 1 / -1;
}
/* …then let only the actual fields flow into the responsive columns. */
.settings-page__layout[data-active-tab="gameplay"] .form-section > .field,
.settings-page__layout[data-active-tab="players"] .form-section > .field {
    grid-column: auto;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px dashed var(--color-border);
}
.form-section__title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
}
.form-section__hint {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* Read-only env-var display in Settings page (Logging & privacy). */
.env-display {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-xs) var(--space-md);
    margin: 0;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.env-display dt {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin: 0;
    align-self: center;
}
.env-display__value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--text-sm);
    color: var(--color-text);
    margin: 0;
    align-self: center;
    overflow-wrap: anywhere;
}

.gauth-secret {
    display: grid;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.gauth-secret__badge {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 4px 9px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.gauth-secret__badge--ok {
    color: #146c43;
    background: rgba(25, 135, 84, 0.12);
    border-color: rgba(25, 135, 84, 0.32);
}
.gauth-secret__badge--warn {
    color: #995400;
    background: rgba(255, 193, 7, 0.16);
    border-color: rgba(255, 193, 7, 0.36);
}
.gauth-secret__badge--unknown {
    color: var(--color-text-muted);
    background: var(--color-surface);
}
.gauth-secret__line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-sm);
    align-items: center;
}
.gauth-secret__code {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

.colour-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.input--picker {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-background);
    cursor: pointer;
    flex-shrink: 0;
}
.input--picker:focus {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
}
.input--hex {
    flex: 1;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.04em;
}

.logo-uploader {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.logo-uploader__row {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    flex-wrap: wrap;
}
.logo-uploader__thumb {
    /* Owner-visible logo preview after upload.
       Was display:none CSS default + JS style.display='' (no-op
       against !important-less default), so the thumb stayed
       invisible even with a valid src. Switch to [hidden] attribute
       drive so JS's removeAttribute('hidden') actually shows it.
       Checkerboard background so a black or
       transparent logo PNG stays visible against the admin's dark
       theme. The image (object-fit: contain) sits on top of the
       pattern; transparent areas of the PNG show the pattern
       through, opaque areas show the logo. */
    max-width: 120px;
    max-height: 80px;
    width: auto;
    height: auto;
    object-fit: contain;
    background-color: #555;
    background-image:
        linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px;
}
.logo-uploader__thumb[hidden] {
    display: none !important;
}
.logo-uploader__meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
    flex: 1;
}
.logo-uploader__input {
    /* Hidden visually but kept accessible — the styled <label> takes
       focus instead. */
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.logo-uploader__input:focus + .logo-uploader__label,
.logo-uploader__label:focus {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
}
.logo-uploader__label {
    align-self: flex-start;
    cursor: pointer;
}
.logo-uploader__status {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    word-break: break-all;
}
.logo-uploader__hint {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}
.logo-uploader__clear {
    align-self: flex-start;
    flex-shrink: 0;
}

/* Settings split-view layout.
   Iframe natively 390×720 (iPhone 14 Pro size) so the lobby's mobile
   media queries fire NATURALLY — no CSS overrides in the player
   page. Wrapper crops + scales the rendered output to a comfortable
   605×1115 visual size on the admin (scale 1.55: 390×1.55=604.5,
   720×1.55=1116). Sticky top:16px so the preview stays visible while
   the operator scrolls the form. */
.settings-page__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 605px;
    gap: var(--space-xl);
    align-items: start;
    width: 100%;
}
.settings-page__layout .settings-form {
    min-width: 0;
}
.settings-page__preview {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.settings-page__preview-hint {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.settings-page__preview-wrapper {
    /* Owner spec v3 — iframe natively 800×430 landscape so the lobby's
       applyMobileViewportScale() (main.js) triggers the scale-to-fit
       pattern (scale 0.741, width 134.884vw, height 134.884vh) shown
       in owner's reference capture. That gives a perfectly arranged
       9-seat table with all plaques visible. Wrapper crops + scales
       the rendered output to ~605×325 visually (scale ≈ 0.756). */
    width: 605px;
    height: 325px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-background);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.settings-preview__iframe {
    width: 800px;
    height: 430px;
    border: 0;
    transform: scale(0.756);
    transform-origin: top left;
    display: block;
}

/* Min-width 1280px for the split layout (per owner spec). Below
   that the iframe wrapper at 605px would overflow alongside any
   reasonable form width — stack vertically instead. */
@media (max-width: 1279px) {
    .settings-page__layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .settings-page__preview {
        position: static;
        max-height: none;
        order: 2;
        align-items: center;
    }
}

/* tableLogoScale slider styling. */
.field--logo-scale .logo-scale__row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.field--logo-scale input[type="range"] {
    flex: 1;
    accent-color: var(--color-accent);
}
.field--logo-scale .logo-scale__value {
    min-width: 3.5em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--color-text);
    text-align: right;
}

.toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
    color: var(--color-text);
}
.toggle input[type="checkbox"] {
    position: absolute;
    top: 0; left: 0;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.toggle__track {
    width: 40px;
    height: 24px;
    border-radius: 9999px;
    background: var(--color-border);
    position: relative;
    transition: background-color 180ms ease;
}
.toggle__track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    background: var(--color-text);
    transition: transform 180ms ease;
}
.toggle input:checked + .toggle__track {
    background: var(--color-accent);
}
.toggle input:checked + .toggle__track::after {
    transform: translateX(16px);
}
.toggle input:focus-visible + .toggle__track {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
}
.toggle__text {
    font-size: var(--text-sm);
}

/* ───────── TablePaletteView full-page refactor ────────────────────────────
   Per-table palette editor moves out of a modal
   into a full-screen admin view so the iframe preview can render the
   table at near-native size (vs ~500px-wide pinned in a modal pane). */

.palette-edit__header {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    flex-wrap: wrap;
    margin-bottom: var(--space-base);
}
.palette-edit__title {
    margin: 0;
    flex: 1 1 auto;
    font-size: var(--text-2xl, 24px);
    font-weight: 600;
}
.palette-edit__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-left: auto;
}
.palette-edit__back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.palette-edit__layout {
    display: grid;
    /* Bias the preview column wider — full-page layout removes the
       modal's 1100px cap so the iframe scales much closer to native. */
    grid-template-columns: minmax(640px, 2.4fr) minmax(280px, 1fr);
    gap: var(--space-lg);
    align-items: start;
}
@media (max-width: 1023px) {
    .palette-edit__layout { grid-template-columns: 1fr; }
}
.palette-edit__preview {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.palette-edit__left-col {
    display: flex;
    flex-direction: column;
    gap: var(--space-base);
}
.palette-edit__text-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-base);
}
@media (max-width: 767px) {
    .palette-edit__text-row { grid-template-columns: 1fr; }
}
.palette-edit__preview-hint {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}
/* The stage clips the iframe + maintains aspect-ratio. The iframe
 * is rendered at fixed desktop dimensions (1440 × 810) and visually
 * scaled DOWN via the --scale CSS variable (set by the JS
 * ResizeObserver in admin.js showTableBrandingModal). This avoids
 * the "pill table" rendering that happens when the lobby's CSS
 * media queries kick in at narrow viewports.
 */
.palette-edit__preview-stage {
    --scale: 0.34;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #05070d;
}
.palette-edit__iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 1440px;
    height: 810px;
    border: 0;
    background: #05070d;
    transform-origin: top left;
    transform: scale(var(--scale));
    /* Disable pointer events so swatch clicks always reach the
       admin form even when they happen over the preview area. The
       preview is a read-only mirror; the lobby inside doesn't need
       interaction. */
    pointer-events: none;
}
.palette-edit__swatches {
    display: flex;
    flex-direction: column;
    /* Tighter vertical rhythm so all 5 categories + watermark
     * input fit in the viewport without scrolling. The container
     * still scrolls if the modal is constrained (very small screens),
     * but at 1440 / 1024 / 956 the full list is visible. */
    gap: var(--space-sm);
    max-height: 78vh;
    overflow-y: auto;
    padding-right: 4px;
}
.swatch-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.swatch-section__title {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-secondary);
}
.palette-edit__chips-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 4px;
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    user-select: none;
}
.palette-edit__chips-toggle-input {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-accent, #d4af37);
}
.swatch-grid {
    display: grid;
    /* 6 columns × 36px swatches replaces the prior 3 × 56px
     * grid. The whole section is now ~50% shorter; 5 sections +
     * watermark input fit comfortably in the modal without scrolling
     * past the fold (owner: "elles sont gigantesques"). */
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}
.swatch {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 36px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background-size: cover;
    background-position: center;
    transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
    padding: 0;
}
.swatch:hover {
    transform: scale(1.06);
    border-color: var(--color-text-secondary);
}
.swatch:focus-visible {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-ring);
}
.swatch.is-active {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(245, 200, 66, 0.45);
}
.swatch--chip {
    border-radius: 50%;
    aspect-ratio: 1 / 1;
}
.swatch-section--watermark .field {
    gap: 4px;
}
.swatch-section--watermark .field__label {
    font-size: 12px;
}
.swatch-section--watermark .field__hint {
    font-size: 11px;
}
.btn--ghost {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}
.btn--ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text);
}

/* ───────────────────────── Reduced motion ─────────────────────────────── */

@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;
    }
}
