:root {
    --primary:       #005f73;
    --primary-dark:  #003d4d;
    --primary-light: #0a9396;
    --accent:        #94d2bd;
    --highlight:     #ee9b00;
    --danger:        #ae2012;
    --success:       #2a9d5c;
    --text:          #1a2332;
    --text-muted:    #5a6a7e;
    --bg:            #f0f6f8;
    --card:          #ffffff;
    --border:        #d0dde6;
    --shadow:        0 2px 12px rgba(0,95,115,.10);
    --shadow-lg:     0 8px 32px rgba(0,95,115,.16);
    --radius:        12px;
    --radius-sm:     8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ── HEADER ─────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    color: #fff;
    padding: 0 2rem;
    box-shadow: 0 2px 16px rgba(0,0,0,.3);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 68px;
    flex-wrap: wrap;
}
.site-logo { display: flex; align-items: center; gap: .75rem; color: #fff; }
.site-logo:hover { text-decoration: none; }
.logo-icon {
    width: 44px; height: 44px;
    background: rgba(255,255,255,.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.logo-text { line-height: 1.2; }
.logo-text strong { display: block; font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
.logo-text span { font-size: .72rem; opacity: .8; }
.header-nav { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.header-nav form { margin: 0; }
.header-nav a, .header-nav button {
    color: rgba(255,255,255,.85);
    font-size: .875rem;
    padding: .4rem .9rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}
.header-nav a:hover, .header-nav button:hover { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }
.header-nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.header-nav .btn-logout { border-color: rgba(255,255,255,.3); }
.header-user { font-size: .85rem; opacity: .75; padding: .4rem .6rem; }

/* ── MAIN ────────────────────────────────── */
.main-wrap { max-width: 1200px; margin: 2rem auto; padding: 0 1.5rem; }
.main-wrap.medium { max-width: 760px; }
.site-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: .8rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border);
}

/* ── CARDS ──────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid var(--border);
}
.card.form-card { max-width: 660px; }
.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--accent);
    display: flex; align-items: center; gap: .5rem;
}

/* ── FORM ───────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .4rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: .65rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(10,147,150,.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group small { display: block; margin-top: .3rem; }
.form-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: 1.5rem; }
.inline-form { display: contents; }

/* ── BUTTONS ────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .6rem 1.4rem;
    border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 600; font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all .15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light-primary { background: rgba(0,95,115,.08); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-light-primary:hover { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #1e7a46; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8b1a10; }
.btn-warning { background: var(--highlight); color: #fff; }
.btn-warning:hover { background: #c47d00; }
.btn-outline-danger { background: #fdf0ef; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-outline-success { background: #edfaf2; color: var(--success); border: 1.5px solid var(--success); }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; padding: .8rem; font-size: 1rem; }
.actions { display: flex; align-items: stretch; gap: .3rem; flex-wrap: wrap; }

/* ── ALERTS ─────────────────────────────── */
.alert {
    padding: .9rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .9rem; font-weight: 500;
    border-left: 4px solid;
}
.alert-error   { background: #fdf0ef; color: var(--danger);  border-color: var(--danger); }
.alert-success { background: #edfaf2; color: var(--success); border-color: var(--success); }
.alert-info    { background: #e8f6f9; color: var(--primary); border-color: var(--primary-light); }

/* ── TABLE ──────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
    background: var(--primary);
    color: #fff;
    padding: .75rem 1rem;
    text-align: left;
    font-weight: 600; font-size: .83rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: rgba(0,95,115,.04); }
tbody td { padding: .75rem 1rem; vertical-align: middle; }
td.num { text-align: center; font-weight: 700; color: var(--primary); }
code { font-size: .82rem; }
.badge { display: inline-block; padding: .2rem .65rem; border-radius: 20px; font-size: .76rem; font-weight: 600; }
.badge-active   { background: #edfaf2; color: var(--success); }
.badge-inactive { background: #fdf0ef; color: var(--danger); }
.badge-category { background: rgba(0,95,115,.08); color: var(--primary); }
.src-label { font-size: .8rem; font-weight: 600; }
.src-youtube { color: #c00; }
.src-file, .src-url { color: var(--primary); }

/* ── PAGE TITLE ─────────────────────────── */
.page-title { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 1.5rem; }
.page-title span { color: var(--primary-light); }
.section-title {
    font-size: 1rem; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .06em;
    margin-bottom: 1rem;
    display: flex; align-items: center; gap: .5rem;
}
.section-title::before { content: ""; width: 28px; height: 2px; background: var(--primary-light); display: inline-block; }
.group-title {
    font-size: .85rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted);
    margin: .75rem 0 .5rem;
}

/* ── STAT CARDS ─────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 1.25rem 1.5rem; border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: .82rem; color: var(--text-muted); margin-top: .3rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── VIDEO CARDS ────────────────────────── */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 1.5rem; }
.video-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}
.video-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.video-thumb-btn { position: relative; display: block; width: 100%; border: 0; padding: 0; background: none; cursor: pointer; }
.video-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--primary); display: block; }
.video-thumb-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex; align-items: center; justify-content: center;
}
.play-icon {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}
.play-icon span {
    width: 52px; height: 52px;
    background: rgba(0,0,0,.6);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.video-card-body { padding: 1.25rem; }
.video-card-title { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; }
.video-card-desc  { font-size: .85rem; color: var(--text-muted); margin-bottom: .75rem; }
.video-category   { font-size: .75rem; background: rgba(0,95,115,.1); color: var(--primary); padding: .2rem .6rem; border-radius: 20px; display: inline-block; margin-bottom: .5rem; }

/* ── VIDEO PLAYER MODAL ─────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.75);
    z-index: 1000;
    display: none;
    align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); max-width: 860px; width: 100%; box-shadow: 0 24px 64px rgba(0,0,0,.4); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; background: var(--primary); color: #fff; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: rgba(255,255,255,.8); font-size: 1.4rem; cursor: pointer; line-height: 1; padding: .2rem .4rem; }
.modal-close:hover { color: #fff; }
.video-embed-wrap { position: relative; padding-bottom: 56.25%; height: 0; background: #000; }
.video-embed-wrap iframe, .video-embed-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }
.modal-desc { padding: 1rem 1.5rem; font-size: .9rem; color: var(--text-muted); white-space: pre-line; }

/* ── LOGIN PAGE ─────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 2rem;
}
.login-box { background: #fff; border-radius: 20px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 24px 64px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .icon-wrap {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    margin: 0 auto .75rem;
    display: flex; align-items: center; justify-content: center;
}
.login-logo h1 { font-size: 1.15rem; font-weight: 700; color: var(--primary-dark); }
.login-logo p  { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.login-divider { text-align: center; position: relative; margin: 1.5rem 0 .5rem; font-size: .75rem; color: var(--text-muted); letter-spacing: .05em; }
.login-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.login-divider span { background: #fff; padding: 0 .75rem; position: relative; }
.login-note { text-align: center; margin-top: 1.5rem; font-size: .8rem; color: var(--text-muted); }
.login-note a { color: var(--text-muted); }

/* ── ASSIGN CHECKBOXES ───────────────────── */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: .75rem; }
.check-item {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .85rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .15s;
}
.check-item:hover { border-color: var(--primary-light); background: rgba(0,95,115,.04); }
.check-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; margin-top: .15rem; }
.check-item.checked { border-color: var(--primary); background: rgba(0,95,115,.07); }
.check-label { font-size: .88rem; font-weight: 500; line-height: 1.3; }
.check-desc  { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }

