:root {
  --color-bg: #f4f6fa;
  --color-card: #ffffff;
  --color-text: #1a2230;
  --color-muted: #6b7280;
  --color-brand: #1d4ed8;
  --color-brand-dark: #1e3a8a;
  --color-ok: #16a34a;
  --color-ok-bg: #dcfce7;
  --color-ko: #dc2626;
  --color-ko-bg: #fee2e2;
  --color-info: #0284c7;
  --color-info-bg: #e0f2fe;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}
img { max-width: 100%; height: auto; }
a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Topbar */
.topbar, .admin-topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 14px 0;
}
.admin-topbar { background: var(--color-brand-dark); border-bottom: none; }
.admin-topbar a, .admin-topbar .brand { color: #fff; }
.topbar-inner, .admin-topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; color: var(--color-text); text-decoration: none; }
.topnav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topnav a { color: inherit; font-size: 14px; }
.user-name { font-weight: 600; color: var(--color-muted); }

/* Main */
main.container { padding: 28px 16px 80px; }
h1 { margin-top: 0; font-size: 26px; }
h2 { font-size: 20px; margin-top: 0; }
.muted { color: var(--color-muted); }
.small { font-size: 13px; }

/* Cards */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

/* Auth */
.auth-card {
  max-width: 420px;
  margin: 40px auto;
  background: #fff;
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
label input, label textarea, label select, input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  display: block;
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  background: #fff;
  font-family: inherit;
  margin-top: 2px;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--color-brand);
  outline-offset: 0;
  border-color: transparent;
}
.form-inline {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 12px 0;
}
.form-inline label { flex: 1; min-width: 180px; margin-bottom: 0; }
.form-block { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }

/* Buttons */
.btn, button.btn, button.primary {
  display: inline-block;
  padding: 9px 16px;
  background: #fff;
  color: var(--color-text);
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary, button.primary {
  background: var(--color-brand);
  color: #fff;
  border-color: var(--color-brand);
}
.btn.primary:hover, button.primary:hover { background: var(--color-brand-dark); }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }
.btn-link {
  background: none; border: none; padding: 4px 6px; color: var(--color-brand);
  cursor: pointer; font-size: 13px; font-family: inherit; text-decoration: none;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--color-ko); }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 7px; margin: 12px 0; font-size: 14px; }
.alert.success { background: var(--color-ok-bg); color: #065f46; border: 1px solid #86efac; }
.alert.error { background: var(--color-ko-bg); color: #7f1d1d; border: 1px solid #fca5a5; }
.alert.info { background: var(--color-info-bg); color: #075985; border: 1px solid #7dd3fc; }
.alert-card { padding: 22px; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 600; margin-left: 6px;
}
.badge.ok { background: var(--color-ok-bg); color: #065f46; }
.badge.ko { background: var(--color-ko-bg); color: #7f1d1d; }

/* Progress */
.progress-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.progress-bar {
  height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--color-brand); border-radius: 999px; transition: width .3s;
}

/* Modules list */
.modules-list { list-style: none; padding: 0; margin: 12px 0; }
.modules-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 14px 18px; margin-bottom: 8px;
  border-radius: 8px; box-shadow: var(--shadow);
}
.modules-list li.done { background: #f0fdf4; border-left: 3px solid var(--color-ok); }
.module-num {
  display: inline-block; background: var(--color-brand); color: #fff; width: 28px; height: 28px;
  border-radius: 50%; text-align: center; line-height: 28px; font-weight: 700; margin-right: 10px;
}
.module-title { font-weight: 600; }

/* PDF viewer */
.pdf-viewer { width: 100%; height: 650px; border: 1px solid #d1d5db; border-radius: 7px; overflow: hidden; }
.pdf-viewer iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Quiz */
.quiz-form .question { margin-bottom: 16px; }
.quiz-form legend { font-weight: 700; color: var(--color-brand); padding: 0 6px; }
.q-text { font-weight: 600; margin-top: 4px; }
.choix {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid #e5e7eb; border-radius: 7px; margin-bottom: 6px; cursor: pointer;
  font-weight: 400;
}
.choix:hover { background: #f9fafb; }
.choix input { width: auto; margin: 0; }

/* Result */
.result-card { text-align: center; padding: 30px; }
.big-score { font-size: 64px; font-weight: 800; margin-bottom: 8px; }
.big-score.ok { color: var(--color-ok); }
.big-score.ko { color: var(--color-ko); }
.result-detail { font-size: 16px; color: var(--color-muted); margin-bottom: 16px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 9px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.data-table th { background: #f9fafb; font-weight: 600; }
.data-table tr.row-inactive { opacity: .55; }
.actions-cell { white-space: nowrap; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin: 12px 0 24px; }
.stat {
  background: #fff; padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--color-brand); }
.stat-label { color: var(--color-muted); font-size: 13px; margin-top: 4px; }
.stat.ok .stat-num { color: var(--color-ok); }

/* Misc */
.breadcrumb { margin-bottom: 12px; font-size: 14px; }
.actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.footer { border-top: 1px solid #e5e7eb; padding: 14px 0; margin-top: 40px; background: #fff; color: var(--color-muted); }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.credentials th { text-align: left; padding: 6px 10px; }
.credentials td { padding: 6px 10px; }
details { margin: 8px 0; }
summary { cursor: pointer; padding: 6px 0; font-size: 15px; }
