/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --bg: #f5f5f0;
  --surface: #ffffff;
  --surface-alt: #f0efe9;
  --border: #ddd9d0;
  --border-strong: #b8b3a8;

  --text: #1a1916;
  --text-muted: #6b6760;
  --text-light: #9b9790;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --accent-text: #ffffff;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.07), 0 4px 6px rgba(0,0,0,.05);

  --max-w: 720px;
  --max-w-wide: 1200px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1c1b1a;
    --surface-alt: #252421;
    --border: #2e2c29;
    --border-strong: #4a4742;

    --text: #f0ede8;
    --text-muted: #a09c96;
    --text-light: #6b6760;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: #1e3a5f;
    --accent-text: #ffffff;

    --success: #22c55e;
    --success-bg: #14301f;
    --error: #ef4444;
    --error-bg: #2d1515;
    --warning: #f59e0b;
    --warning-bg: #2d2010;

    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.4);
  }
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1rem; font-weight: 600; }

p { margin-top: 0.5rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1rem;
}

.container-wide {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Header / Nav ────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-logo span {
  color: var(--accent);
}

.header-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ── Hero / Page title ────────────────────────────────────────────────────── */
.page-hero {
  padding: 2.5rem 0 2rem;
}

.page-hero .tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 0.25em 0.75em;
  margin-bottom: 0.75rem;
}

.page-hero h1 { margin-bottom: 0.5rem; }

.page-hero .subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 55ch;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 0.75rem; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ── Course list ──────────────────────────────────────────────────────────── */
.cours-section { margin-bottom: 2.5rem; }

.cours-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.cours-section-header h2 { flex: 1; }

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

.cours-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.cours-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.cours-card-body { flex: 1; }
.cours-card-body h2 { font-size: 1.05rem; margin: 0 0 0.35rem; }

.nav-back {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
}
.nav-back:hover { color: var(--accent); }

.exercice-list {
  display: grid;
  gap: 0.75rem;
}

.exercice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.exercice-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.exercice-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}

.exercice-card .meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.exercice-card .arrow {
  color: var(--text-light);
  flex-shrink: 0;
  transition: transform .15s, color .15s;
}

.exercice-card:hover .arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.exercice-card--externe {
  border-color: var(--border);
}
.exercice-card--externe:hover {
  border-color: var(--accent);
}
.exercice-card--externe:hover .arrow {
  color: var(--accent);
  transform: translateX(2px) translateY(-2px);
}

.exercice-card--bientot {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}

/* ── Quiz layout ─────────────────────────────────────────────────────────── */
.quiz-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0 1.25rem;
  margin-bottom: 1.5rem;
}

.consigne-box {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 1rem;
}

.quiz-form {
  padding-bottom: 3rem;
}

.identity-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.identity-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

.identity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 480px) {
  .identity-grid { grid-template-columns: 1fr; }
}

/* ── Form fields ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.375rem; }

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.field label .required {
  color: var(--error);
  margin-left: 0.2em;
}

.field label .optional {
  color: var(--text-light);
  font-size: 0.8em;
  font-weight: 400;
  margin-left: 0.3em;
}

.input {
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.625rem 0.875rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.input::placeholder { color: var(--text-light); }

textarea.input {
  resize: vertical;
  min-height: 100px;
}

/* ── Bloc separator ──────────────────────────────────────────────────────── */
.bloc {
  margin-bottom: 1.75rem;
}

.bloc-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-alt);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

.bloc-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.bloc-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15em 0.6em;
  margin-left: auto;
}

/* ── Question card ───────────────────────────────────────────────────────── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color .15s;
}

.question-card.answered {
  border-color: var(--border-strong);
}

.question-num {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.question-enonce {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 1rem;
  line-height: 1.5;
}

/* ── QCM options ─────────────────────────────────────────────────────────── */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.option-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .1s, background .1s;
  line-height: 1.5;
}

.option-label:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.option-label input[type=radio] {
  margin-top: 0.2em;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.option-label input[type=radio]:checked ~ * { font-weight: 500; }

.option-label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.option-text { flex: 1; }

.option-label.jnsp {
  border-style: dashed;
  color: var(--text-muted);
}

.option-label.jnsp:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.option-label.jnsp:has(input:checked) {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

/* ── Code options ────────────────────────────────────────────────────────── */
.option-code pre {
  margin: 0;
  font-size: 0.8125rem;
  background: none;
  border: none;
  padding: 0;
}

/* ── Échelle ─────────────────────────────────────────────────────────────── */
.echelle-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.echelle-label-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 80px;
}

.echelle-label-text.right { text-align: right; min-width: 80px; }

.echelle-options {
  display: flex;
  gap: 0.375rem;
  flex: 1;
  justify-content: center;
}

.echelle-btn-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.echelle-btn-label input[type=radio] { display: none; }

.echelle-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: border-color .1s, background .1s, color .1s;
  user-select: none;
}

.echelle-btn-label:hover .echelle-btn {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.echelle-btn-label input:checked + .echelle-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

@media (max-width: 480px) {
  .echelle-row { flex-direction: column; align-items: flex-start; }
  .echelle-options { justify-content: flex-start; }
}

/* ── Code field section ──────────────────────────────────────────────────── */
.code-section {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.code-section h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--warning);
}

