:root {
    --bg: #0d1119;
    --panel: rgba(18, 24, 36, 0.92);
    --border: rgba(255, 255, 255, 0.08);
    --text: #eef4fb;
    --muted: #92a2bc;
    --accent: #7dd8ff;
    --primary: #ff9147;
    --primary-soft: #ffc56d;
    --success: #75d2a6;
    --danger: #ff7c7c;
    --shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
    --sidebar-w: 220px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    font-family: "Segoe UI", "PingFang SC", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 145, 71, 0.18), transparent 22%),
        radial-gradient(circle at 88% 16%, rgba(125, 216, 255, 0.16), transparent 18%),
        linear-gradient(165deg, #090d14, #101622 50%, #0a0f17);
    min-height: 100vh;
}

button, input, textarea, select { font: inherit; }

/* ========== Login Page ========== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card .brand-mark-lg {
    margin: 0 auto 12px;
}

.login-card h1 {
    margin: 0 0 4px;
}

/* ========== Admin Shell Layout ========== */

.admin-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ========== Sidebar ========== */

.sidebar-nav {
    background: rgba(12, 16, 26, 0.95);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 15px;
}

.nav-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 10px;
}

.nav-item {
    background: none;
    border: none;
    color: var(--muted);
    text-align: left;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.nav-item.active {
    background: rgba(125, 216, 255, 0.1);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    padding: 14px 14px 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.sidebar-footer .status-pill {
    text-align: center;
    font-size: 12px;
}

/* ========== Content Area ========== */

.content-area {
    padding: 24px 28px;
    overflow-y: auto;
    max-height: 100vh;
}

.tab-page {
    display: none;
}

.tab-page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.page-header h2 {
    margin: 0;
    font-size: 22px;
}

/* ========== Shared Components ========== */

.admin-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.section-head h3 {
    margin: 0;
    font-size: 16px;
}

.button-group {
    display: flex;
    gap: 10px;
}

.eyebrow, .section-desc, .stat-label, .table-meta {
    color: var(--muted);
}

.eyebrow {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    backdrop-filter: blur(18px);
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

/* Status grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.status-card {
    border-radius: 14px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.status-card strong {
    display: block;
    margin-top: 6px;
    font-size: 18px;
}

/* Admin grid (2-column) */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

/* Forms */
input, textarea, select {
    width: 100%;
    padding: 10px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

textarea {
    min-height: 280px;
    resize: vertical;
}

select {
    appearance: none;
    cursor: pointer;
}

.stack {
    display: grid;
    gap: 10px;
}

/* Buttons */
button {
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #24160b;
    font-weight: 700;
    transition: opacity 0.15s;
}

button:hover { opacity: 0.9; }

.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.ghost:hover {
    background: rgba(255, 255, 255, 0.14);
}

button.danger {
    background: rgba(255, 124, 124, 0.15);
    color: var(--danger);
}

button.danger:hover {
    background: rgba(255, 124, 124, 0.3);
}

.status-pill {
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(125, 216, 255, 0.12);
    color: var(--accent);
    font-weight: 700;
    font-size: 12px;
}

/* Feedback */
.feedback {
    min-height: 20px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}

.feedback.success { color: var(--success); }
.feedback.error { color: var(--danger); }

/* Tables */
.table-wrap { overflow: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
}

.status-tag {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 12px;
}

.status-tag.active, .status-tag.paid { color: var(--success); }
.status-tag.banned { color: var(--danger); }

.log-panel {
    margin: 10px 0 0;
    padding: 14px;
    border-radius: 14px;
    white-space: pre-wrap;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
}

.hidden { display: none !important; }

/* Action buttons */
.action-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.action-btn-group button {
    padding: 5px 10px;
    font-size: 12px;
}

/* Theme form grid */
.theme-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.theme-field {
    display: grid;
    gap: 5px;
}

.theme-field.full-width {
    grid-column: 1 / -1;
}

.theme-field label {
    color: var(--muted);
    font-size: 12px;
}

.theme-field input[type="color"] {
    height: 40px;
    padding: 4px;
    cursor: pointer;
}

/* Gallery thumbnail */
.gallery-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Brand mark */
.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #24160b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 16px;
    flex-shrink: 0;
}

.brand-mark-lg {
    width: 56px;
    height: 56px;
    font-size: 22px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #24160b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    max-width: 440px;
    width: 90%;
}

.modal-content select {
    width: 100%;
    padding: 10px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

/* ========== Responsive ========== */

@media (max-width: 1100px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .sidebar-nav {
        position: fixed;
        left: -260px;
        top: 0;
        width: 240px;
        z-index: 500;
        transition: left 0.25s;
        height: 100vh;
    }

    .sidebar-nav.open {
        left: 0;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .status-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content-area {
        padding: 14px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .theme-form {
        grid-template-columns: 1fr;
    }
}

/* ========== Phone Preview ========== */

.phone-frame {
    width: 395px;
    height: 720px;
    margin: 0 auto;
    border: 3px solid #333;
    border-radius: 36px;
    overflow: hidden;
    background: #0d0d1a;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.phone-notch {
    width: 120px;
    height: 24px;
    margin: 0 auto;
    background: #333;
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

#modal-mobile-preview .modal-card {
    max-height: 90vh;
    overflow: hidden;
}
