:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --ok: #1c7a4a;
  --ok-bg: #e4f4ec;
  --warn: #8a5a00;
  --warn-bg: #fdf1dc;
  --bad: #a32020;
  --bad-bg: #fbe7e7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }

/* ---------- layout ---------- */

.topbar {
  background: #101820;
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}

.topbar .brand {
  font-weight: 650;
  letter-spacing: .2px;
  font-size: 15px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.topbar nav { display: flex; gap: 4px; height: 100%; }

.topbar nav a {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: #cbd3dc;
  text-decoration: none;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}

.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.topbar nav a.active { color: #fff; border-bottom-color: #4c9fd8; }
.topbar .spacer { flex: 1; }

.page { max-width: 1160px; margin: 0 auto; padding: 28px 24px 64px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.panel h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; }
.panel h2 .hint { font-weight: 400; color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
}

/* ---------- stat tiles ---------- */

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  font-weight: 600;
}

.stat .value { font-size: 28px; font-weight: 650; margin-top: 4px; line-height: 1.1; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  font-weight: 650;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

table td.num, table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }

input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cfd5dc;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}

select[multiple] { padding: 6px; }
select[multiple] option { padding: 6px 8px; border-radius: 4px; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 95, 139, .35);
  outline-offset: 0;
  border-color: var(--accent);
}

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

.field { margin-bottom: 14px; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.row > .shrink { flex: 0 0 auto; }

.checklist {
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}

.checklist label {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-weight: 400;
  font-size: 14px;
  padding: 7px 8px;
  border-radius: 5px;
  cursor: pointer;
  margin: 0;
}

.checklist label:hover { background: #f4f7fa; }
.checklist input { margin: 2px 0 0; }
.checklist .meta { color: var(--muted); font-size: 12.5px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #cfd5dc;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn:hover { background: #f5f6f8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #17506f; }
.btn.danger { color: var(--bad); border-color: #e8c2c2; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.inline-form { display: inline; }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: #eef0f3; color: #5b6472; }

/* ---------- progress ---------- */

.bar {
  height: 7px;
  background: #e9edf1;
  border-radius: 999px;
  overflow: hidden;
  min-width: 90px;
}

.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.done > span { background: var(--ok); }

.progress-cell { display: flex; align-items: center; gap: 9px; }
.progress-cell .pct { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 38px; }

/* ---------- flashes ---------- */

.flashes { margin-bottom: 16px; }

.flash {
  padding: 11px 14px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash.success { background: var(--ok-bg); color: var(--ok); border-color: #bfe0ce; }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: #eec3c3; }

/* ---------- misc ---------- */

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.empty { color: var(--muted); padding: 22px 10px; text-align: center; font-size: 14px; }

.link-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.link-box input { border: none; background: transparent; padding: 0; font-size: 13px; }

.copy-link { min-width: 260px; }
.copy-link input { flex: 1 1 auto; min-width: 0; }

hr.sep { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- trainee page ---------- */

body.trainee { background: #eef1f4; }

.trainee-wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }

.trainee-head {
  background: #101820;
  color: #fff;
  padding: 22px 20px 26px;
}

.trainee-head .inner { max-width: 900px; margin: 0 auto; }
.trainee-head h1 { margin: 0 0 4px; font-size: 20px; font-weight: 650; }
.trainee-head p { margin: 0; color: #b7c1cc; font-size: 14px; }

.trainee-status {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.trainee-status .bar { flex: 1 1 220px; background: rgba(255, 255, 255, .18); }
.trainee-status .bar > span { background: #4c9fd8; }
.trainee-status .bar.done > span { background: #3fbf87; }

.trainee-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.trainee-card > header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.trainee-card > header h2 { margin: 0; font-size: 16px; font-weight: 650; }

.video-list { list-style: none; margin: 0; padding: 0; }

.video-item {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}

.video-item:last-child { border-bottom: none; }
.video-item.done { background: #fbfdfc; }

.video-thumb {
  width: 116px;
  height: 66px;
  border-radius: 5px;
  background: #dfe4ea;
  flex: 0 0 auto;
  overflow: hidden;
  position: relative;
}

.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.video-thumb .play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}

.video-meta { flex: 1 1 auto; min-width: 0; }
.video-meta .t { font-size: 14.5px; font-weight: 550; margin-bottom: 3px; }
.video-meta .s { font-size: 12.5px; color: var(--muted); }

.video-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.player-wrap { padding: 0; }
.player-wrap iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; background: #000; }

.player-problem {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #ecd5a8;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--radius);
  font-size: 14px;
}

.done-banner {
  background: var(--ok-bg);
  color: var(--ok);
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid #bfe0ce;
  margin-bottom: 18px;
  font-weight: 600;
}

.done-banner .sub { font-weight: 400; font-size: 14px; margin-top: 4px; }

.callout {
  background: #f0f6fb;
  border: 1px solid #cfe1ef;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13.5px;
  color: #1d4763;
  margin-bottom: 14px;
}

.callout.ok {
  background: #eef7f0;
  border-color: #bcdfc7;
  color: #1c5333;
}

.callout.error {
  background: #fdf0ef;
  border-color: #f0c8c4;
  color: #7d2b23;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink);
  margin: 8px 0 14px;
  cursor: pointer;
}

label.checkbox input { width: auto; margin: 0; }
