/* ══════════════════════════════════════════════════════════════
   Guardian Panel CTF — Design System
   Based on Guardian_Panel CTF Figma
   ══════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }
/* Component flex/grid rules must not make intentionally hidden controls visible. */
[hidden]:not([hidden="until-found"]) { display: none !important; }

:root {
  /* Backgrounds */
  --bg-page: #1c2835;
  --bg-card: #041324;
  --bg-sidebar: #041324;
  --bg-topbar: #041324;

  /* Primary */
  --primary: #007bff;
  --primary-hover: #0069d9;
  --logo-red: #ff1919;

  /* Text */
  --text-primary: #f8fbff;
  --text-muted: #9ca5b1;
  --text-helper: #bfc8d3;

  /* Status colors */
  --green: #1bd170;
  --red: #ff4d4d;
  --yellow: #fbbf24;
  --orange: #f59e0b;
  --purple: #a78bfa;

  /* Backward-compat aliases (used in main.js inline styles) */
  --text: var(--text-primary);
  --text-dim: var(--text-muted);
  --blue: var(--primary);
  --bg-primary: var(--bg-page);
  --green-bg: rgba(27, 209, 112, 0.15);
  --yellow-bg: rgba(251, 191, 36, 0.15);
  --blue-bg: rgba(0, 123, 255, 0.15);
  --purple-bg: rgba(167, 139, 250, 0.15);
  --red-bg: rgba(255, 77, 77, 0.15);

  /* Borders */
  --border: rgba(248, 251, 255, 0.08);
  --border-light: rgba(248, 251, 255, 0.12);
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;

  /* Buttons */
  --btn-bg: rgba(248, 251, 255, 0.06);
  --btn-text: var(--text-primary);
  --btn-border: rgba(248, 251, 255, 0.12);
  --btn-bg-hover: rgba(248, 251, 255, 0.10);
  --btn-border-hover: rgba(248, 251, 255, 0.20);

  /* Primary (call-to-action) button + focus ring + card elevation */
  --btn-primary-bg: #0069d9;
  --btn-primary-fg: #ffffff;
  --btn-primary-bg-hover: #005bbd;
  --focus-ring: rgba(0, 123, 255, 0.45);
  --shadow-card: none;

  /* Typography */
  --font-primary: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-weight-normal: 300;
  --font-weight-medium: 400;
  --font-weight-bold: 500;
  --font-brand: 'Arial Black', 'Segoe UI', sans-serif;
  --font-mono: 'DejaVu Sans Mono', 'Liberation Mono', 'Courier New', monospace;
}

/* ── Light Theme ──────────────────────────────────────────────── */

[data-theme="light"] {
  --bg-page: #f5f6f8;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;

  --text-primary: #15181d;
  --text-muted: #5b6573;
  --text-helper: #3d4654;

  /* Enterprise: the accent (active nav, tabs, links, borders) is near-black, not blue */
  --primary: #15181d;
  --primary-hover: #2c313a;

  --green: #08783d;
  --red: #b91c1c;
  --yellow: #d97706;
  --orange: #c2410c;
  --purple: #7c3aed;

  --green-bg: rgba(13, 158, 85, 0.1);
  --yellow-bg: rgba(217, 119, 6, 0.1);
  --blue-bg: rgba(21, 24, 29, 0.07);          /* neutralised: active nav/pills read grey, not blue */
  --purple-bg: rgba(124, 58, 237, 0.08);
  --red-bg: rgba(220, 38, 38, 0.1);

  --border: rgba(15, 23, 36, 0.1);
  --border-light: rgba(15, 23, 36, 0.15);

  /* Enterprise light controls: white secondary buttons with a clear border */
  --btn-bg: #ffffff;
  --btn-text: var(--text-primary);
  --btn-border: rgba(21, 24, 29, 0.16);
  --btn-bg-hover: #f1f3f6;
  --btn-border-hover: rgba(21, 24, 29, 0.32);

  /* Black-ish primary CTA + neutral focus ring + soft card elevation */
  --btn-primary-bg: #15181d;
  --btn-primary-fg: #ffffff;
  --btn-primary-bg-hover: #2c313a;
  --focus-ring: rgba(21, 24, 29, 0.28);
  --shadow-card: 0 1px 2px rgba(15, 23, 36, 0.04), 0 1px 3px rgba(15, 23, 36, 0.06);
}

[data-theme="light"] .logo-acdc {
  filter: none;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App Shell ────────────────────────────────────────────────── */

#app {
  min-height: 100vh;
}

.main-column {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.content {
  flex: 1;
  padding: 20px 24px 32px;
  overflow-y: auto;
}

/* ── Top Bar ──────────────────────────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.logo-guardian {
  height: 32px;
  width: auto;
  /* Dark mode: invert black→white, then rotate hue to restore red from cyan */
  filter: invert(1) hue-rotate(180deg) saturate(2.5) brightness(1.1);
}

