:root {
  --blue: #0b7cff;
  --blue-dark: #063b78;
  --green: #20c997;
  --bg: #f4f8fb;
  --text: #102a43;
  --white: #ffffff;
  --soft: #e6eef5;
  --muted: #627d98;
  --danger: #d64545;
  --shadow: 0 18px 45px rgba(6, 59, 120, .12);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(11,124,255,.12), rgba(32,201,151,.14)),
    var(--bg);
}

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

.login-card {
  width: min(100%, 430px);
  background: var(--white);
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: var(--shadow);
}

.login-logo { width: 160px; margin-bottom: 24px; }
.admin-link { display: inline-block; margin-top: 18px; color: var(--blue-dark); font-weight: 700; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--soft);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 800;
  color: var(--blue-dark);
  padding: 6px 8px 18px;
}

.brand img { width: 48px; border-radius: var(--radius); }
.nav-list { display: grid; gap: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
}

.nav-item:hover, .nav-item:focus {
  background: #eef6ff;
  color: var(--blue-dark);
}

.nav-logout { margin-top: auto; color: var(--danger); }

.nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: currentColor;
  opacity: .9;
  mask-size: 20px;
  mask-position: center;
  mask-repeat: no-repeat;
}

.nav-icon[data-icon="grid"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7'/%3E%3Crect x='14' y='3' width='7' height='7'/%3E%3Crect x='14' y='14' width='7' height='7'/%3E%3Crect x='3' y='14' width='7' height='7'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="book"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/%3E%3Cpath d='M4 4.5A2.5 2.5 0 0 1 6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="user"], .nav-icon[data-icon="users"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M20 21a8 8 0 0 0-16 0'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="layers"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='m12 2 9 5-9 5-9-5 9-5Z'/%3E%3Cpath d='m3 12 9 5 9-5'/%3E%3Cpath d='m3 17 9 5 9-5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="play"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="check"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3'%3E%3Cpath d='m20 6-11 11-5-5'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="chart"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M3 3v18h18'/%3E%3Cpath d='m7 15 4-4 3 3 5-7'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="logout"] { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpath d='m16 17 5-5-5-5'/%3E%3Cpath d='M21 12H9'/%3E%3C/svg%3E"); }

.main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 { margin: 0; font-size: 28px; color: var(--blue-dark); }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.topbar-user img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--soft);
}

.topbar-user small, table small { display: block; color: var(--muted); }
.sidebar-toggle { display: none; }

.hero-band, .course-hero, .result-card {
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  color: var(--white);
  padding: 30px;
  box-shadow: var(--shadow);
}

.hero-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.hero-band h2 { margin: 0 0 10px; max-width: 760px; font-size: 34px; line-height: 1.15; }
.hero-band .eyebrow, .course-hero .eyebrow, .result-card .eyebrow { color: #c8ffe9; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card, .panel, .course-card, .login-card {
  background: var(--white);
  border: 1px solid var(--soft);
}

.stat-card {
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card span, .muted { color: var(--muted); }
.stat-card strong { display: block; margin-top: 8px; font-size: 34px; color: var(--blue-dark); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .7fr);
  gap: 18px;
  margin-bottom: 22px;
}

.admin-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.panel {
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 10px 28px rgba(6, 59, 120, .07);
}

.panel-large { min-width: 0; }
.narrow { max-width: 760px; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

h1, h2, h3, h4, p { overflow-wrap: anywhere; }
h2, h3, h4 { margin-top: 0; color: var(--blue-dark); }
.hero-band h2, .course-hero h2, .result-card h2 { color: var(--white); }

.btn {
  border: 0;
  border-radius: var(--radius);
  padding: 11px 16px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  cursor: pointer;
  white-space: normal;
}

.btn-primary { background: var(--blue); color: var(--white); }
.btn-secondary { background: #eef6ff; color: var(--blue-dark); }
.btn-light { background: var(--white); color: var(--blue-dark); }
.btn-disabled { background: var(--soft); color: var(--muted); pointer-events: none; }
.btn-block { width: 100%; }
.btn-small { min-height: 34px; padding: 7px 10px; font-size: 14px; }
.text-link { color: var(--blue); font-weight: 800; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.course-card {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(6, 59, 120, .08);
}

.course-card > img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--soft);
}

.course-card-body { padding: 18px; }
.course-card h2 { font-size: 21px; }
.course-meta, .course-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e7f7ff;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 12px;
}

