/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── THEME VARIABLES ──────────────────────────────────────── */
:root {
    --accent:        #0070f3;
    --accent-hover:  #0060d0;
    --accent-subtle: #0070f318;
    --green:         #00c853;
    --green-subtle:  #00c85320;
    --red:           #f03040;
    --red-subtle:    #f0304018;
    --amber:         #f59e0b;
    --radius-sm:     6px;
    --radius-md:     10px;
    --radius-lg:     14px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.08);
    --transition:    150ms ease;
    --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --topbar-h:      56px;
}

/* DARK THEME */
[data-theme="dark"] {
    --bg-base:       #0e1117;
    --bg-surface:    #161b22;
    --bg-elevated:   #1c2330;
    --bg-hover:      #21262d;
    --border:        #30363d;
    --border-subtle: #21262d;
    --text-primary:  #e6edf3;
    --text-secondary:#8b949e;
    --text-tertiary: #6e7681;
    --text-on-accent:#ffffff;
}

/* LIGHT THEME */
[data-theme="light"] {
    --bg-base:       #f0f2f5;
    --bg-surface:    #ffffff;
    --bg-elevated:   #ffffff;
    --bg-hover:      #f6f8fa;
    --border:        #d0d7de;
    --border-subtle: #e8ecf0;
    --text-primary:  #1a1f27;
    --text-secondary:#57606a;
    --text-tertiary: #8c959f;
    --text-on-accent:#ffffff;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

/* ── BASE ─────────────────────────────────────────────────── */
html, body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── SCREENS ──────────────────────────────────────────────── */
.screen { display: none; height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }

/* ── LOGIN ────────────────────────────────────────────────── */
#login-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
}

[data-theme="dark"] #login-screen {
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, #0d1f3c, transparent),
        var(--bg-base);
}

.login-wrap {
    width: 100%;
    max-width: 360px;
    padding: 2rem;
    position: relative;
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.brand-logo {
    width: 48px;
    height: 48px;
    color: var(--accent);
}

.login-brand h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.brand-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.login-form {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-md);
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.field input {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    width: 100%;
}

.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.btn-primary {
    padding: 0.65rem 1rem;
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(0,112,243,0.3);
}

.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-ghost:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.error-msg {
    background: var(--red-subtle);
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    color: var(--red);
    font-size: 0.8rem;
    line-height: 1.4;
}

.hidden { display: none !important; }

/* ── THEME TOGGLE ─────────────────────────────────────────── */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle:hover { border-color: var(--text-secondary); color: var(--text-primary); background: var(--bg-hover); }

#theme-toggle-login {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
}

/* ── TOP BAR ──────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    flex-shrink: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.topbar-logo {
    width: 24px;
    height: 24px;
    color: var(--accent);
    flex-shrink: 0;
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Connection status pill */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all var(--transition);
}

.status-pill.connected {
    background: var(--green-subtle);
    border-color: var(--green);
    color: var(--green);
}

.status-pill.disconnected {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text-tertiary);
}

.status-pill.connecting {
    background: rgba(245,158,11,0.12);
    border-color: var(--amber);
    color: var(--amber);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-pill.connected .status-dot {
    box-shadow: 0 0 4px currentColor;
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-pill.connecting .status-dot {
    animation: blink 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.2; }
}

.topbar-center { display: flex; justify-content: center; }

/* Nav buttons */
.page-nav { display: flex; gap: 0.15rem; }

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    padding: 0.45rem 0.85rem;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    position: relative;
}

.nav-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-btn.active { color: var(--accent); background: var(--accent-subtle); }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0 5px;
    min-width: 17px;
    height: 17px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

.device-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* ── PAGES ────────────────────────────────────────────────── */
.page {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem;
}

.page.active { display: block; }

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 55vh;
    gap: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
}

.empty-state svg {
    width: 56px;
    height: 56px;
    opacity: 0.3;
    margin-bottom: 0.25rem;
}

.empty-state p {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.empty-sub {
    font-size: 0.78rem !important;
    font-weight: 400 !important;
    color: var(--text-tertiary) !important;
    max-width: 280px;
}

/* ── CAMERA GRID ──────────────────────────────────────────── */
.camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

@media (max-width: 480px) {
    .camera-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}

.camera-tile {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition);
}

.camera-tile:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.camera-video-wrap {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    overflow: hidden;
}

.camera-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Live indicator */
.live-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity var(--transition);
}

.live-badge.visible { opacity: 1; }

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 4px var(--red);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

/* Connecting overlay */
.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--bg-elevated);
    transition: opacity var(--transition);
}

