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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
  padding: 2rem 1rem;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #f8fafc;
}

h2 {
  font-size: 1.25rem;
  font-weight: 500;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.header {
  max-width: 900px;
  margin: 0 auto 2rem;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

/* Leaderboard table */
table {
  width: 100%;
  border-collapse: collapse;
  background: #1e2330;
  border-radius: 0.75rem;
  overflow: hidden;
  font-size: 1.05rem;
}

thead th {
  background: #2d3347;
  padding: 0.85rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #94a3b8;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr {
  border-top: 1px solid #2d3347;
  transition: background 0.15s;
}

tbody tr:hover {
  background: #252b3b;
}

td {
  padding: 0.85rem 1rem;
}

td.rank {
  font-weight: 700;
  font-size: 1.2rem;
  width: 3.5rem;
  text-align: center;
}

td.duration {
  font-family: ui-monospace, monospace;
  color: #7dd3fc;
}

td.schnitzel { color: #f97316; font-weight: 600; }
td.kartoffeln { color: #a78bfa; }

td.group-name {
  font-size: 0.8rem;
  color: #64748b;
}

/* Footer / refresh bar */
.refresh-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  color: #64748b;
  font-size: 0.875rem;
}

button {
  background: #2d3347;
  color: #e2e8f0;
  border: 1px solid #3d4660;
  border-radius: 0.375rem;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.15s;
}

button:hover { background: #3d4660; }

/* Landing page cohort list */
.cohort-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.cohort-list a {
  display: block;
  background: #1e2330;
  border: 1px solid #2d3347;
  border-radius: 0.6rem;
  padding: 1rem 1.25rem;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 1.05rem;
  transition: border-color 0.15s, background 0.15s;
}

.cohort-list a:hover {
  border-color: #5b6af5;
  background: #252b3b;
}

.empty {
  color: #64748b;
  margin-top: 1.5rem;
}

.error {
  color: #f87171;
  margin-top: 1rem;
}

/* ── Admin login ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.login-card {
  background: #1e2330;
  border: 1px solid #2d3347;
  border-radius: 0.75rem;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 1.75rem;
  text-align: center;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 1rem;
}

/* ── Form helpers ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.form-group label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input {
  background: #0f1117;
  border: 1px solid #2d3347;
  border-radius: 0.375rem;
  color: #e2e8f0;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: #5b6af5;
}

/* ── Admin layout ── */
.admin-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #151822;
  border-right: 1px solid #2d3347;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid #2d3347;
}

.sidebar-header h1 {
  font-size: 1.2rem;
}

.sidebar-label {
  padding: 0.75rem 1rem 0.35rem;
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.sidebar-section {
  padding: 0 0;
}

.sidebar-section .inline-form {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid #2d3347;
}

.sidebar-list {
  list-style: none;
  padding: 0 0.5rem;
  margin: 0;
}

.sidebar-item {
  display: flex;
  flex-direction: column;
  padding: 0.65rem 0.75rem;
  border-radius: 0.4rem;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 0.1rem;
}

.sidebar-item:hover { background: #1e2330; }
.sidebar-item.active { background: #252b3b; border-left: 3px solid #5b6af5; }

.item-name { font-size: 0.95rem; font-weight: 600; }
.item-slug { font-size: 0.75rem; color: #64748b; }

.empty-item {
  padding: 0.5rem 0.75rem;
  color: #64748b;
  font-size: 0.875rem;
}

/* ── Main content ── */
.admin-main {
  padding: 2rem;
  overflow-y: auto;
}

.cohort-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.cohort-header h2 {
  font-size: 1.5rem;
  color: #f8fafc;
  margin-bottom: 0.2rem;
}

.slug-badge {
  font-size: 0.8rem;
  color: #64748b;
  font-family: ui-monospace, monospace;
}

.cohort-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #2d3347;
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}

.tab-btn:hover { background: transparent; color: #e2e8f0; }
.tab-btn.active { color: #5b6af5; border-bottom-color: #5b6af5; }

/* ── Inline form (group/cohort add) ── */
.inline-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* ── Button variants ── */
.btn-ghost {
  background: transparent;
  border: 1px solid #3d4660;
  color: #94a3b8;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

.btn-ghost:hover { background: #2d3347; color: #e2e8f0; }

.btn-danger {
  background: transparent;
  border: 1px solid #7f1d1d;
  color: #f87171;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

.btn-danger:hover { background: #7f1d1d33; }

.btn-sm { font-size: 0.75rem; padding: 0.25rem 0.6rem; }

/* ── Token modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-card {
  background: #1e2330;
  border: 1px solid #2d3347;
  border-radius: 0.75rem;
  padding: 1.75rem;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-card h3 {
  font-size: 1.1rem;
  color: #f8fafc;
}

.token-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #0f1117;
  border: 1px solid #2d3347;
  border-radius: 0.4rem;
  padding: 0.6rem 0.75rem;
}

.token-display code {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  color: #7dd3fc;
  word-break: break-all;
}

.modal-warning {
  font-size: 0.85rem;
  color: #fbbf24;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-primary {
  background: #5b6af5;
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s;
}

.btn-primary:hover { background: #4a58e0; }

/* ── Handout page ── */
.handout-body {
  padding: 0;
}

.handout-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.handout-header {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.handout-card {
  background: #1e2330;
  border: 1px solid #2d3347;
  border-radius: 0.75rem;
  padding: 2rem 2rem 1.5rem;
}

.handout-title-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid #2d3347;
  padding-bottom: 1.5rem;
}

.handout-logo {
  font-size: 2.5rem;
  line-height: 1;
}

.handout-h1 {
  font-size: 1.4rem;
  color: #f8fafc;
  margin-bottom: 0.25rem;
}

.handout-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
}

.handout-section {
  margin-bottom: 1.75rem;
}

.handout-section h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.handout-token-box {
  background: #0f1117;
  border: 2px solid #5b6af5;
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, monospace;
  font-size: 1.05rem;
  color: #7dd3fc;
  word-break: break-all;
  letter-spacing: 0.03em;
}

.handout-code-block {
  background: #0f1117;
  border: 1px solid #2d3347;
  border-radius: 0.4rem;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  color: #e2e8f0;
  overflow-x: auto;
}

.handout-code-block pre {
  margin: 0;
  white-space: pre-wrap;
}

.handout-code-block .key     { color: #7dd3fc; }
.handout-code-block .str     { color: #86efac; }
.handout-code-block .num     { color: #f97316; }
.handout-code-block .comment { color: #64748b; }

.handout-note {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-top: 0.5rem;
}

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

.handout-table th {
  background: #2d3347;
  padding: 0.5rem 0.75rem;
  text-align: left;
  color: #94a3b8;
  font-weight: 600;
}

.handout-table td {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #2d3347;
}

.handout-table code {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  color: #7dd3fc;
}

.handout-footer {
  border-top: 1px solid #2d3347;
  padding-top: 1rem;
  text-align: center;
  color: #64748b;
  font-size: 0.875rem;
}

/* ── Top-3 row tints ── */
tbody tr.rank-1 { background: rgba(255, 195, 30, 0.08); }
tbody tr.rank-2 { background: rgba(192, 192, 192, 0.08); }
tbody tr.rank-3 { background: rgba(180, 120, 60, 0.08); }

tbody tr.rank-1:hover { background: rgba(255, 195, 30, 0.14); }
tbody tr.rank-2:hover { background: rgba(192, 192, 192, 0.14); }
tbody tr.rank-3:hover { background: rgba(180, 120, 60, 0.14); }

/* ── Beamer / classroom (≥ 1400px) ── */
@media (min-width: 1400px) {
  .header, .container { max-width: 1400px; }
  h1 { font-size: 3rem; }
  h2 { font-size: 1.6rem; }
  table { font-size: 1.5rem; }
  thead th { font-size: 1rem; padding: 1rem 1.25rem; }
  td { padding: 1.1rem 1.25rem; }
  td.rank { font-size: 2.2rem; width: 5rem; }
  td.group-name { font-size: 0.95rem; }
}

/* ── Mobile (≤ 700px) ── */
@media (max-width: 700px) {
  body { padding: 1rem 0.5rem; }
  table { font-size: 0.95rem; }
  thead th { padding: 0.6rem 0.6rem; font-size: 0.75rem; }
  td { padding: 0.6rem 0.6rem; }
  td.group-name { display: none; }
}

/* ── Print styles ── */
@media print {
  body, .handout-body { background: #fff !important; color: #000 !important; }

  .no-print-hide, .handout-header { display: none !important; }

  .handout-wrap { padding: 0; max-width: 100%; }

  .handout-card {
    background: #fff !important;
    border: none !important;
    border-radius: 0;
    padding: 0;
  }

  .handout-title-row { border-bottom: 2px solid #000 !important; }
  .handout-h1 { color: #000 !important; }
  .handout-subtitle { color: #444 !important; }

  .handout-section h2 { color: #555 !important; border-bottom: 1px solid #ccc; padding-bottom: 0.2rem; }

  .handout-token-box {
    background: #f0f4ff !important;
    border: 2px solid #3344cc !important;
    color: #001a99 !important;
  }

  .handout-code-block {
    background: #f8f8f8 !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
  }

  .handout-code-block .key     { color: #0066cc !important; }
  .handout-code-block .str     { color: #007700 !important; }
  .handout-code-block .num     { color: #cc4400 !important; }
  .handout-code-block .comment { color: #888 !important; }

  .handout-note { color: #555 !important; }

  .handout-table th { background: #eee !important; color: #000 !important; }
  .handout-table td { border-top: 1px solid #ccc !important; }
  .handout-table code { color: #003399 !important; }

  .handout-footer { color: #555 !important; border-top: 1px solid #ccc !important; }
}
