/* IPTV admin panel: hand-written, no build step. Tokens first, then layout, then components. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --surface-hover: #f7f8fa;
    --border: #e4e7ec;
    --border-strong: #d0d5dd;
    --text: #101828;
    --text-muted: #5d6679;
    --text-faint: #8a93a6;

    --brand-from: #6366f1;
    --brand-to: #8b5cf6;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --primary-text: #4338ca;

    --success: #079455;
    --success-soft: #e7f8ef;
    --warning: #b54708;
    --warning-soft: #fff4e5;
    --danger: #d92d20;
    --danger-soft: #fef0ef;
    --info: #0b6bcb;
    --info-soft: #e8f2fc;

    --sidebar-bg: #111827;
    --sidebar-text: #aab2c3;
    --sidebar-text-active: #ffffff;
    --sidebar-brand-from: #a5a8ff;
    --sidebar-brand-to: #c4b5fd;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(255, 255, 255, 0.1);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.18);
    --player-bg: #000;
    --player-text: rgba(255, 255, 255, 0.85);
    --focus: 0 0 0 3px rgba(79, 70, 229, 0.25);

    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, monospace;
}

/* Dark theme. data-theme on <html> (switcher, App\Support\Theme): "system" follows the OS,
   "light"/"dark" force a mode. The two blocks below must stay identical. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0d12;
        --surface: #12151c;
        --surface-2: #181c25;
        --surface-hover: #161a22;
        --border: #232835;
        --border-strong: #2f3646;
        --text: #eceef3;
        --text-muted: #9aa3b5;
        --text-faint: #6b7385;

        --primary: #6366f1;
        --primary-hover: #7c7ff5;
        --primary-soft: rgba(99, 102, 241, 0.14);
        --primary-text: #a5a8ff;

        --success: #3ccb7f;
        --success-soft: rgba(60, 203, 127, 0.12);
        --warning: #f5a524;
        --warning-soft: rgba(245, 165, 36, 0.12);
        --danger: #f97066;
        --danger-soft: rgba(249, 112, 102, 0.12);
        --info: #53a8f5;
        --info-soft: rgba(83, 168, 245, 0.12);

        --sidebar-bg: #0e1117;
        --shadow-sm: none;
        --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
        --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
        --player-bg: #000;
        --player-text: rgba(255, 255, 255, 0.85);
        --focus: 0 0 0 3px rgba(99, 102, 241, 0.35);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0d12;
    --surface: #12151c;
    --surface-2: #181c25;
    --surface-hover: #161a22;
    --border: #232835;
    --border-strong: #2f3646;
    --text: #eceef3;
    --text-muted: #9aa3b5;
    --text-faint: #6b7385;

    --primary: #6366f1;
    --primary-hover: #7c7ff5;
    --primary-soft: rgba(99, 102, 241, 0.14);
    --primary-text: #a5a8ff;

    --success: #3ccb7f;
    --success-soft: rgba(60, 203, 127, 0.12);
    --warning: #f5a524;
    --warning-soft: rgba(245, 165, 36, 0.12);
    --danger: #f97066;
    --danger-soft: rgba(249, 112, 102, 0.12);
    --info: #53a8f5;
    --info-soft: rgba(83, 168, 245, 0.12);

    --sidebar-bg: #0e1117;
    --shadow-sm: none;
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
    --player-bg: #000;
    --player-text: rgba(255, 255, 255, 0.85);
    --focus: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.icon { width: 18px; height: 18px; flex-shrink: 0; }
code, .mono { font-family: var(--mono); font-size: 0.85em; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 14px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 22px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
    color: #fff;
}

/* "Nebo" + gradient "TV" wordmark (x-brand-name) */
.brand-name { font-weight: 800; letter-spacing: -0.02em; }
.brand-accent {
    background: linear-gradient(135deg, var(--brand-from), var(--brand-to));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.sidebar .brand-accent { background-image: linear-gradient(135deg, var(--sidebar-brand-from), var(--sidebar-brand-to)); }

.nav-section {
    padding: 18px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7385;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--sidebar-text);
    font-weight: 500;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-link .count {
    margin-left: auto;
    font-size: 12px;
    color: #6b7385;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}
.sidebar .avatar { background: rgba(255, 255, 255, 0.1); color: #fff; }

.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user strong { display: block; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { font-size: 12px; color: #6b7385; }

.main { min-width: 0; padding: 32px 40px 64px; }
.container { max-width: 1240px; margin: 0 auto; }
.container-narrow { max-width: 820px; margin: 0 auto; }

.topbar { display: none; }
.nav-overlay { display: none; }

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-header p { color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}
.breadcrumb svg.icon { width: 15px; height: 15px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none !important;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn svg.icon { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-hover); }

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

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-block { width: 100%; }

.inline-form { display: inline; margin: 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-header p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-main > .card + .card, .grid-2 > .card + .card, .stats > .card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack > .card + .card { margin-top: 0; }

/* ---------- Stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat { padding: 18px 20px; }
.stat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}
.stat-label svg.icon { width: 16px; height: 16px; color: var(--text-faint); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.stat-meta { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table .shrink { width: 1%; white-space: nowrap; }
.table .right { text-align: right; }
.table .actions { display: flex; justify-content: flex-end; gap: 4px; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius-lg); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--radius-lg); }

.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--text-faint); font-size: 12.5px; }
.cell-flex { display: flex; align-items: center; gap: 12px; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

.logo-thumb {
    width: 40px;
    height: 28px;
    border-radius: 5px;
    object-fit: contain;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.logo-fallback {
    display: grid;
    place-items: center;
    width: 40px;
    height: 28px;
    border-radius: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--text-muted);
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 13px; color: var(--text); }
.label .optional { font-weight: 400; color: var(--text-faint); }
.help { color: var(--text-faint); font-size: 12.5px; }
.field-error { color: var(--danger); font-size: 12.5px; }

.input, .select, .textarea {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; padding: 10px 12px; min-height: 90px; resize: vertical; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a93a6' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input[type="file"] { height: auto; padding: 8px; }

.input-group { position: relative; }
.input-group svg.icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); width: 16px; height: 16px; pointer-events: none; }
.input-group .input { padding-left: 34px; }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; cursor: pointer; }
.check strong { display: block; font-weight: 600; }
.check span { color: var(--text-muted); font-size: 13px; }

.check-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    max-height: 340px;
    overflow-y: auto;
    padding: 2px;
}
.check-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.check-tile:hover { background: var(--surface-hover); }
.check-tile:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check-tile input { width: 16px; height: 16px; accent-color: var(--primary); }
.check-tile .name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-tile .faint { font-size: 12px; }

.segmented {
    align-self: flex-start;
    display: inline-flex;
    padding: 3px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    gap: 2px;
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 7px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- Toolbar / filters ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.toolbar .input-group { flex: 1 1 220px; max-width: 320px; }
.toolbar .select { width: auto; min-width: 140px; height: 34px; font-size: 13px; }
.toolbar .input { height: 34px; font-size: 13px; }
.toolbar .spacer { flex: 1; }

.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.bulk-bar strong { color: var(--primary-text); }
.bulk-bar .select { width: auto; height: 32px; font-size: 13px; }

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert svg.icon { margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; font-weight: 400; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert .alert-body { flex: 1; }
.alert .alert-close { background: none; border: 0; color: inherit; opacity: 0.6; cursor: pointer; padding: 0; }
.alert .alert-close:hover { opacity: 1; }

/* ---------- Empty state ---------- */
.empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text-faint);
    margin-bottom: 12px;
}
.empty-icon svg.icon { width: 22px; height: 22px; }
.empty h3 { color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }

.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; font-weight: 500; }

/* ---------- Copy field ---------- */
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-family: var(--mono); font-size: 13px; background: var(--surface-2); }

.steps { margin: 0; padding-left: 20px; color: var(--text-muted); }
.steps li { margin-bottom: 6px; }
.steps strong { color: var(--text); }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .page {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 7px;
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    background: var(--surface);
}
.pagination a.page:hover { background: var(--surface-hover); text-decoration: none; }
.pagination .page.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page.disabled { color: var(--text-faint); background: transparent; }

/* ---------- Dialog ---------- */
dialog.modal {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(10, 12, 18, 0.5); backdrop-filter: blur(2px); }
dialog.modal form { margin: 0; }
dialog.modal-wide { width: min(880px, calc(100vw - 32px)); }

/* Channel preview player (channels index) */
.player { position: relative; background: var(--player-bg); aspect-ratio: 16 / 9; }
.player video { display: block; width: 100%; height: 100%; background: var(--player-bg); }
.player-status {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    padding: 24px; text-align: center;
    color: var(--player-text); font-size: 14px;
    pointer-events: none;
}
.player-status[hidden] { display: none; }

/* ---------- Auth ---------- */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(60rem 30rem at 50% -10%, var(--primary-soft), transparent),
        var(--bg);
}
.auth-card { width: min(400px, 100%); }
.auth-card .card-body { padding: 28px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.auth-brand h1 { font-size: 20px; font-weight: 700; }
.auth-brand p { color: var(--text-muted); }

/* ---------- Preferences: language menu + theme switch (partials/preferences) ---------- */
.prefs { display: flex; align-items: center; gap: 6px; }
.lang-menu { position: relative; flex: 1; min-width: 0; }
.lang-current {
    display: flex; align-items: center; gap: 7px;
    height: 32px; padding: 0 8px;
    border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--surface); color: var(--text);
    font-size: 13px; font-weight: 500; cursor: pointer; list-style: none; user-select: none;
}
.lang-current::-webkit-details-marker { display: none; }
.lang-current:focus-visible { outline: none; box-shadow: var(--focus); }
.lang-current .chevron { width: 13px; height: 13px; margin-left: auto; color: var(--text-faint); transition: transform 0.15s; }
.lang-menu[open] .chevron { transform: rotate(180deg); }
.flag { width: 20px; height: 14px; border-radius: 2px; object-fit: cover; flex-shrink: 0; box-shadow: 0 0 0 1px var(--border); }
.lang-options {
    position: absolute; z-index: 30; left: 0; top: calc(100% + 6px);
    min-width: 100%; margin: 0; padding: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.lang-option {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; white-space: nowrap; cursor: pointer;
}
.lang-option:hover, .lang-option:focus-visible { background: var(--surface-hover); outline: none; }
.lang-option[aria-current] { font-weight: 600; }
.lang-check { width: 15px; height: 15px; margin-left: auto; color: var(--primary); }

.theme-switch { display: flex; gap: 1px; margin: 0; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); flex-shrink: 0; }
.theme-switch button {
    display: grid; place-items: center; width: 24px; height: 26px;
    border: 0; border-radius: 6px; background: none; color: var(--text-faint); cursor: pointer;
}
.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button:focus-visible { outline: none; box-shadow: var(--focus); }
.theme-switch button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-text); }