[data-theme="light"] .logo-guardian {
  filter: none;
}

.topbar-logo-sep {
  width: 1px;
  height: 28px;
  background: var(--border-light);
}

.logo-acdc {
  height: 44px;
  width: auto;
  opacity: 1;
  filter: invert(1) hue-rotate(180deg) saturate(1.1) brightness(1.1);
  max-width: 190px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  justify-content: flex-end;
  flex-shrink: 1;
}

#user-chip {
  max-width: min(44vw, 360px);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── Timer Strip ──────────────────────────────────────────────── */

.timer-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.timer-strip .timer {
  font-size: 18px;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  font-family: var(--font-primary);
  letter-spacing: 0.04em;
}

.timer-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
}

.timer-strip .timer {
  margin-left: auto;
}

/* ── Status Indicator ─────────────────────────────────────────── */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-indicator::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-indicator.running {
  background: var(--green-bg);
  color: var(--green);
}
.status-indicator.running::before { background: var(--green); box-shadow: 0 0 6px var(--green); }

.status-indicator.paused {
  background: var(--yellow-bg);
  color: var(--yellow);
}
.status-indicator.paused::before { background: var(--yellow); }

.status-indicator.offline, .status-indicator.disconnected {
  background: var(--red-bg);
  color: var(--red);
}
.status-indicator.offline::before, .status-indicator.disconnected::before { background: var(--red); }

/* ── Buttons ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn:hover {
  background: var(--btn-bg-hover);
  border-color: var(--btn-border-hover);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn:disabled, .btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  font-size: 11px;
  padding: 3px 8px;
}

.btn-primary, .btn-green {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: var(--btn-primary-bg);
}
.btn-primary:hover, .btn-green:hover {
  background: var(--btn-primary-bg-hover);
  border-color: var(--btn-primary-bg-hover);
}

.btn-secondary, .btn-yellow {
  background: var(--bg-page);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-blue {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: var(--btn-primary-bg);
}
.btn-blue:hover { background: var(--btn-primary-bg-hover); border-color: var(--btn-primary-bg-hover); }

.btn-red {
  background: rgba(255, 77, 77, 0.12);
  color: var(--red);
  border-color: rgba(255, 77, 77, 0.25);
}

.btn-small {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-small.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-accent {
  background: rgba(167, 139, 250, 0.15);
  color: var(--purple);
  border-color: rgba(167, 139, 250, 0.3);
}
.btn-accent:hover { background: rgba(167, 139, 250, 0.25); }

.btn-success {
  background: rgba(27, 209, 112, 0.12);
  color: var(--green);
  border-color: rgba(27, 209, 112, 0.25);
}
.btn-success:hover { background: rgba(27, 209, 112, 0.20); }

.btn-danger {
  background: rgba(255, 77, 77, 0.12);
  color: var(--red);
  border-color: rgba(255, 77, 77, 0.25);
}
.btn-danger:hover { background: rgba(255, 77, 77, 0.20); }

/* ── Tabs ─────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: var(--font-weight-normal);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: var(--font-weight-medium);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Breadcrumbs ──────────────────────────────────────────────── */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
}

.breadcrumbs a, .breadcrumbs span {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumbs .bc-active {
  color: var(--text-primary);
  background: var(--bg-page);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
}

.breadcrumbs .bc-sep {
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Stats Bar (Dashboard Cards) ──────────────────────────────── */

.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.stat-card.big { padding: 20px; }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-weight: var(--font-weight-medium);
}

.stat-value {
  font-size: 28px;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  font-family: var(--font-primary);
  line-height: 1.1;
}

.stat-card.big .stat-value {
  font-size: 32px;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 300;
}

.stat-trend .trend-up {
  color: var(--green);
}

/* ── Table ────────────────────────────────────────────────────── */

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

thead th {
  background: rgba(248, 251, 255, 0.02);
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-medium);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th::after {
  content: ' \25B4\25BE';
  font-size: 8px;
  color: var(--text-muted);
  opacity: 0.4;
  margin-left: 3px;
}

thead th:first-child::after { content: ''; }

tbody td {
  padding: 10px 14px;
  font-size: 13px;
  border-top: 1px solid var(--border);
  color: var(--text-helper);
}

tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--btn-bg-hover);
}

tbody tr.first {
  background: rgba(27, 209, 112, 0.06);
}

tbody tr.first td:nth-child(2) {
  color: var(--green);
  font-weight: var(--font-weight-bold);
}

