:root {
    --bg: #f2f5f8;
    --card: #ffffff;
    --ink: #0e1a2b;
    --muted: #5d6b82;
    --primary: #0f766e;
    --accent: #d97706;
    --danger: #be123c;
    --ok: #166534;
    --border: #d7dee8;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Trebuchet MS", Helvetica, Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 5% 5%, #dff7f2 0%, transparent 40%),
        radial-gradient(circle at 95% 15%, #fff0d9 0%, transparent 35%),
        var(--bg);
}

a {
    color: inherit;
}

.container {
    width: min(1200px, 92%);
    margin: 0 auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #0ea5e9);
    font-weight: 800;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 18px;
    padding: 18px 0 28px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.panel-body {
    padding: 16px 18px 20px;
}

.panel h2,
.panel h3 {
    margin: 0;
    font-size: 1rem;
}

.muted {
    color: var(--muted);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.metric {
    background: linear-gradient(160deg, #ffffff, #f8fbff);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}

.metric strong {
    font-size: 1.4rem;
    display: block;
}

.metric span {
    color: var(--muted);
    font-size: 0.88rem;
}

.flash {
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 12px 0;
    font-size: 0.92rem;
}

.flash.ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: var(--ok);
}

.flash.err {
    background: #fff1f2;
    border-color: #fecdd3;
    color: var(--danger);
}

form {
    margin: 0;
}

label {
    display: block;
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 6px;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
}

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

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

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

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #0284c7);
    color: #fff;
}

.btn-secondary {
    background: #e7eef8;
    color: #0f2944;
}

.btn-danger {
    background: #ffe4e6;
    color: #9f1239;
}

.btn-sm {
    padding: 7px 11px;
    font-size: 0.84rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 0.8rem;
    color: var(--muted);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.tag {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tag.ready {
    background: #dcfce7;
    color: #166534;
}

.tag.processing,
.tag.queued {
    background: #ffedd5;
    color: #9a3412;
}

.tag.error {
    background: #ffe4e6;
    color: #be123c;
}

.tag.free {
    background: #e0f2fe;
    color: #0c4a6e;
}

.tag.premium {
    background: #fff7ed;
    color: #9a3412;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-card {
    width: min(440px, 100%);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.watch-layout {
    display: grid;
    gap: 20px;
    grid-template-columns: 2fr 1fr;
    margin: 20px auto 30px;
}

.player-shell {
    border: 1px solid #d2dae5;
    border-radius: 16px;
    background: #020617;
    overflow: hidden;
}

.player-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.video-js {
    width: 100%;
    height: 100%;
}

.watch-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
}

.video-list {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.video-tile {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 0.18s ease;
}

.video-tile:hover {
    transform: translateY(-3px);
}

.thumb {
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #0f766e, #0284c7);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.tile-body {
    padding: 12px;
}

.headline {
    margin: 0;
    font-size: 1.48rem;
}

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

.paywall {
    border: 1px dashed #fdba74;
    background: #fff7ed;
    color: #7c2d12;
    border-radius: 12px;
    padding: 12px;
    font-size: 0.92rem;
}

.ads-box {
    border: 1px dashed #93c5fd;
    background: #f0f9ff;
    border-radius: 12px;
    min-height: 90px;
    padding: 10px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.84rem;
}

.edit-details summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.edit-details summary::-webkit-details-marker {
    display: none;
}

.edit-form {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f8fbff;
}

@media (max-width: 980px) {
    .admin-grid,
    .watch-layout {
        grid-template-columns: 1fr;
    }

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

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

@media (max-width: 640px) {
    .row {
        grid-template-columns: 1fr;
    }

    .metrics,
    .video-list {
        grid-template-columns: 1fr;
    }

    .topbar-inner {
        min-height: 64px;
    }
}

/* =====================
   ADMIN SIDEBAR LAYOUT
   ===================== */

.admin-body {
    background: #edf0f5;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #0d1117;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    overflow-y: auto;
    scrollbar-width: none;
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 18px;
    color: #f3f4f6;
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.sidebar-menu-label {
    font-size: 0.67rem;
    letter-spacing: 1.3px;
    color: #374151;
    padding: 18px 16px 6px;
    margin: 0;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 8px;
    flex: 1;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    cursor: pointer;
    user-select: none;
    line-height: 1;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.05);
    color: #d1d5db;
}

.sidebar-item.active {
    background: rgba(99,102,241,0.18);
    color: #a5b4fc;
    font-weight: 600;
}

.sidebar-item svg { flex-shrink: 0; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.84rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    color: #e5e7eb;
    font-weight: 600;
    font-size: 0.84rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: #4b5563;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #4b5563;
    padding: 5px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    transition: color 0.12s, background 0.12s;
    flex-shrink: 0;
}

.sidebar-logout-btn:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

.content-area {
    flex: 1;
    margin-left: 230px;
    padding: 26px 30px;
    min-height: 100vh;
}

.section-page-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.section-page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 3px;
}

.section-page-sub {
    color: var(--muted);
    font-size: 0.87rem;
    margin: 0;
}

.admin-section { display: none; }
.admin-section.active { display: block; }

@media (max-width: 900px) {
    .sidebar { width: 200px; }
    .content-area { margin-left: 200px; }
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 60;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #0d1117;
    border: none;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.45);
    transition: background 0.15s;
}

.sidebar-toggle:hover { background: #1a2030; }

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: #e5e7eb;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 40;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

@media (max-width: 640px) {
    .sidebar-toggle { display: flex; }

    .sidebar {
        width: 230px;
        left: -230px;
        transition: left 0.25s ease;
    }

    .sidebar.open { left: 0; z-index: 50; }

    .content-area {
        margin-left: 0;
        padding: 14px;
        padding-top: 68px;
    }
}
