:root {
  --bg: #f5f7fa; --surface: #fff; --text: #1b2430; --muted: #66727f; --line: #e3e8ee;
  --brand: #0f4c81; --brand-2: #e8f0f8; --accent: #f2a900;
  --green: #1d7a46; --green-bg: #e3f4ea; --red: #b42318; --red-bg: #fde8e7;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin: 0 0 .7em; }
code { background: var(--brand-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; word-break: break-all; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--red); }

.topbar { background: var(--brand); color: #fff; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; min-height: 58px; gap: 12px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.logo { background: var(--accent); color: #1b2430; font-weight: 800; border-radius: 6px; padding: 3px 7px; font-size: .85rem; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a, .topbar .link { color: #fff; opacity: .9; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }

main.wrap { padding-top: 20px; padding-bottom: 40px; min-height: calc(100vh - 120px); }
.foot { color: var(--muted); font-size: .85rem; padding-bottom: 24px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.center-card { text-align: center; padding: 40px 18px; }
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn.ghost { background: var(--brand-2); color: var(--brand); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.full { width: 100%; }
.topbar .btn.sm { background: var(--accent); color: #1b2430; }

label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 12px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--brand-2); border-color: var(--brand); }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
label.check { font-weight: 400; display: flex; align-items: center; margin-bottom: 6px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; }
legend { font-weight: 600; font-size: .88rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid.compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-items: end; }
.form-grid .span2 { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input, .inline-form select { margin: 0; width: auto; flex: 1; padding: 5px 8px; }
.inline-form .w-sort { width: 64px; flex: 0 0 64px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.row-actions form { margin: 0; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { margin: 0; max-width: 360px; }
.danger-zone { text-align: right; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline-flex; margin: 0 0 0 6px; vertical-align: middle; }
td.actions .inline-form select { width: 84px; flex: none; }
.card { overflow-x: auto; }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--brand-2); color: var(--brand); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--green-bg); color: var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); }

.hero { background: linear-gradient(135deg, var(--brand), #1a6aa8); color: #fff; border-radius: 14px; padding: 42px 32px; margin-bottom: 26px; }
.hero h1 { font-size: 1.9rem; max-width: 720px; }
.hero p { opacity: .9; max-width: 620px; }
.hero .btn { background: var(--accent); color: #1b2430; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.course-card { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.course-card h3 { margin: 6px 0 0; }
.course-card p { margin: 0 0 6px; }
.course-card .btn { margin-top: auto; align-self: flex-start; }
.course-card.dim { opacity: .7; }
.course-icon { width: 46px; height: 46px; border-radius: 10px; background: var(--brand-2); color: var(--brand); display: grid; place-items: center; font-weight: 800; }

.auth { max-width: 420px; margin: 30px auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { margin: 0; display: flex; flex-direction: column; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat b { font-size: 1.6rem; }
.stat small { color: var(--muted); }
.stat.warn { border-color: var(--accent); background: #fff8e6; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col > .card { margin-bottom: 18px; }
.creds { border-color: var(--accent); background: #fff8e6; }
.creds pre { background: #fff; padding: 12px; border-radius: 8px; border: 1px solid var(--line); user-select: all; }

.course-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.course-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; user-select: none; }
.player video { width: 100%; height: 100%; display: block; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.wm { position: absolute; top: 0; left: 0; color: rgba(255,255,255,.35); font-size: 14px; font-weight: 600; pointer-events: none;
  text-shadow: 0 0 2px rgba(0,0,0,.5); transition: transform 2s ease; white-space: nowrap; z-index: 2; }
.fs-btn { position: absolute; top: 10px; right: 10px; z-index: 3; background: rgba(0,0,0,.45); color: #fff; border: 0; border-radius: 6px; font-size: 18px; width: 36px; height: 34px; cursor: pointer; opacity: .75; }
.fs-btn:hover { opacity: 1; }
.player-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,.75); padding: 20px; text-align: center; z-index: 4; }
.player-msg[hidden] { display: none; }
.lec-title { margin-top: 14px; }
.lec-list { padding: 14px 0; max-height: 75vh; overflow-y: auto; }
.lec-list h3 { padding: 0 16px; }
.lec-list ol { list-style: none; margin: 0; padding: 0; counter-reset: lec; }
.lec-list li { counter-increment: lec; }
.lec-list li a { display: flex; justify-content: space-between; gap: 8px; padding: 9px 16px; color: var(--text); }
.lec-list li a::before { content: counter(lec) "."; color: var(--muted); min-width: 24px; }
.lec-list li a span:first-of-type { flex: 1; }
.lec-list li a:hover { background: var(--bg); text-decoration: none; }
.lec-list li.on a { background: var(--brand-2); color: var(--brand); font-weight: 600; }
.up-row { display: grid; grid-template-columns: 1fr 140px 90px; gap: 8px; align-items: center; margin-top: 8px; font-size: .88rem; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress { width: 100%; }

@media (max-width: 860px) {
  .course-layout, .two-col, .form-grid { grid-template-columns: 1fr; }
  .hero { padding: 28px 20px; }
}