/* ── VIDEO FORM ─────────────────────────── */
.src-tabs { display: flex; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.file-current {
    padding: .75rem;
    background: #edfaf2;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--success);
    margin-bottom: .75rem;
    font-size: .875rem;
}
.file-current strong { color: var(--success); }
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #fafcfd;
}
.drop-zone.dragover, .drop-zone.has-file { border-color: var(--primary-light); background: rgba(0,95,115,.05); }
.drop-zone p { color: var(--text-muted); font-size: .9rem; }
.drop-zone p.hint { font-size: .78rem; margin-top: .3rem; }
.drop-zone strong { color: var(--primary); }
.progress { margin-top: .75rem; }
.progress-head { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: .3rem; }
.progress-head span:first-child { font-weight: 600; }
.progress-head span:last-child { color: var(--primary); }
.progress-track { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { background: linear-gradient(90deg, var(--primary), var(--primary-light)); height: 100%; width: 0; transition: width .2s; }
.upload-status { font-size: .85rem; color: var(--primary); }
.upload-status.error { color: var(--danger); }

.thumb-sm {
    display: block;
    width: 96px;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 6px;
    background: var(--border);
}
.thumb-empty { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); opacity: .35; }
.thumb-preview { display: block; width: 100%; max-width: 320px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; margin-bottom: .6rem; }

/* ── SETTINGS ───────────────────────────── */
details.add-admin summary { cursor: pointer; font-weight: 600; color: var(--primary); font-size: .9rem; padding: .5rem 0; }
details.add-admin .inner { margin-top: 1rem; padding: 1.25rem; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ── UTIL ───────────────────────────────── */
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state svg { opacity: .35; margin-bottom: 1rem; }

@media (max-width: 600px) {
    .site-header { padding: 0 1rem; }
    .main-wrap { padding: 0 1rem; margin: 1rem auto; }
    .card { padding: 1.25rem; }
    .video-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}
