:root {
  color-scheme: light dark;
  --bg: #f1f5f9;
  --card: #fff;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --warn: #b45309;
  --bar: #3b82f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --card: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --warn: #fbbf24;
    --bar: #60a5fa;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 16px 48px;
}
.wrap { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 1.45rem; font-weight: 700; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 20px; }
nav.links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
  font-weight: 600;
  font-size: 0.9rem;
}
nav.links a {
  color: var(--accent);
  text-decoration: none;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--card);
  color: var(--text);
}
.row { margin-bottom: 14px; }
button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}
.flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meta { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
.hidden { display: none !important; }
.banner {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  background: #e0f2fe;
  color: #0c4a6e;
  border: 1px solid #38bdf8;
}
@media (prefers-color-scheme: dark) {
  .banner { background: #0c4a6e; color: #e0f2fe; border-color: #0369a1; }
}
.warn-box {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  background: #fffbeb;
  color: var(--warn);
  border: 1px solid #fcd34d;
}
.report-course-title {
  margin: 0 0 14px;
  padding: 0;
  width: 100%;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.report-progress-wrap {
  margin-top: 12px;
  margin-bottom: 4px;
}
.report-progress-wrap[data-progress-wrap="results"] {
  margin-bottom: 16px;
}
.report-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.report-progress-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.report-progress-track {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.report-progress-fill {
  height: 100%;
  background: var(--bar);
  border-radius: 999px;
  width: 0%;
  transition: width 0.4s ease;
}
.report-progress-wrap.is-indeterminate .report-progress-fill {
  width: 40%;
  animation: report-progress-slide 1.15s ease-in-out infinite;
}
@keyframes report-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.summary-grid .stat {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.summary-grid .stat strong { display: block; font-size: 1.2rem; }
.dropoff-panel h3 { margin: 0 0 10px; font-size: 1rem; }
.dropoff-bars {
  margin: 12px 0;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
}
.dropoff-bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 1fr 48px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
}
.dropoff-bar-row.dropoff-step-row {
  grid-template-columns: 52px minmax(140px, 1.4fr) 1fr minmax(72px, auto);
}
.dropoff-bar-row .dropoff-order {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
  padding-right: 4px;
}
.dropoff-bar-row .dropoff-step-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.step-link,
#dataTable a {
  color: var(--accent);
  text-decoration: none;
}
a.step-link:hover,
#dataTable a:hover {
  text-decoration: underline;
}
.dropoff-bar-row .dropoff-stats {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.dropoff-bar-row .bar-track {
  height: 10px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.dropoff-bar-row .bar-fill {
  height: 100%;
  background: var(--bar);
  border-radius: 4px;
}
.table-wrap {
  overflow-x: auto;
  max-height: 60vh;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
table.report-table th,
table.report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
table.report-table th {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
  cursor: pointer;
  user-select: none;
}
table.report-table tr:hover td { background: var(--bg); }
table.report-table a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
table.report-table a:hover { text-decoration: underline; }
.filter-input {
  max-width: 280px;
  margin-bottom: 10px;
}
.table-expand {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.table-expand > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 14px;
  list-style: none;
  user-select: none;
}
.table-expand > summary::-webkit-details-marker { display: none; }
.table-expand > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--muted);
}
.table-expand[open] > summary::before {
  transform: rotate(90deg);
}
.table-expand > :not(summary) {
  padding: 0 14px 14px;
}
.table-expand .table-wrap {
  margin-top: 0;
}
.lookback-presets {
  margin-bottom: 10px;
}
button.lookback-preset {
  padding: 6px 12px;
  font-size: 0.82rem;
}
button.lookback-preset.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#lookback-row.is-disabled input,
#lookback-row.is-disabled .lookback-presets {
  opacity: 0.45;
  pointer-events: none;
}
.print-only { display: none; }
@media print {
  body { padding: 0; background: #fff; color: #000; }
  .no-print { display: none !important; }
  .print-only { display: block; }
  .card { border: none; box-shadow: none; page-break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
  table.report-table th { position: static; }
  details.table-expand > summary { display: none; }
  details.table-expand > :not(summary) {
    display: block !important;
    padding: 0;
  }
  details.table-expand {
    border: none;
    background: transparent;
  }
}
