/* ==========================================================================
   WAOW Connect — Jury Scores Dashboard
   Design: charcoal gallery surface + warm gold spotlight accent
   Display font: Cabinet Grotesk | Body/data font: Satoshi
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: 20 10% 8%;
  --bg-elev-1: 20 9% 11%;
  --bg-elev-2: 20 8% 14%;
  --bg-elev-3: 22 8% 18%;
  --border: 22 8% 22%;
  --border-soft: 22 8% 17%;

  /* Text */
  --text-primary: 30 20% 96%;
  --text-secondary: 24 8% 68%;
  --text-tertiary: 24 6% 48%;

  /* Accent — warm gallery gold */
  --accent: 38 92% 58%;
  --accent-strong: 38 96% 66%;
  --accent-soft: 38 60% 20%;
  --accent-text: 30 40% 10%;

  /* Semantic score heat scale (low -> high, 1-7) */
  --heat-1: 6 70% 45%;
  --heat-2: 18 75% 48%;
  --heat-3: 32 80% 50%;
  --heat-4: 45 65% 48%;
  --heat-5: 70 45% 45%;
  --heat-6: 95 40% 42%;
  --heat-7: 142 45% 40%;

  --success: 142 45% 45%;
  --danger: 4 72% 55%;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-display: 'Cabinet Grotesk', 'General Sans', sans-serif;
  --font-body: 'Satoshi', 'Inter', sans-serif;

  --shadow-1: 0 1px 2px hsl(0 0% 0% / 0.4);
  --shadow-2: 0 8px 24px -8px hsl(0 0% 0% / 0.5);
  --shadow-glow: 0 0 0 1px hsl(var(--accent) / 0.25), 0 8px 28px -10px hsl(var(--accent) / 0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: hsl(var(--bg));
  color: hsl(var(--text-primary));
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, hsl(var(--accent) / 0.08), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 0%, hsl(38 60% 30% / 0.06), transparent 55%);
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }

button { font-family: inherit; cursor: pointer; }

.tabular { font-variant-numeric: tabular-nums lining-nums; }

::selection { background: hsl(var(--accent) / 0.3); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: hsl(var(--border)) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   Login screen
   ========================================================================== */

.login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: hsl(var(--bg-elev-1));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-2);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand h1 {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
}

