/* ═══════════════════════════════════════════
   BUG MARATHON WEEK — DASHBOARD STYLES
   Dark esports scoreboard theme
   ═══════════════════════════════════════════ */

[hidden] { display: none !important; }

/* ─── TOKENS ─── */
:root {
  --bg:          #0a0e17;
  --bg-card:     #111827;
  --bg-card-alt: #0f1629;
  --border:      #1e293b;
  --border-glow: #1e3a5f;

  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;

  --cyan:        #00f0ff;
  --cyan-dim:    rgba(0, 240, 255, .15);
  --green:       #10b981;
  --green-dim:   rgba(16, 185, 129, .15);
  --red:         #ef4444;
  --red-dim:     rgba(239, 68, 68, .15);
  --amber:       #f59e0b;
  --amber-dim:   rgba(245, 158, 11, .15);
  --purple:      #a78bfa;
  --purple-dim:  rgba(167, 139, 250, .15);

  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, monospace;
  --radius:      8px;
  --radius-sm:   4px;
  --transition:  .3s ease;
}

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

html {
  font-size: clamp(13px, 1.1vw, 16px);
  scroll-behavior: smooth;
}

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

/* ─── HEADER ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0,240,255,.04) 0%, transparent 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-icon {
  width: 32px;
  height: 32px;
  color: var(--cyan);
  flex-shrink: 0;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--cyan), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-sub {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-live {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--red-dim);
  padding: .25rem .65rem;
  border-radius: 999px;
  border: 1px solid rgba(239,68,68,.3);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

.live-text {
  font-size: .7rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: .08em;
}

.header-time {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-muted);
}

/* ─── CONTROLS BAR ─── */
.controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1rem 2rem;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}

.controls-left {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.control-group label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 600;
  padding: .45rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--cyan);
  color: var(--text);
}

.btn.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-accent {
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-accent:hover {
  background: var(--cyan-dim);
}

.btn-group {
  display: flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn + .btn      { border-left: 0; }

/* Select */
.select {
  font-family: var(--font);
  font-size: .8rem;
  padding: .45rem .7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  padding-right: 1.8rem;
}

.select:focus {
  outline: none;
  border-color: var(--cyan);
}

/* ─── SECTIONS ─── */
.section {
  padding: 1.5rem 2rem;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.section-title svg {
  color: var(--cyan);
}

/* ─── LEADERBOARD TABLE ─── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.leaderboard thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.leaderboard th {
  padding: .65rem .75rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  background: var(--bg-card-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.leaderboard td {
  padding: .6rem .75rem;
  border-bottom: 1px solid rgba(30,41,59,.5);
  white-space: nowrap;
  vertical-align: middle;
}

.leaderboard tbody tr {
  background: var(--bg-card);
  transition: transform .5s ease, opacity .3s ease, background .2s ease;
}

.leaderboard tbody tr:hover {
  background: rgba(0,240,255,.03);
}

/* Rank #1 row glow */
.leaderboard tbody tr.rank-1 {
  background: linear-gradient(90deg, rgba(0,240,255,.06) 0%, var(--bg-card) 60%);
}

.leaderboard tbody tr.rank-1 td:first-child {
  border-left: 3px solid var(--cyan);
}

/* Column widths */
.col-rank   { width: 50px; text-align: center; }
.col-name   { min-width: 160px; }
.col-team   { min-width: 80px; }
.col-pts    { min-width: 80px; text-align: right; }
.col-delta  { min-width: 65px; text-align: right; }
.col-today  { min-width: 55px; text-align: center; }
.col-total  { min-width: 55px; text-align: center; }
.col-cfr    { min-width: 100px; }
.col-pr     { min-width: 65px; text-align: center; }
.col-badges { min-width: 130px; }

/* Rank cell */
.rank-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
}

.rank-crown {
  font-size: 1.1rem;
  animation: pulse-glow 2s infinite;
}

.rank-fire {
  font-size: .95rem;
  animation: flicker 1s infinite;
}

/* Dev name cell */
.dev-name {
  font-weight: 600;
}

.dev-team {
  font-size: .7rem;
  color: var(--text-dim);
}

/* Points */
.pts-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--cyan);
}

/* Delta */
.delta-positive {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--green);
}

.delta-negative {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--red);
}

.delta-neutral {
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.rank-drop-indicator {
  color: var(--red);
  font-size: .75rem;
  margin-left: .2rem;
}

/* Clean Fix Rate mini-bar */
.cfr-bar-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.cfr-bar {
  width: 60px;
  height: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 3px;
  overflow: hidden;
}

.cfr-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s ease;
}

.cfr-bar-fill.high   { background: var(--green); }
.cfr-bar-fill.mid    { background: var(--amber); }
.cfr-bar-fill.low    { background: var(--red);   }

.cfr-pct {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-muted);
  min-width: 32px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  font-size: .65rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 999px;
  letter-spacing: .02em;
}

.badge + .badge { margin-left: .3rem; }

