/* HunterCore admin panel. Matches the design canvas: dark top bar and sidebar,
   light content, white report cards. Section colours: Dashboard gold, Teams blue,
   Routing green, Challenge Development red. */

:root {
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --text: #1F2328;
  --heading: #111418;
  --muted: #5B6470;
  --border: #D8DDE3;
  --line: #E6E9ED;
  --line-soft: #F0F2F5;
  --dark: #0E1117;
  --dark-line: #1F2530;
  --side-text: #C9CFD8;
  --side-head: #8A93A3;

  --gold: #E8AE2E;
  --tint-teams: #64B5F6;
  --tint-routing: #81C784;
  --tint-dev: #E57373;

  --blue: #1976D2;
  --green: #2E7D32;
  --red: #D32F2F;
  --link: #1F5FBF;
  --chart: #1D4FA8;
  --pie-in: #2F6FDB;
  --pie-out: #F2A93B;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: 'Space Grotesk', Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); }
h1, h2, h3 { color: var(--heading); margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px;
  min-height: 56px; padding: 0 clamp(16px, 2.5vw, 32px);
  background: var(--dark); color: #E8EAED;
}
.brand { display: flex; align-items: center; gap: 10px; color: #FFFFFF; font: 700 17px var(--display); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: var(--gold); display: grid; place-items: center; }
.topbar-spacer { flex: 1; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; }
.status-live { background: #10302E; color: #6FE3D7; }
.status-off { background: var(--dark-line); color: var(--side-text); }
.logout { background: none; border: 0; color: var(--side-text); font: inherit; cursor: pointer; min-height: 44px; padding: 0 8px; }
.logout:hover { color: #FFFFFF; }

/* ---------------------------------------------------------------- sidebar + content */
.shell { display: flex; flex-wrap: wrap; align-items: stretch; min-height: calc(100vh - 56px); }
.sidebar {
  flex: 1 1 220px; display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px; background: var(--dark); border-top: 1px solid var(--dark-line);
}
.side-head { padding: 18px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-head); }
.side-item {
  display: flex; align-items: center; gap: 10px; min-height: 24px; padding: 10px 12px;
  border-radius: 6px; color: var(--side-text);
}
.side-item:hover { text-decoration: none; color: #FFFFFF; }
.side-item svg { flex-shrink: 0; }
/* the coloured bar: pale when not selected, full colour when selected */
.side-item .bar { width: 3px; height: 18px; border-radius: 2px; background: var(--tint); opacity: .4; }
.side-item.active { background: var(--dark-line); color: #FFFFFF; font-weight: 600; }
.side-item.active .bar { opacity: 1; }
.tint-dash { --tint: var(--gold); }
.tint-teams { --tint: var(--tint-teams); }
.tint-routing { --tint: var(--tint-routing); }
.tint-dev { --tint: var(--tint-dev); }

.content { flex: 999 1 560px; min-width: 0; }

/* ---------------------------------------------------------------- page header */
.page-header { background: var(--card); border-bottom: 1px solid var(--border); }
.page-header-inner {
  max-width: 1400px; margin: 0 auto; padding: 18px clamp(16px, 2.5vw, 32px);
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.crumb { font-size: 13px; color: var(--muted); }
.page-title { font: 600 26px var(--display); letter-spacing: -.01em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page { max-width: 1400px; margin: 0 auto; padding: 20px clamp(16px, 2.5vw, 32px) 56px; display: flex; flex-direction: column; gap: 16px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { border: 0; color: #FFFFFF; font-weight: 600; background: var(--accent, var(--heading)); }
.btn-gold { border: 0; background: var(--gold); color: #1A1205; font-weight: 600; }
.btn-danger { border-color: #F5C2C2; background: #FDECEC; color: #B71C1C; }
.btn-dashed { border: 1px dashed var(--accent); background: transparent; color: var(--accent); font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line-soft); }
.accent-teams { --accent: var(--blue); }
.accent-routing { --accent: var(--green); }
.accent-dev { --accent: var(--red); }

/* ---------------------------------------------------------------- flash messages */
.flash { padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.flash-ok { background: #E8F5E9; border: 1px solid #A5D6A7; color: #1B5E20; }
.flash-warn { background: #FFF8E1; border: 1px solid #F3D27A; color: #5C4300; }

/* ---------------------------------------------------------------- cards and tables */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); }
.scroll-x { overflow-x: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; }
.table th {
  padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); background: #F7F8FA; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table td.tight { padding: 4px 8px; white-space: nowrap; width: 1%; }
.strong { font-weight: 600; color: var(--heading); }
.mono { font-family: var(--mono); font-size: 13px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 0; font-family: inherit; cursor: pointer; }
.pill-in { background: #E3F2FD; color: #0D47A1; }
.pill-out { background: var(--line-soft); color: #4A525D; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; background: var(--line-soft); color: #3A424D; font: 12.5px var(--mono); }
.stops { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stop { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: #E8F5E9; color: #1B5E20; font-size: 13px; font-weight: 500; }
.stop-n { width: 20px; height: 20px; border-radius: 10px; background: var(--green); color: #FFFFFF; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.stop-arrow { color: #8A93A3; }

/* ---------------------------------------------------------------- dashboard reports */
.report-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.report-total { flex: 1 1 280px; display: flex; flex-direction: column; }
.report-pie { flex: 2 1 480px; display: flex; flex-direction: column; }
.big-number { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 28px 16px; }
.big-number strong { font: 600 88px/1 var(--display); letter-spacing: -.03em; color: var(--link); }
.big-number span { color: var(--muted); }
.pie-body { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 32px 48px; padding: 24px; }
.pie { width: 220px; height: 220px; border-radius: 50%; flex-shrink: 0; }
.legend { display: flex; flex-direction: column; gap: 18px; min-width: 220px; }
.legend-item { display: flex; gap: 12px; align-items: flex-start; }
.swatch { width: 14px; height: 14px; border-radius: 3px; margin-top: 4px; flex-shrink: 0; }
.legend-value { font-size: 13px; color: var(--muted); }
.legend-value strong { font: 600 22px var(--display); color: var(--heading); }

.progress-list { list-style: none; margin: 0; padding: 8px 16px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); column-gap: 40px; }
.progress-row { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--line-soft); }
.progress-rank { width: 22px; flex-shrink: 0; text-align: right; font-size: 12px; font-weight: 600; color: var(--muted); }
.progress-team { flex: 0 1 140px; min-width: 0; font-weight: 500; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-count { width: 56px; flex-shrink: 0; text-align: right; font: 13px var(--mono); }
.track-wrap { flex: 1; min-width: 0; position: relative; height: 22px; display: flex; align-items: center; }
.track { width: 100%; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.fill { height: 100%; border-radius: 3px; background: var(--pie-in); }
.fill.complete { background: var(--gold); }
/* one thin line per solved riddle; its tooltip is drawn with CSS only */
.mark {
  position: absolute; top: 0; width: 14px; height: 22px; margin-left: -7px; padding: 0;
  border: 0; background: transparent; cursor: pointer; display: flex; justify-content: center;
}
.mark::before { content: ""; width: 2px; height: 22px; border-radius: 1px; background: #0B3A82; }
.mark::after {
  content: attr(data-riddle) "\A" "Solved " attr(data-time);
  white-space: pre; display: none; position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 5;
  padding: 8px 10px; border-radius: 6px; background: var(--heading); color: #FFFFFF; font-size: 12px; line-height: 1.4;
  box-shadow: 0 4px 14px rgba(17, 20, 24, .25); pointer-events: none;
}
.mark:hover::before, .mark:focus-visible::before { background: var(--heading); }
.mark:hover::after, .mark:focus-visible::after { display: block; }

.trend { padding: 16px 20px 14px; display: flex; flex-direction: column; gap: 14px; }
.trend-chart { position: relative; height: 150px; }
.trend-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.trend-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-up { background: #E8F5E9; color: #1B5E20; }
.badge-down { background: #FFF3E0; color: #8A4B00; }
.badge-steady { background: var(--line-soft); color: #3A424D; }

/* ---------------------------------------------------------------- dialogs */
.scrim {
  position: fixed; inset: 0; z-index: 20; display: flex; justify-content: center; align-items: flex-start;
  padding: 72px 16px 32px; background: rgba(14, 17, 23, .55); overflow-y: auto;
}
.dialog { width: 100%; max-width: 640px; background: var(--card); border-radius: 10px; box-shadow: 0 24px 60px rgba(14, 17, 23, .35); display: flex; flex-direction: column; overflow: hidden; }
.dialog-wide { max-width: 860px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 14px 24px; border-bottom: 1px solid var(--line); }
.dialog-title { font: 600 20px var(--display); }
.dialog-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: #F7F8FA; }
.dialog-foot .left { margin-right: auto; }
.error { padding: 10px 14px; border-radius: 6px; background: #FDECEC; border: 1px solid #F5C2C2; color: #8E1515; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: #3A424D; }
.field-error { margin: 0; font-size: 12px; color: #B3261E; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 6px; border: 1px solid #C4CBD4;
  background: #FFFFFF; color: var(--text); font: inherit;
}
.textarea { height: auto; min-height: 120px; padding: 10px 12px; font-family: var(--mono); font-size: 13px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.fieldset { margin: 0; padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fieldset legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- slush bucket */
.bucket { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; }
.bucket-list { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bucket-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.bucket-label.chosen { color: var(--green); }
.bucket select { height: 280px; width: 100%; padding: 4px; border: 1px solid #C4CBD4; border-radius: 6px; font: inherit; }
.bucket select.chosen { border-color: #A5D6A7; }
.bucket select option { padding: 8px 10px; border-radius: 4px; }
.bucket select option:checked { background: #C8E6C9; color: #0F3D14; }
.bucket-buttons { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.bucket-buttons .btn { min-width: 44px; padding: 0 10px; }

/* ---------------------------------------------------------------- challenges */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.ch-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; border-radius: 8px; }
.ch-card h2 { font-size: 16px; font-weight: 600; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.ch-meta span { display: inline-flex; align-items: center; gap: 5px; }
.ch-open { min-height: 40px; border-radius: 6px; border: 1px solid #F5C2C2; background: #FDECEC; color: #B71C1C; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.ch-open:hover { text-decoration: none; filter: brightness(.98); }
.preview { padding: 14px 16px; border-radius: 8px; background: #F7F8FA; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #3A424D; }
.preview span { display: flex; align-items: center; gap: 8px; }
.preview code { color: var(--heading); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); border-bottom: 3px solid transparent; }
.tab:hover { text-decoration: none; color: var(--heading); }
.tab.active { color: var(--heading); font-weight: 600; border-bottom-color: var(--red); }
.page-header-inner.with-tabs { padding-bottom: 0; flex-direction: column; align-items: stretch; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--muted); }

.workbench { padding: 16px; display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.files { flex: 1 1 220px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; }
.file-list { display: flex; flex-direction: column; gap: 2px; }
.file {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: 6px;
  color: #3A424D; font: 13px var(--mono);
}
.file:hover { text-decoration: none; background: var(--line-soft); }
.file.active { background: #FDECEC; color: #8E1515; font-weight: 600; }
.editor-side { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.editor-bar .grow { flex: 1 1 220px; }
.editor { height: 520px; border-radius: 6px; overflow: hidden; background: #1E1E1E; }
/* shown until Monaco has loaded, and if it can't load (no internet) */
.editor-fallback { width: 100%; height: 520px; border: 0; border-radius: 6px; padding: 12px 16px; background: #1E1E1E; color: #D4D4D4; font: 13px/1.7 var(--mono); resize: vertical; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 6px; background: #FFF8E1; border: 1px solid #F3D27A; color: #5C4300; font-size: 13px; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--dark); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 10px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
