:root {
    --bg: #0b1020;
    --bg-soft: #121932;
    --surface: rgba(15, 23, 42, 0.84);
    --surface-strong: #151c36;
    --text: #eff3ff;
    --muted: #aeb8d6;
    --line: rgba(255, 255, 255, 0.08);
    --primary: #8b5cf6;
    --primary-2: #6d28d9;
    --success: #22c55e;
    --danger: #f43f5e;
    --warning: #f59e0b;
    --shadow: 0 24px 60px rgba(3, 7, 18, 0.35);
    --gradient: linear-gradient(135deg, #1b1238 0%, #4c1d95 45%, #111827 100%);
}

html[data-theme="light"] {
    --bg: #eef3fb;
    --bg-soft: #f6f9ff;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --line: rgba(15, 23, 42, 0.08);
    --primary: #7c3aed;
    --primary-2: #a855f7;
    --success: #16a34a;
    --danger: #e11d48;
    --warning: #d97706;
    --shadow: 0 24px 60px rgba(148, 163, 184, 0.18);
    --gradient: linear-gradient(135deg, #ffffff 0%, #efe8ff 42%, #f8fbff 100%);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Inter", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(168, 85, 247, 0.24), transparent 28%),
        radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.18), transparent 30%),
        var(--bg);
    color: var(--text);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; }

.admin-shell, .login-shell {
    min-height: 100vh;
}

.admin-shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.brand-wrap h1,
.page-head h2,
.card-header h3,
.login-card h2 {
    margin: 0;
}

.sidebar-nav a,
.theme-toggle,
.ghost-button,
.primary-button,
.danger-button {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 16px;
    transition: 0.2s ease;
}

.sidebar-nav a.active,
.sidebar-nav a:hover,
.theme-toggle:hover,
.ghost-button:hover {
    background: var(--surface);
}

.page-wrap {
    padding: 24px 28px 42px;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
    padding: 24px 18px;
    background: rgba(8, 13, 29, 0.74);
    backdrop-filter: blur(18px);
    border-right: 1px solid var(--line);
}

html[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, 0.78);
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-head h1 {
    margin: 0;
    font-size: 24px;
}

.sidebar-close {
    display: none;
    margin-left: auto;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 0 16px;
    background: transparent;
}

.sidebar-nav a.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(109, 40, 217, 0.14));
    border-color: rgba(139, 92, 246, 0.28);
}

.nav-label {
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
}

.sidebar-button {
    width: 100%;
    justify-content: center;
}

.page-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.page-topbar-copy h2 {
    margin: 0;
    font-size: 26px;
}

.sidebar-toggle {
    display: none;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    margin: 4px auto;
    background: currentColor;
    border-radius: 999px;
}

.sidebar-backdrop {
    display: none;
}

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

.subtle {
    margin: 6px 0 0;
    color: var(--muted);
}

.primary-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    border: none;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.primary-button.full { width: 100%; }

.ghost-button {
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.danger-button {
    background: rgba(244, 63, 94, 0.12);
    color: #fff;
    border-color: rgba(244, 63, 94, 0.24);
    cursor: pointer;
}

html[data-theme="light"] .danger-button {
    color: var(--danger);
}

.sm {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
}

.panel-card, .stat-card, .login-card, .feature-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.panel-card,
.login-card {
    padding: 22px;
}

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

.card-header.compact {
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

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

.stat-card.warning strong { color: #fda4af; }

.grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.tag-cloud,
.stack-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag,
.status-pill,
.download-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.24);
    color: var(--text);
    font-size: 13px;
}

.status-pill.active {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.22);
}

.status-pill.inactive {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.22);
}

.stack-item {
    width: 100%;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--line);
}

.stack-item span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.content-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-cell img,
.preview-card img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 14px;
}

.content-cell span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.toolbar-grid,
.form-fields {
    display: grid;
    gap: 16px;
}

.toolbar-grid {
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: end;
}

.grid-inline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    font-size: 13px;
    color: var(--muted);
}

.field input,
.field textarea,
.field select {
    width: 100%;
    padding: 13px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
}

.field textarea {
    resize: vertical;
    min-height: 140px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.form-actions,
.toolbar-actions,
.action-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-actions {
    margin-top: 18px;
    justify-content: flex-end;
}

.preview-card {
    padding: 14px;
    border-radius: 20px;
    border: 1px dashed var(--line);
    background: rgba(255,255,255,0.03);
}

.empty-cell,
.pagination-wrap {
    text-align: center;
    color: var(--muted);
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
}

.alert.success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.24);
}

.alert.danger {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.24);
}

.alert ul {
    margin: 8px 0 0 18px;
    padding: 0;
}

.login-page {
    background:
        radial-gradient(circle at top left, rgba(168, 85, 247, 0.34), transparent 30%),
        radial-gradient(circle at bottom right, rgba(79, 70, 229, 0.28), transparent 30%),
        #090c18;
}

.login-shell {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
    padding: 32px;
}

.login-hero {
    padding: 28px;
    border-radius: 28px;
    background: var(--gradient);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--shadow);
}

.login-hero h1 {
    margin: 0 0 12px;
    max-width: 760px;
    font-size: clamp(34px, 5vw, 56px);
    line-height: 1.04;
}

.login-hero p {
    max-width: 440px;
    color: #d6daf0;
    font-size: 17px;
}

.login-card {
    align-self: center;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.login-hint {
    margin-top: 16px;
    color: var(--muted);
}

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

    .toolbar-grid,
    .grid-two,
    .grid-inline,
    .login-shell {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: min(290px, calc(100vw - 32px));
        transform: translateX(-100%);
        transition: transform 0.24s ease;
    }

    .sidebar-toggle,
    .sidebar-close {
        display: inline-grid;
        place-items: center;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgba(2, 6, 23, 0.5);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .page-wrap,
    .login-shell {
        padding: 18px;
    }

    .panel-card,
    .login-card,
    .login-hero {
        padding: 18px;
        border-radius: 20px;
    }

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

    .page-head,
    .form-actions,
    .toolbar-actions,
    .action-row {
        align-items: stretch;
        flex-direction: column;
    }
}