.camera-overlay.hidden { opacity: 0; pointer-events: none; }

.camera-overlay svg {
    width: 32px;
    height: 32px;
    color: var(--text-tertiary);
    opacity: 0.4;
}

.camera-overlay span {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Camera info bar */
.camera-info {
    padding: 0.65rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.camera-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.camera-state {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

.camera-state.live { color: var(--green); }

/* Quality controls */
.camera-controls {
    padding: 0.5rem 0.85rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}

.controls-label {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-right: auto;
}

.camera-controls select {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition);
}

.camera-controls select:focus { border-color: var(--accent); }

/* ── ALERTS ───────────────────────────────────────────────── */
.alerts-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.alerts-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.alerts-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 760px;
}

.alert-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    box-shadow: var(--shadow-sm);
    animation: fade-up 0.2s ease-out;
    transition: border-color var(--transition);
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert-item.unread {
    border-left: 3px solid var(--accent);
}

.alert-item:hover { border-color: var(--border); }

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.alert-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.alert-time {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

.alert-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-camera-tag {
    display: inline-flex;
    align-items: center;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
}

.alert-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .topbar { padding: 0 0.85rem; gap: 0.5rem; }
    .brand-name { display: none; }
    .device-label { display: none; }
    .page { padding: 0.85rem; }
    .status-text { display: none; }
    .status-pill { padding: 0.25rem; }
}

@media (max-width: 400px) {
    .nav-btn span { display: none; }
}

/* ── LOGIN TABS ───────────────────────────────────────────── */
.login-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.login-tab {
    flex: 1;
    background: none;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    padding: 0.45rem;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.login-tab.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.field select {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    outline: none;
    width: 100%;
    cursor: pointer;
    transition: border-color var(--transition);
    -webkit-appearance: none;
}

.field select:focus { border-color: var(--accent); }

/* ── ADMIN PAGE ───────────────────────────────────────────── */
.admin-wrap {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Health grid */
.health-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    divide-x: 1px solid var(--border);
}

.health-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    border-right: 1px solid var(--border);
}

.health-card:last-child { border-right: none; }

.health-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.health-value {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
}

.health-value.ok { color: var(--green); }

/* Buttons small */
.btn-primary-sm {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}

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

.btn-ghost-sm {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-ghost-sm:hover { border-color: var(--text-secondary); color: var(--text-primary); }

/* Inline form */
.inline-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-hover);
}

.inline-form input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.75rem;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
}

.inline-form input:focus { border-color: var(--accent); }

/* Hubs list */
.hubs-list { padding: 0.5rem 0; }

.hub-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
    cursor: pointer;
}

.hub-row:last-child { border-bottom: none; }
.hub-row:hover { background: var(--bg-hover); }

.hub-row-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
}

.hub-row-info { flex: 1; min-width: 0; }

.hub-row-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hub-row-meta {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin-top: 0.1rem;
}

.hub-row-code {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-family: monospace;
    letter-spacing: 0.05em;
}

.hub-row-arrow {
    color: var(--text-tertiary);
    font-size: 0.8rem;
}

/* Devices table */
.devices-table-wrap { overflow-x: auto; }

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

.devices-table th {
    text-align: left;
    padding: 0.65rem 1.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.devices-table td {
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.devices-table tr:last-child td { border-bottom: none; }
.devices-table tr:hover td { background: var(--bg-hover); }

.device-type-tag {
    display: inline-flex;
    align-items: center;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.device-type-tag.sensor { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
.device-type-tag.monitor { background: rgba(0,200,83,0.1); border-color: var(--green); color: var(--green); }
.device-type-tag.admin { background: rgba(245,158,11,0.1); border-color: var(--amber); color: var(--amber); }

.online-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
}

.online-dot::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.online-dot.online::before {
    background: var(--green);
    box-shadow: 0 0 4px var(--green);
}

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
    animation: fade-up 0.2s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.join-code-display { display: flex; flex-direction: column; gap: 0.5rem; }

.join-code-display label,
.qr-wrap label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.join-code {
    font-family: monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.1em;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    text-align: center;
}

.join-code-note {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.qr-wrap { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }

.qr-code {
    background: white;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── ADMIN NAV ────────────────────────────────────────────── */
.admin-only { display: none; }
.admin-only.visible { display: flex; }

/* ── DANGER BUTTON ────────────────────────────────────────── */
.btn-danger {
    background: none;
    border: 1px solid var(--red);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--red);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-danger:hover {
    background: var(--red-subtle);
}