.badge-ok { background: #dcfff2; color: #087f5b; }
.badge-bad { background: #ffe8e8; color: #a61b1b; }

.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
  margin: 14px 0 8px;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.course-row {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 18px;
  align-items: center;
}

.course-row img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
}

.activity-list, .certificate-list, .answer-review {
  display: grid;
  gap: 12px;
}

.activity-list > div, .certificate-list a, .answer-review article {
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 14px;
}

.activity-list span, .certificate-list span { display: block; color: var(--muted); }

.course-hero {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  margin-bottom: 22px;
}

.course-hero img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
}

.module-list { display: grid; gap: 16px; }
.module { border: 1px solid var(--soft); border-radius: var(--radius); padding: 18px; }
.lesson-link {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--soft);
}

.check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--soft);
  border-radius: 50%;
}

.check.done { background: var(--green); border-color: var(--green); }

.lesson-panel {
  max-width: 960px;
  background: var(--white);
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.video-box {
  margin: 20px 0;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.video-box iframe, .video-box video {
  width: 100%;
  height: 100%;
  border: 0;
}

.lesson-content {
  font-size: 18px;
  color: #243b53;
}

.lesson-actions, .action-row, .row-actions, .filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form { display: grid; gap: 16px; }
.form label span { display: block; margin-bottom: 7px; font-weight: 800; color: var(--blue-dark); }
.form input, .form select, .form textarea, .filters input, .filters select {
  width: 100%;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--white);
  color: var(--text);
}

.form textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: auto; }

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0;
  font-weight: 700;
}

.alert-error { background: #ffe8e8; color: #8a1c1c; }
.alert-success { background: #dcfff2; color: #087f5b; }

.question {
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 16px;
}

.question legend { font-weight: 900; color: var(--blue-dark); padding: 0 8px; }
.option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
}

.result-card {
  text-align: center;
  margin-bottom: 22px;
}

.score {
  display: block;
  font-size: 74px;
  line-height: 1;
  margin: 10px 0;
}

.answer-review .ok { color: #087f5b; }
.answer-review .bad { color: #a61b1b; }
.answer-review span, .answer-review small { display: block; margin-top: 6px; }

.profile-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}

.profile-card { text-align: center; }
.profile-card img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 18px;
  background: var(--soft);
}

dl { display: grid; gap: 10px; text-align: left; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; font-weight: 800; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th { color: var(--blue-dark); font-size: 13px; text-transform: uppercase; }

.certificate-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #eef6ff;
}

.certificate {
  width: min(100%, 980px);
  min-height: 660px;
  background: var(--white);
  border: 12px solid #d6eaff;
  outline: 2px solid var(--blue);
  border-radius: var(--radius);
  padding: 54px;
  text-align: center;
  display: grid;
  align-content: center;
  gap: 22px;
}

.certificate img { width: 180px; margin: 0 auto; }
.certificate h1 { color: var(--blue-dark); font-size: 44px; margin: 0; }
.certificate-text { font-size: 22px; max-width: 780px; margin: 0 auto; }
.certificate-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 10px 0;
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .profile-grid, .course-hero, .admin-columns { grid-template-columns: 1fr; }
  .course-row { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 76px; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: 70px;
    padding: 8px;
    border-right: 0;
    border-top: 1px solid var(--soft);
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .sidebar .brand { display: none; }
  .nav-list { display: flex; gap: 4px; flex: 1; }
  .nav-item {
    min-width: 74px;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    font-size: 12px;
    text-align: center;
  }
  .nav-logout { margin-top: 0; }
  .main { padding: 16px; }
  .topbar { align-items: flex-start; }
  .topbar-user div { display: none; }
  .sidebar-toggle { display: none; }
  .hero-band { display: grid; }
  .hero-band h2 { font-size: 27px; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid, .certificate-meta { grid-template-columns: 1fr; }
  .lesson-link { grid-template-columns: 26px 1fr; }
  .lesson-link small { grid-column: 2; }
  .certificate { padding: 28px; min-height: auto; }
  .certificate h1 { font-size: 30px; }
  .certificate-text { font-size: 18px; }
}

@media print {
  body { background: var(--white); }
  .no-print { display: none !important; }
  .certificate-page { padding: 0; background: var(--white); }
  .certificate { min-height: 100vh; border-color: #d6eaff; outline: 0; box-shadow: none; }
}
