* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(56, 189, 248, 0.15), transparent 35%),
        radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.12), transparent 35%),
        #020617;
    color: #e2e8f0;
    display: flex;
    min-height: 100vh;
    line-height: 1.45;
}
.sidebar {
    width: 260px;
    background: linear-gradient(160deg, #0f172a, #1e293b);
    padding: 24px 0;
    flex-shrink: 0;
    min-height: 100vh;
    overflow-y: auto;
}
.sidebar-header { padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 18px; }
.sidebar-header p { font-size: 12px; color: #94a3b8; margin-top: 4px; }
.sidebar-nav { padding: 16px 0; }
.nav-item {
    display: block;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: rgba(255,255,255,0.1); border-left-color: #22c55e; color: #fff; }
.main-content { flex: 1; padding: 24px; overflow: auto; }
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 24px;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 12px;
}
.top-bar h1 { font-size: 22px; margin: 0; flex: 1 1 auto; min-width: 160px; }
.admin-info, .top-bar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.section-header h2 { margin: 0; font-size: 18px; color: #e2e8f0; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 18px 20px;
}
.stat-card h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 8px;
}
.stat-number { font-size: 28px; font-weight: 700; color: #f8fafc; }
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 14px;
}
.toolbar label { font-size: 13px; color: #94a3b8; white-space: nowrap; }
.muted { color: #94a3b8; font-size: 13px; line-height: 1.5; }
code {
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}
@media (max-width: 900px) {
    body { flex-direction: column; }
    .sidebar {
        width: 100%;
        min-height: auto;
        max-height: none;
    }
    .main-content { padding: 16px; }
}
.table-container {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 16px;
    overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid rgba(148, 163, 184, 0.15); }
th { color: #94a3b8; font-size: 12px; text-transform: uppercase; }
.btn-primary, .btn-success, .btn-danger {
    border: none; padding: 10px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; margin-right: 6px;
}
.btn-primary { background: #3b82f6; color: #fff; }
.btn-success { background: #22c55e; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.modal {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
    background: #0f172a; border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px; padding: 24px; width: 480px; max-width: 95%;
}
.modal-wide { width: 560px; }
.modal-content input, .modal-content select {
    width: 100%; padding: 10px; margin: 8px 0;
    border-radius: 8px; border: 1px solid rgba(148, 163, 184, 0.3);
    background: #020617; color: #e2e8f0;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid input, .form-grid select { grid-column: span 1; }
.check-row { grid-column: span 2; display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 14px; }
.modal-buttons { display: flex; gap: 10px; margin-top: 16px; }
.loading { padding: 40px; text-align: center; color: #94a3b8; }
.settings-block { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid rgba(148,163,184,0.15); }
.settings-block h3 { margin-bottom: 12px; color: #a5b4fc; }
.settings-row { margin-bottom: 14px; }
.settings-row label { display: block; font-size: 13px; color: #94a3b8; margin-bottom: 6px; }
.settings-row input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(148,163,184,0.3);
    background: #020617;
    color: #e2e8f0;
}
.settings-row select {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(148,163,184,0.3);
    background: #020617;
    color: #e2e8f0;
}
.settings-row label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 14px;
}
.settings-row input[type="checkbox"],
.notify-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    max-width: 18px;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #3b82f6;
    vertical-align: middle;
}
.notify-table-wrap {
    overflow-x: auto;
    margin: 12px 0 16px;
}
table.notify-table {
    width: 100%;
    min-width: 420px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}
table.notify-table th,
table.notify-table td {
    padding: 14px 12px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
table.notify-table th:first-child,
table.notify-table td:first-child {
    width: 48%;
    text-align: left;
}
table.notify-table th:not(:first-child),
table.notify-table td:not(:first-child) {
    width: 26%;
    text-align: center;
}
table.notify-table td.toggle-cell {
    text-align: center;
}
table.notify-table .toggle-cell label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    cursor: pointer;
}
.slide-preview-9x16 {
    aspect-ratio: 9 / 16;
    width: 100%;
    max-width: 200px;
    height: auto;
    max-height: 360px;
    margin: 0 auto 8px;
    background: rgba(0,0,0,0.35);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(148,163,184,0.25);
}
.slide-preview-9x16 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* —— Auth gate (login before admin shell) —— */
body.auth-guest {
    display: block;
    min-height: 100vh;
}
body.auth-guest .app-shell {
    display: none !important;
}
body.auth-authenticated {
    display: flex;
    min-height: 100vh;
}
body.auth-authenticated .auth-gate {
    display: none !important;
}
body.auth-authenticated .app-shell {
    display: flex !important;
    flex: 1;
    width: 100%;
    min-height: 100vh;
}
body.auth-pending .app-shell,
body.auth-pending .auth-gate {
    visibility: hidden;
}
.auth-gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px 28px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.auth-brand {
    text-align: center;
    margin-bottom: 28px;
}
.auth-brand .logo-mark {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}
.auth-brand h1 {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0 0 6px;
}
.auth-brand p {
    font-size: 13px;
    color: #94a3b8;
    margin: 0;
}
.auth-card h2 {
    font-size: 15px;
    font-weight: 600;
    color: #cbd5e1;
    margin: 0 0 18px;
    text-align: center;
}
.auth-card .settings-row input {
    max-width: none;
}
.auth-card .btn-primary {
    width: 100%;
    margin-top: 4px;
    padding: 12px;
}
.auth-footer-links {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
}
.auth-footer-links button {
    background: none;
    border: none;
    color: #60a5fa;
    cursor: pointer;
    padding: 0;
    font-size: 13px;
}
.auth-footer-links button:hover {
    text-decoration: underline;
}
.auth-msg-error {
    color: #f87171;
    font-size: 13px;
    margin-top: 12px;
    min-height: 1.2em;
}
.auth-msg-success {
    color: #86efac;
    font-size: 13px;
    margin-top: 12px;
    min-height: 1.2em;
}
.session-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.session-bar .session-user {
    font-size: 14px;
    color: #86efac;
}
.session-bar .session-user strong {
    color: #f8fafc;
}

.backup-panel {
    margin-bottom: 24px;
    padding: 18px 20px;
    border-radius: 12px;
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(30, 58, 138, 0.15);
}
.backup-panel h3 {
    margin: 0 0 8px;
    font-size: 16px;
    color: #93c5fd;
}
.backup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 14px;
}
.backup-card {
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.7);
}
.backup-card h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #e2e8f0;
}
.backup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.backup-actions input[type="file"] {
    font-size: 12px;
    color: #94a3b8;
    max-width: 100%;
}
.btn-secondary {
    background: rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.3);
}
.backup-result {
    margin-top: 12px;
    font-size: 13px;
    color: #86efac;
    white-space: pre-wrap;
}