.team-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.team-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.team-dot.paused { background: var(--yellow); }
.team-dot.dead { background: var(--red); }
.team-dot.stopped { background: var(--text-muted); }
.team-dot.registered { background: var(--primary); }
.team-dot.finished { background: var(--purple); }

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.hidden { display: none; }

.pts {
  color: var(--green);
  font-weight: 700;
}

.tokens-val { color: var(--purple); }

.mono {
  font-family: var(--font-mono);
}

/* ── Team Select / Dropdowns ──────────────────────────────────── */

.team-select-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.team-select-bar label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: var(--font-weight-medium);
}

.team-select-bar select {
  background: var(--bg-page);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 32px 8px 12px;
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: var(--font-weight-normal);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca5b1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
  outline: none;
  min-width: 200px;
  max-width: 100%;
}

.team-select-bar select:focus {
  border-color: var(--primary);
}

.team-select-bar .tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  background: var(--green-bg);
  color: var(--green);
}

/* ── Team Stats Grid ──────────────────────────────────────────── */

.team-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 1200px) {
  .stats-bar, .team-stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Chart ────────────────────────────────────────────────────── */

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  position: relative;
  height: 320px;
}

/* ── Section Title ────────────────────────────────────────────── */

.section-title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: var(--font-weight-medium);
}

/* ── Timeline ─────────────────────────────────────────────────── */

.timeline-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.timeline-controls .btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.timeline {
  max-height: 520px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
}

.ev {
  display: grid;
  grid-template-columns: 72px 24px 110px 1fr;
  gap: 4px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: start;
}

.ev:last-child { border-bottom: none; }
.ev:hover { background: var(--btn-bg-hover); }

.ev-time {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.ev-icon {
  text-align: center;
  font-weight: var(--font-weight-bold);
  color: var(--text-muted);
}

.ev-type {
  font-weight: var(--font-weight-bold);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-data {
  color: var(--text-primary);
  word-break: break-all;
  line-height: 1.5;
}

.ev-type.cmd { color: var(--orange); }
.ev-type.http { color: var(--primary); }
.ev-type.llm { color: var(--purple); }
.ev-type.flag { color: var(--green); }
.ev-type.system { color: var(--red); }

.ev-cmd-output {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text-helper);
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--border-light);
}

.ev-prompt {
  background: rgba(100, 116, 139, 0.10);
  border-left: 3px solid var(--primary);
  color: var(--text-primary);
}

.ev-prompt .ev-block-label {
  color: var(--primary);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: block;
}

.ev-response {
  background: rgba(27, 209, 112, 0.06);
  border-left: 3px solid var(--green);
  color: var(--text-primary);
}

.ev-response .ev-block-label {
  color: var(--green);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: block;
}

.ev-stdout {
  background: rgba(245, 158, 11, 0.06);
  border-left: 3px solid var(--orange);
  color: var(--text-helper);
}

/* Light theme overrides for ev blocks */
[data-theme="light"] .ev-prompt { background: rgba(100, 116, 139, 0.10); }
[data-theme="light"] .ev-response { background: rgba(13, 158, 85, 0.08); }
[data-theme="light"] .ev-stdout { background: rgba(194, 65, 12, 0.06); }
[data-theme="light"] .ev-cmd-output { background: rgba(0, 0, 0, 0.04); }

/* ── LLM Conversation Viewer ──────────────────────────────────── */

.llm-conversation {
  max-height: 700px;
  overflow-y: auto;
}

.llm-turn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  overflow: hidden;
}

.llm-turn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(248, 251, 255, 0.02);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.llm-turn-header:hover {
  background: rgba(248, 251, 255, 0.04);
}

.llm-step {
  color: var(--purple);
  font-weight: 700;
  font-size: 14px;
}

.llm-meta {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

.llm-turn-body { padding: 16px; }
.llm-turn-body.collapsed { display: none; }

.llm-msg {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
}

.llm-msg.system {
  background: rgba(167, 139, 250, 0.06);
  border-left: 3px solid var(--purple);
  color: var(--text-muted);
  font-size: 12px;
}

.llm-msg.user {
  background: rgba(100, 116, 139, 0.10);
  border-left: 3px solid var(--primary);
}

.llm-msg.assistant {
  background: rgba(27, 209, 112, 0.06);
  border-left: 3px solid var(--green);
}

.llm-msg-role {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.llm-msg.system .llm-msg-role { color: var(--purple); }
.llm-msg.user .llm-msg-role { color: var(--primary); }
.llm-msg.assistant .llm-msg-role { color: var(--green); }

.llm-msg-content {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-helper);
}

.llm-completion {
  background: rgba(27, 209, 112, 0.05);
  border: 1px solid rgba(27, 209, 112, 0.15);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 8px;
}

.llm-completion-label {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.llm-completion-text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--green);
  font-weight: var(--font-weight-bold);
}