/* ── Submit area ─────────────────────────────────────────────────────────── */
.submit-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
  text-align: center;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
  -webkit-appearance: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px rgba(37,99,235,.3);
  text-decoration: none;
  color: var(--accent-text);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  text-decoration: none;
  color: var(--text);
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-danger:hover {
  background: var(--error);
  color: #fff;
  text-decoration: none;
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.4rem 0.8rem;
}

.btn-lg {
  font-size: 1.0625rem;
  padding: 0.8rem 2rem;
}

/* ── Results section ─────────────────────────────────────────────────────── */
#results-section { display: none; }

#results-section.visible { display: block; margin-top: 2rem; }

.score-summary {
  background: var(--surface);
  border: 2px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.score-main {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--success);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.score-label { color: var(--text-muted); font-size: 0.9rem; }

.score-blocs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.score-bloc {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  text-align: center;
}

.score-bloc strong { display: block; font-size: 1.125rem; }

.corrections-list { display: flex; flex-direction: column; gap: 0.75rem; }

.correction-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 4px solid var(--border);
}

.correction-item.correct { border-left-color: var(--success); }
.correction-item.incorrect { border-left-color: var(--error); }

.correction-status {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.correction-status.ok { color: var(--success); }
.correction-status.ko { color: var(--error); }

.correction-enonce { font-weight: 500; margin-bottom: 0.5rem; }

.correction-answer {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.correction-explication {
  font-size: 0.875rem;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--border-strong);
  margin-top: 0.5rem;
}

/* ── Error / Alert boxes ─────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error);
  color: var(--error);
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  color: var(--warning);
}

#error-section { display: none; margin-top: 1rem; }
#error-section.visible { display: block; }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.admin-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 1.5rem;
}

.admin-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.admin-card h3 { margin-bottom: 0.25rem; }

.admin-card .meta { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1rem; }

.admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

/* ── Code form ───────────────────────────────────────────────────────────── */
.code-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.code-form .input { max-width: 120px; }

.code-status {
  font-size: 0.8rem;
  padding: 0.25em 0.6em;
  border-radius: 999px;
  font-weight: 600;
}

.code-status.active { background: var(--success-bg); color: var(--success); }
.code-status.inactive { background: var(--surface-alt); color: var(--text-muted); }

/* ── Data table ──────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--surface-alt);
  border-bottom: 2px solid var(--border);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  user-select: none;
}

th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
th.sort-asc::after { content: " ▲"; font-size: 0.7em; }
th.sort-desc::after { content: " ▼"; font-size: 0.7em; }

td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

tr:hover td { background: var(--surface-alt); }

.td-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.td-text {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Binômes ─────────────────────────────────────────────────────────────── */
#binomes-result {
  display: none;
  margin-top: 1.5rem;
}

#binomes-result.visible { display: block; }

.binomes-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 1rem;
}

.binome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.binome-card h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.binome-student {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}

.binome-student:last-child { border-bottom: none; }

.binome-name { font-weight: 500; }
.binome-score { color: var(--text-muted); font-size: 0.8125rem; }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ── Progress indicator ──────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 1.25em;
  height: 1.25em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-gray { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Pagination / back ───────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text); font-weight: 500; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state p { margin-top: 0.5rem; font-size: 0.9rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 4rem;
  font-size: 0.8125rem;
  color: var(--text-light);
  text-align: center;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.font-mono { font-family: var(--font-mono); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Log viewer ──────────────────────────────────────────────────────────── */
.log-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg-btn {
  padding: .35rem .9rem;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  transition: background .12s, color .12s;
  user-select: none;
}
.seg-btn input { display: none; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active,
.seg-btn:hover { background: var(--surface-alt); color: var(--text); }
.seg-btn.active { color: var(--accent); font-weight: 600; }

.log-select {
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  cursor: pointer;
}

.log-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .85rem;
  border-radius: 999px;
  font-size: .8125rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.stat-chip.stat-danger { background: var(--error-bg); border-color: var(--error); }
.stat-chip.stat-success { background: var(--success-bg); border-color: var(--success); }
.stat-val { font-weight: 700; font-size: .95rem; }
.stat-lbl { color: var(--text-muted); }
.stat-chip.stat-danger .stat-val { color: var(--error); }
.stat-chip.stat-success .stat-val { color: var(--success); }
.stat-chip.stat-top code { font-size: .8rem; background: var(--surface); padding: 1px 5px; border-radius: 3px; }

.log-viewer {
  background: #0d1117;
  border-radius: var(--radius-lg);
  border: 1px solid #30363d;
  overflow: auto;
  max-height: 72vh;
  box-shadow: var(--shadow-lg);
}

.log-pre {
  margin: 0;
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.55;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line { display: block; }
.log-line + .log-line { border-top: 1px solid #21262d; }
.log-danger { color: #ff7b72; background: rgba(255,123,114,.06); }
.log-success { color: #56d364; background: rgba(86,211,100,.05); }
.log-info { color: #79c0ff; }
.log-warn { color: #e3b341; background: rgba(227,179,65,.05); }