.badge-clean {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16,185,129,.3);
}

.badge-qa-blocked {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.3);
}

.badge-reopen {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245,158,11,.3);
}

/* ─── QUALITY SHIELD ─── */
.warning-banner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  background: var(--amber-dim);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: var(--radius);
  color: var(--amber);
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.warning-banner.hidden { display: none; }

/* ─── STATS GRID ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color var(--transition);
}

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

.card-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: .35rem;
}

.card-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
}

.card-value--sm {
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-muted);
  min-height: 2.5rem;
}

.card-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* Card accent colors */
.card--cyan   .card-value { color: var(--cyan);   }
.card--green  .card-value { color: var(--green);  }
.card--red    .card-value { color: var(--red);    }
.card--amber  .card-value { color: var(--amber);  }
.card--purple .card-value { color: var(--purple); }

/* ─── IMPACT SECTION ─── */
.impact-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: .75rem;
}

.stats-grid--impact {
  grid-template-columns: 1fr 1fr;
}

.spotlight-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.card-spotlight {
  border-color: var(--border-glow);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0,240,255,.03) 100%);
}

.card-spotlight .card-value {
  color: var(--cyan);
}

.card-spotlight .card-value[contenteditable="true"] {
  cursor: text;
  outline: none;
  color: var(--text-muted);
}

.card-spotlight .card-value[contenteditable="true"]:focus {
  color: var(--text);
  background: rgba(0,240,255,.04);
  border-radius: var(--radius-sm);
  padding: .25rem;
  margin: -.25rem;
}

/* ─── CHARTS ─── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.card-chart {
  padding: 1.25rem;
}

.card-chart-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.card-chart canvas {
  width: 100% !important;
}

#trendChart {
  max-height: 280px;
}

/* ─── FOOTER ─── */
.footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .75rem;
  color: var(--text-dim);
}

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  padding: .6rem 1.25rem;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  opacity: 0;
  transition: all .3s ease;
  z-index: 999;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden { display: block; opacity: 0; }

/* ─── ANIMATIONS ─── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(0,240,255,.4)); }
  50%      { filter: drop-shadow(0 0 8px rgba(0,240,255,.8)); }
}

@keyframes flicker {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .7; transform: scale(1.1); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn .4s ease forwards;
}

/* Row rank-change animation */
.row-up {
  animation: slideUp .5s ease;
}

.row-down {
  animation: slideDown .5s ease;
}

@keyframes slideUp {
  from { transform: translateY(10px); opacity: .7; }
  to   { transform: translateY(0);   opacity: 1;  }
}

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: .7; }
  to   { transform: translateY(0);     opacity: 1;  }
}

/* ─── RESPONSIVE ─── */

/* TV / large screens */
@media (min-width: 1600px) {
  html { font-size: 18px; }
}

/* Tablet */
@media (max-width: 1024px) {
  .impact-top-row {
    grid-template-columns: 1fr;
  }

  .spotlight-cards {
    grid-template-columns: 1fr 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile */
@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
    padding: 1rem 1rem;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
  }

  .controls-left {
    flex-direction: column;
    gap: .75rem;
  }

  .controls-right {
    width: 100%;
  }

  .controls-right .btn {
    width: 100%;
    justify-content: center;
  }

  .section {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .impact-top-row {
    grid-template-columns: 1fr;
  }

  .spotlight-cards {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .header-title {
    font-size: 1.2rem;
  }
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ─── ESTIMATE PILLS ─── */
.col-estimates { white-space: nowrap; }
.est-pills {
  display: inline-flex;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: .7rem;
}
.est-pill {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 600;
  line-height: 1.2;
}
.est-pill.est-zero { opacity: .25; }
.est-xs  { background: rgba(99,102,241,.15); color: #818cf8; }
.est-s   { background: rgba(56,189,248,.15); color: #38bdf8; }
.est-m   { background: rgba(52,211,153,.15); color: #34d399; }
.est-l   { background: rgba(251,191,36,.15); color: #fbbf24; }
.est-xl  { background: rgba(239,68,68,.15);  color: #ef4444; }

/* ─── GUIDELINES BUTTON ─── */
.btn-guidelines {
  background: rgba(99, 102, 241, .15);
  color: var(--purple);
  border: 1px solid rgba(99, 102, 241, .3);
  cursor: pointer;
  margin-left: 12px;
  font-size: .8rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background .2s;
}
.btn-guidelines:hover {
  background: rgba(99, 102, 241, .3);
}

/* ─── MODAL ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(480px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 1.15rem;
  color: var(--text);
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text);
}
.modal-body {
  padding: 16px 24px 24px;
}
.guideline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.guideline-item:last-child {
  border-bottom: none;
}
.guideline-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.guideline-item strong {
  color: var(--text);
  font-size: .9rem;
}
.guideline-item p {
  color: var(--text-dim);
  font-size: .82rem;
  margin: 4px 0 0;
  line-height: 1.5;
}