/* ── Challenges Grid ──────────────────────────────────────────── */

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

.challenge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}

.challenge-card:hover {
  border-color: var(--border-light);
}

.challenge-card h4 {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: var(--font-weight-bold);
  margin-bottom: 6px;
}

.challenge-card .challenge-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.challenge-card .challenge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.challenge-card .challenge-status.running {
  color: var(--green);
  background: var(--green-bg);
}

.challenge-card .challenge-status.not_running {
  color: var(--text-muted);
}

/* ── Admin Panel ──────────────────────────────────────────────── */

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-column {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.admin-column-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: var(--font-weight-bold);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.admin-section {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.admin-section-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-bold);
  margin-bottom: 10px;
}

.admin-input { width: 100%; }   /* form fields fill their container; toolbar controls keep natural width */

.admin-input,
select:not([multiple]),
input[type="text"], input[type="number"], input[type="search"],
input[type="email"], input[type="password"], input[type="datetime-local"] {
  padding: 7px 11px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-primary);
  transition: border-color .15s, box-shadow .15s;
}

.admin-input:focus,
select:focus, input[type="text"]:focus, input[type="number"]:focus,
input[type="search"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.admin-input::placeholder, input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

select, select.admin-input {
  cursor: pointer;
}

.admin-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.admin-status {
  font-size: 12px;
  margin-top: 6px;
  min-height: 1.2em;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  border-radius: 10px;
  background: var(--bg-page);
  color: var(--text-primary);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.admin-actions .btn:hover {
  background: var(--btn-bg-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.admin-actions .btn svg {
  width: 16px;
  height: 16px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(248, 251, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-dot.ok {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.health-dot.down {
  background: var(--red);
}

.health-tag {
  margin-left: auto;
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  padding: 3px 8px;
  border-radius: 4px;
}

/* ── Badge ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  background: var(--primary);
  color: #ffffff;
  font-family: var(--font-mono);
}

/* ── Scrollbar ────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(248, 251, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(248, 251, 255, 0.2); }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .stats-bar, .team-stats-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar-brand-sub { display: none; }
}

@media (max-width: 768px) {
  .stats-bar, .team-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 10px 16px; gap: 8px; }
  .tabs { padding: 0 16px; overflow-x: auto; }
  .breadcrumbs { padding: 10px 16px; }
  .content { padding: 16px; }
  .topbar-logo { gap: 8px; }
  .logo-acdc { height: 38px; max-width: 154px; }
  #user-chip { max-width: 34vw; }
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .page-head > div:last-child {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-head > div:last-child .admin-input,
  .page-head > div:last-child input,
  .page-head > div:last-child select {
    width: 100% !important;
    max-width: 100%;
  }
  .team-select-bar {
    align-items: stretch;
    padding: 12px;
    gap: 8px;
  }
  .team-select-bar label {
    flex: 1 1 100%;
    margin-bottom: -4px;
  }
  .team-select-bar select,
  .team-select-bar .admin-input {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  .team-select-bar .spacer { display: none; }
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
    box-shadow: inset -18px 0 16px -18px rgba(15, 23, 36, 0.4);
  }
}

@media (max-width: 520px) {
  .topbar { padding: 8px 10px; }
  .nav-burger { margin-right: 6px; }
  .logo-acdc { height: 34px; max-width: 136px; }
  .topbar-right { gap: 7px; flex: none; }
  #user-chip { display: none !important; }
  .theme-toggle { width: 32px; height: 32px; }
}

/* ── Theme Toggle ─────────────────────────────────────────────── */

.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }

[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root .theme-toggle .icon-sun { display: block; }
:root .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Clickable Cards ──────────────────────────────────────────── */

.challenge-card.clickable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.challenge-card.clickable:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* ── Timeline Search ──────────────────────────────────────────── */

.timeline-search {
  margin-bottom: 10px;
}

.timeline-search .search-input {
  width: 100%;
  max-width: 400px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 13px;
  outline: none;
}

.timeline-search .search-input:focus {
  border-color: var(--primary);
}

/* ── Projector Mode ───────────────────────────────────────────── */

.projector-mode .topbar { padding: 8px 24px; }
.projector-mode .timer-strip { padding: 8px 24px; }

.projector-mode .stat-value { font-size: 36px; }
.projector-mode .stat-label { font-size: 14px; }

.projector-mode table { font-size: 15px; }
.projector-mode thead th { font-size: 13px; padding: 14px 16px; }
.projector-mode tbody td { font-size: 15px; padding: 12px 16px; }

.projector-mode .chart-container { height: 400px; }

.projector-mode .content { padding: 16px 24px; }

/* ── Utilities ────────────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  font-size: 12px;
}