/* In the (always dark) sidebar: open upwards, sidebar colours */
.sidebar .prefs { margin: auto 0 12px; }
.sidebar .prefs ~ .sidebar-footer { margin-top: 0; }
.sidebar .lang-current, .sidebar .theme-switch { background: var(--sidebar-hover); border-color: transparent; color: var(--sidebar-text); }
.sidebar .lang-current .chevron, .sidebar .theme-switch button { color: var(--sidebar-text); }
.sidebar .theme-switch button:hover { color: var(--sidebar-text-active); }
.sidebar .theme-switch button[aria-pressed="true"] { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.sidebar .flag { box-shadow: none; }
.sidebar .lang-options { top: auto; bottom: calc(100% + 6px); }

.auth .prefs { justify-content: center; margin-top: 16px; }
.auth .lang-menu { flex: 0 1 170px; }

/* ---------- Alerts: header bell (partials/notifications) ---------- */
.header-bar { display: flex; justify-content: flex-end; padding: 16px 40px 0; }
.header-bar + .main { padding-top: 8px; }
.topbar-end { margin-left: auto; }
.notif-menu { position: relative; --notif-ring: var(--bg); }
.topbar .notif-menu { --notif-ring: var(--surface); }
.notif-button {
    position: relative; list-style: none;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--surface); border-color: var(--border); color: var(--text-muted); box-shadow: var(--shadow-sm);
    transition: background-color .15s, border-color .15s, color .15s;
}
.notif-button::-webkit-details-marker { display: none; }
.notif-button svg.icon { width: 18px; height: 18px; transform-origin: 50% 2px; }
.notif-button:hover { border-color: var(--border-strong); color: var(--text); }
.notif-button:hover svg.icon { animation: notif-ring .6s ease-in-out; }
.notif-button.has-unread { color: var(--text); }
.notif-menu[open] > .notif-button { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); }
.notif-count {
    position: absolute; top: -5px; right: -6px;
    min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
    border: 2px solid var(--notif-ring);
    background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
    font-variant-numeric: tabular-nums;
}
.notif-panel {
    position: absolute; z-index: 40; right: 0; top: calc(100% + 10px);
    width: min(360px, calc(100vw - 32px));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform-origin: top right;
    animation: notif-open .14s ease-out;
}
@keyframes notif-open { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes notif-ring {
    0%, 100% { transform: rotate(0); }
    20% { transform: rotate(14deg); }
    40% { transform: rotate(-12deg); }
    60% { transform: rotate(8deg); }
    80% { transform: rotate(-4deg); }
}
@media (prefers-reduced-motion: reduce) {
    .notif-button:hover svg.icon, .notif-panel { animation: none; }
}
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border); }
.notif-panel .list { max-height: 360px; overflow-y: auto; }
.notif-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 14px; color: var(--text-muted); text-align: center; }
.notif-empty p { margin: 0; }
.notif-empty-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--text-faint); }
.notif-empty-icon svg.icon { width: 20px; height: 20px; }
.notif-all { display: block; padding: 10px 14px; border-top: 1px solid var(--border); text-align: center; font-weight: 500; }
.alert-item { display: flex; align-items: flex-start; gap: 10px; }
.alert-item.unread { background: var(--primary-soft); }
.alert-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; flex-shrink: 0; }
.alert-dot.is-problem { background: var(--danger); }
.alert-dot.is-ok { background: var(--success); }
.watch-icon { width: 14px; height: 14px; color: var(--warning); vertical-align: -2px; }

/* ---------- Xtream login details (users/show) ---------- */
.login-fields { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px 14px; align-items: center; }
.login-fields .label { margin: 0; }
.login-password { color: var(--text-muted); }
@media (max-width: 520px) {
    .login-fields { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .login-fields .copy-field, .login-password { margin-bottom: 8px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 260px;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.nav-open .nav-overlay { display: block; }
    .nav-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(10, 12, 18, 0.5); }
    .topbar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 30;
        padding: 10px 16px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        font-weight: 700;
    }
    .main { padding: 20px 16px 48px; }
    .header-bar { display: none; }
    .header-bar + .main { padding-top: 20px; }
    .page-header { flex-direction: column; }
    .form-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .dl dd { margin-bottom: 8px; }
    .toolbar .input-group { max-width: none; }
    .hide-sm { display: none; }
}

@media (max-width: 520px) {
    .stats { grid-template-columns: minmax(0, 1fr); }
    .copy-field { flex-direction: column; }
}
