:root {
    --bg: #eef8fb;
    --surface: rgba(255,255,255,.88);
    --surface-strong: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #0ea5a4;
    --primary-dark: #087f8c;
    --secondary: #2563eb;
    --danger: #ef4444;
    --warning: #f59e0b;
    --ok: #10b981;
    --line: #dbeafe;
    --shadow: 0 20px 45px rgba(15, 23, 42, .08);
    --radius: 22px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body.app-body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(45,212,191,.28), transparent 30%),
        radial-gradient(circle at top right, rgba(59,130,246,.25), transparent 35%),
        linear-gradient(135deg, #eef8fb 0%, #f8fbff 100%);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 5vw;
    background: rgba(255,255,255,.78);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(148,163,184,.2);
}

.brand-wrap { display: flex; align-items: center; gap: 14px; }
.logos { display: flex; align-items: center; gap: 6px; }
.logos img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 12px;
    background: white;
    box-shadow: 0 6px 20px rgba(15,23,42,.08);
}
.brand-text h1 { font-size: 17px; line-height: 1.1; margin: 0; }
.brand-text p { font-size: 13px; margin: 2px 0; color: var(--muted); }
.brand-text strong { font-size: 13px; color: var(--primary-dark); }

.nav-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.nav-actions a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    padding: 9px 12px;
    border-radius: 999px;
    transition: .2s;
}
.nav-actions a:hover { background: rgba(14,165,164,.1); color: var(--primary-dark); }

.container {
    width: min(1180px, 92vw);
    margin: 28px auto 80px;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 5vw;
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(18px);
    border-top: 1px solid rgba(148,163,184,.2);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.login-shell {
    min-height: calc(100vh - 220px);
    display: grid;
    place-items: center;
}
.glass-card, .panel, .video-card, .stat-card {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.8);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}
.login-card {
    width: min(460px, 94vw);
    padding: 34px;
}
.login-badge, .eyebrow {
    display: inline-flex;
    color: var(--primary-dark);
    background: rgba(14,165,164,.12);
    border: 1px solid rgba(14,165,164,.16);
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
h2 { font-size: clamp(24px, 3vw, 36px); margin: 10px 0 8px; }
h3 { margin: 0 0 14px; }
h4 { margin: 12px 0 8px; }
.muted { color: var(--muted); }
small { color: var(--muted); }

.form-stack, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
label { font-size: 14px; font-weight: 700; color: #334155; }
input, select {
    width: 100%;
    margin-top: 6px;
    border: 1px solid #dbeafe;
    background: rgba(255,255,255,.92);
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--text);
    outline: none;
    transition: .2s;
}
input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14,165,164,.12);
}
.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
}
.checkline input {
    width: auto;
    margin: 0;
}

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 800;
    transition: .18s ease;
    white-space: nowrap;
}
.btn-primary { color: white; background: linear-gradient(135deg, var(--primary), var(--secondary)); box-shadow: 0 10px 24px rgba(37,99,235,.18); }
.btn-secondary { color: #0f172a; background: #e0f2fe; }
.btn-ghost { color: var(--primary-dark); background: rgba(14,165,164,.1); }
.btn-danger { color: white; background: var(--danger); }
.btn-small { padding: 8px 12px; font-size: 12px; }
.btn-primary:hover, .btn-secondary:hover, .btn-ghost:hover, .btn-danger:hover { transform: translateY(-1px); filter: brightness(.98); }

.alert {
    padding: 13px 16px;
    border-radius: 14px;
    margin: 12px 0;
    font-weight: 700;
}
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-warning { background: #fef3c7; color: #92400e; }

.security-note, .viewer-warning {
    margin-top: 18px;
    padding: 12px 14px;
    background: rgba(37,99,235,.08);
    border-radius: 14px;
    color: #1e40af;
    font-size: 13px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}
.metric-mini, .stat-card {
    padding: 18px;
    text-align: center;
}
.metric-mini strong, .stat-card strong {
    display: block;
    font-size: 34px;
    color: var(--primary-dark);
}
.metric-mini span, .stat-card span { color: var(--muted); font-weight: 700; }

.filter-bar {
    display: flex;
    align-items: end;
    gap: 12px;
    margin: 18px 0 22px;
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(219,234,254,.9);
    border-radius: var(--radius);
    padding: 14px;
}
.filter-bar input, .filter-bar select { margin: 0; }

.course-section { margin: 28px 0; }
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.video-card { padding: 18px; overflow: hidden; }
.video-date {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--primary-dark);
}
.video-date span { color: var(--muted); }
.video-card p { color: var(--muted); min-height: 42px; }
.empty-state {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: var(--radius);
    color: var(--muted);
}

.watch-head {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}
.secure-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(15,23,42,.16);
    background: #020617;
    user-select: none;
}
.secure-player iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.quick-actions, .actions-row, .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.panel {
    padding: 18px;
    margin-bottom: 20px;
}
.table-responsive {
    width: 100%;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th {
    text-align: left;
    color: #334155;
    background: #f0f9ff;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}
td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}
tr:hover td { background: rgba(14,165,164,.04); }
.actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.actions form { margin: 0; }
.pill {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}
.pill-ok { color: #065f46; background: #d1fae5; }
.pill-off { color: #7f1d1d; background: #fee2e2; }

pre {
    white-space: pre-wrap;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 16px;
    padding: 14px;
    overflow-x: auto;
}

@media (max-width: 900px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .video-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
    .brand-text h1 { font-size: 14px; }
    .brand-text p, .brand-text strong { font-size: 12px; }
    .logos img { width: 34px; height: 34px; }
    .page-head, .filter-bar { flex-direction: column; align-items: stretch; }
    .video-grid, .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 22px; }
    .container { width: min(94vw, 1180px); margin-top: 18px; }
}
