:root {
    --bg: #0c1222;
    --bg-elevated: #111827;
    --sidebar: #0f1629;
    --card: #151d32;
    --card-hover: #1a2440;
    --border: rgba(148, 163, 184, 0.12);
    --border-strong: rgba(148, 163, 184, 0.22);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-soft: rgba(59, 130, 246, 0.12);
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --sidebar-width: 280px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #60a5fa; }

code {
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.9em;
    word-break: break-all;
}

/* ── Portal layout ── */
.portal {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.sidebar-brand strong {
    display: block;
    font-size: 15px;
    line-height: 1.3;
}

.sidebar-brand span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary-soft);
    color: #93c5fd;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.sidebar-device {
    padding: 16px;
    margin: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.sidebar-device .label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.device-field {
    margin-bottom: 10px;
}

.device-field small {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.device-field code {
    display: block;
    font-size: 12px;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.25);
    padding: 6px 8px;
    border-radius: 6px;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 22, 41, 0.6);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.menu-toggle svg { width: 20px; height: 20px; }

.topbar-title h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.content {
    flex: 1;
    padding: 28px;
    max-width: 1200px;
    width: 100%;
}

.footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer .dot { opacity: 0.4; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

/* ── Guest / login layout ── */
.guest-shell { min-height: 100vh; }

.guest-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

.guest-hero {
    background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 50%, #0f1629 100%);
    display: flex;
    align-items: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.guest-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%);
    pointer-events: none;
}

.guest-hero-inner {
    position: relative;
    max-width: 440px;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 20px;
}

.guest-hero h1 {
    margin: 0 0 16px;
    font-size: clamp(28px, 4vw, 38px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.guest-hero p {
    margin: 0 0 28px;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1.6;
}

.feature-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.feature-list li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 12px;
    color: #cbd5e1;
    font-size: 14px;
}

.feature-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

.guest-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    background: var(--bg);
}

.login-card {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
}

.login-card-head {
    margin-bottom: 28px;
}

.login-card-head h2 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 600;
}

.login-card-head p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.login-help {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.login-help h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.login-help ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.7;
}

.guest-footer {
    margin-top: auto;
    padding-top: 32px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ── Cards & layout ── */
.page-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.panel-card.highlight {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, var(--card) 60%);
    border-color: rgba(59, 130, 246, 0.2);
}

.panel-card-head {
    margin-bottom: 20px;
}

.panel-card-head h2 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
}

.panel-card-head p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.panel-card-head.row-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* ── Forms ── */
.form-stack,
.form-grid {
    display: grid;
    gap: 18px;
}

.form-grid {
    grid-template-columns: 1fr 1fr;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field.span-2 { grid-column: span 2; }

.field > span {
    font-size: 13px;
    font-weight: 500;
    color: #cbd5e1;
}

.field > span em {
    font-style: normal;
    color: var(--text-dim);
    font-weight: 400;
}

.field small {
    font-size: 12px;
    color: var(--text-dim);
}

input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

input::placeholder { color: var(--text-dim); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, var(--primary));
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-sm { padding: 7px 12px; font-size: 12px; }

.btn-block { width: 100%; }

/* ── Alerts ── */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-error {
    background: var(--danger-soft);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: var(--success-soft);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

/* ── Playlists ── */
.playlist-grid {
    display: grid;
    gap: 14px;
}

.playlist-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
}

.playlist-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.playlist-card h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.playlist-meta {
    margin-top: 10px;
}

.playlist-meta small {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.playlist-meta code,
.playlist-meta span {
    font-size: 13px;
    color: var(--text-muted);
}

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: #93c5fd;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.7;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.empty-state p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    max-width: 360px;
    margin-inline: auto;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 600;
}

.data-table td.truncate {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-muted {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.link-muted:hover { color: var(--primary); }

/* ── Info lists ── */
.info-list,
.faq-list {
    margin: 0;
}

.info-list div,
.faq-list div {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.info-list div:last-child,
.faq-list div:last-child { border-bottom: none; }

.info-list dt,
.faq-list dt {
    font-size: 13px;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 6px;
}

.info-list dd,
.faq-list dd {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.55;
}

.steps-compact {
    margin: 0;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.8;
}

/* ── Help page ── */
.help-steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-step {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.step-num {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--primary-soft);
    color: #93c5fd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.help-step h3 {
    margin: 0 0 6px;
    font-size: 15px;
}

.help-step p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.55;
}

.xtream-only { display: none; }

/* ── Responsive ── */
@media (max-width: 960px) {
    .guest-layout { grid-template-columns: 1fr; }
    .guest-hero { padding: 36px 28px; min-height: auto; }
    .guest-panel { padding: 36px 28px; }
    .two-col { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.visible {
        display: block;
    }

    .main { margin-left: 0; }

    .menu-toggle { display: flex; }

    .content { padding: 20px 16px; }

    .form-grid { grid-template-columns: 1fr; }

    .field.span-2 { grid-column: span 1; }

    .topbar { padding: 14px 16px; }

    .footer { padding: 14px 16px; flex-wrap: wrap; }
}