.login-brand span {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  color: hsl(var(--text-tertiary));
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: hsl(var(--text-secondary));
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field input {
  width: 100%;
  background: hsl(var(--bg-elev-2));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: hsl(var(--text-primary));
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: hsl(var(--accent));
  box-shadow: 0 0 0 3px hsl(var(--accent) / 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: hsl(var(--accent));
  color: hsl(var(--accent-text));
  width: 100%;
  padding: 11px 16px;
  font-size: 14px;
  margin-top: 6px;
}
.btn-primary:hover:not(:disabled) { background: hsl(var(--accent-strong)); }

.btn-ghost {
  background: transparent;
  color: hsl(var(--text-secondary));
  border: 1px solid hsl(var(--border));
}
.btn-ghost:hover { color: hsl(var(--text-primary)); border-color: hsl(var(--text-tertiary)); }

.btn-icon {
  background: hsl(var(--bg-elev-2));
  color: hsl(var(--text-secondary));
  border: 1px solid hsl(var(--border));
  padding: 8px 10px;
}
.btn-icon:hover { color: hsl(var(--text-primary)); }

.form-error {
  background: hsl(var(--danger) / 0.12);
  border: 1px solid hsl(var(--danger) / 0.3);
  color: hsl(4 85% 78%);
  font-size: 13px;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 14px;
  line-height: 1.4;
}

.login-foot {
  margin-top: 18px;
  font-size: 12px;
  color: hsl(var(--text-tertiary));
  text-align: center;
  line-height: 1.5;
}

/* ==========================================================================
   Dashboard shell
   ========================================================================== */

.dashboard {
  display: none;
  height: 100dvh;
  grid-template-rows: auto 1fr;
}
.dashboard.active { display: grid; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid hsl(var(--border-soft));
  background: hsl(var(--bg-elev-1) / 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand h1 { font-size: 16px; font-weight: 700; }
.topbar-brand .subtitle { font-size: 11px; color: hsl(var(--text-tertiary)); font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: hsl(var(--text-secondary));
  background: hsl(var(--bg-elev-2));
  border: 1px solid hsl(var(--border-soft));
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
}

.avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: hsl(var(--accent) / 0.25);
  color: hsl(var(--accent-strong));
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.main {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 40px;
}

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: hsl(var(--bg-elev-1));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.kpi-label {
  font-size: 11px;
  color: hsl(var(--text-tertiary));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.kpi-sub {
  font-size: 11px;
  color: hsl(var(--text-tertiary));
  margin-top: 3px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: hsl(var(--text-tertiary)); pointer-events: none;
}
.search-wrap input {
  width: 100%;
  background: hsl(var(--bg-elev-1));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  color: hsl(var(--text-primary));
}
.search-wrap input:focus { outline: none; border-color: hsl(var(--accent)); }

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: hsl(var(--text-secondary));
  background: hsl(var(--bg-elev-1));
  border: 1px solid hsl(var(--border-soft));
  padding: 7px 12px;
  border-radius: 999px;
}

.switch {
  width: 30px; height: 17px;
  border-radius: 999px;
  background: hsl(var(--border));
  position: relative;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  width: 13px; height: 13px;
  background: hsl(30 20% 92%);
  border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  transition: transform 0.15s ease;
}
.switch.on { background: hsl(var(--accent)); }
.switch.on::after { transform: translateX(13px); }

.spacer { flex: 1; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: hsl(var(--bg-elev-2));
  color: hsl(var(--text-secondary));
  border: 1px solid hsl(var(--border-soft));
}

.updated-text {
  font-size: 11px;
  color: hsl(var(--text-tertiary));
}

/* Table */
.table-card {
  background: hsl(var(--bg-elev-1));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  overscroll-behavior: contain;
}

table.scores {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}

table.scores thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: hsl(var(--bg-elev-2));
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: hsl(var(--text-tertiary));
  padding: 10px 14px;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.scores thead th.sortable:hover { color: hsl(var(--text-primary)); }
table.scores thead th .sort-caret { margin-left: 4px; opacity: 0.6; font-size: 10px; }
table.scores thead th.rank-col,
table.scores tbody td.rank-col { text-align: center; width: 44px; }
table.scores thead th.applicant-col { position: sticky; left: 0; z-index: 3; }
table.scores tbody td.applicant-col {
  position: sticky;
  left: 0;
  background: hsl(var(--bg-elev-1));
  z-index: 1;
  font-weight: 600;
  color: hsl(var(--text-primary));
}

table.scores tbody tr { border-bottom: 1px solid hsl(var(--border-soft)); }
table.scores tbody tr:hover td { background: hsl(var(--bg-elev-2)); }
table.scores tbody tr:hover td.applicant-col { background: hsl(var(--bg-elev-2)); }
table.scores tbody tr:last-child { border-bottom: none; }

table.scores td {
  padding: 10px 14px;
  font-size: 13px;
  color: hsl(var(--text-secondary));
  white-space: nowrap;
}

.applicant-name { display: block; }
.applicant-meta { font-size: 11px; color: hsl(var(--text-tertiary)); font-weight: 500; margin-top: 1px; }

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  background: hsl(var(--bg-elev-3));
  color: hsl(var(--text-secondary));
}
.rank-pill.gold { background: hsl(38 85% 25%); color: hsl(42 95% 75%); }
.rank-pill.silver { background: hsl(200 8% 28%); color: hsl(210 15% 85%); }
.rank-pill.bronze { background: hsl(20 45% 22%); color: hsl(24 65% 72%); }

.score-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
}

.score-empty { color: hsl(var(--text-tertiary)); font-size: 12px; }
.score-draft { opacity: 0.55; border: 1px dashed hsl(var(--text-tertiary) / 0.6); background: transparent !important; color: hsl(var(--text-secondary)) !important; }

.total-cell { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: hsl(var(--accent-strong)); }
.avg-cell { color: hsl(var(--text-secondary)); font-weight: 600; }
.count-cell { color: hsl(var(--text-tertiary)); }

/* States */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: hsl(var(--text-tertiary));
  text-align: center;
}
.state-block strong { color: hsl(var(--text-secondary)); font-size: 14px; font-weight: 600; }
.state-block p { margin: 0; font-size: 12px; max-width: 320px; }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid hsl(var(--border));
  border-top-color: hsl(var(--accent));
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton-row td {
  padding: 12px 14px;
}
.skeleton-bar {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, hsl(var(--bg-elev-2)), hsl(var(--bg-elev-3)), hsl(var(--bg-elev-2)));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.hidden { display: none !important; }

/* Responsive */
@media (max-width: 720px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 16px; }
  .topbar { padding: 12px 16px; }
}
