/* ============================================================
   SFest Design System — mobile-first, offline-safe (no CDN)
   ============================================================ */

/* ----------------------------------------------------------
   Design Tokens
   ---------------------------------------------------------- */
:root {
  /* --- Accent (Indigo) --- */
  --accent:        #3d5af1;
  --accent-hover:  #2a44d6;
  --accent-active: #1f32b0;
  --accent-light:  #eef0fd;

  /* --- Neutral Palette --- */
  --gray-50:  #f8f9fb;
  --gray-100: #f0f2f5;
  --gray-200: #e4e7ed;
  --gray-300: #cdd2db;
  --gray-400: #9da5b4;
  --gray-500: #6b7485;
  --gray-600: #556676;
  --gray-700: #374151;
  --gray-900: #111827;

  /* --- Semantic --- */
  --color-bg:        var(--gray-100);
  --color-surface:   #ffffff;
  --color-text:      var(--gray-900);
  --color-text-muted: var(--gray-500);
  --color-border:    var(--gray-200);
  --color-error:     #c0392b;
  --color-error-bg:  #fdf3f2;
  --color-success:   #1a7f5a;
  --color-success-bg: #f0faf6;
  --color-warning:   #b45309;
  --color-warning-bg: #fffbeb;
  --gold:            #d4a017;
  --color-success-border: color-mix(in srgb, var(--color-success) 25%, transparent);

  /* --- Spacing Scale --- */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* --- Radius Scale --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, .07), 0 2px 4px rgba(0, 0, 0, .05);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, .10), 0 4px 8px rgba(0, 0, 0, .06);

  /* --- Typography --- */
  --font-sans: -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-size-base: 16px;
  --font-size-sm:   14px;
  --font-size-xs:   12px;
  --font-size-lg:   18px;
  --font-size-xl:   22px;
  --font-size-2xl:  28px;
  --line-height: 1.5;

  /* --- Touch target minimum --- */
  --touch-min: 44px;

  /* --- Transitions --- */
  --transition-fast: 140ms ease;
  --transition-base: 200ms ease;

  /* --- On-accent text color --- */
  --color-on-accent: #ffffff;
}

/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ----------------------------------------------------------
   Layout
   ---------------------------------------------------------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--sp-4);
}

/* ----------------------------------------------------------
   Card
   ---------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

/* ----------------------------------------------------------
   Form Primitives
   ---------------------------------------------------------- */
label {
  display: block;
  margin-bottom: var(--sp-4);
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-5);
}

.label-text {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: .01em;
}

input,
textarea,
select {
  display: block;
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);   /* 16px — prevents iOS zoom */
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  min-height: var(--touch-min);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

input:hover,
textarea:hover {
  border-color: var(--gray-400);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 90, 241, .18);
}

input::placeholder {
  color: var(--gray-400);
}

/* ----------------------------------------------------------
   Buttons
   ---------------------------------------------------------- */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--touch-min);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary,
button[type="submit"] {
  width: 100%;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
button[type="submit"]:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:active,
button[type="submit"]:active {
  background: var(--accent-active);
  transform: translateY(1px);
  box-shadow: none;
}

.btn:focus-visible,
.btn-primary:focus-visible,
button[type="submit"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(61, 90, 241, .30);
}

/* ----------------------------------------------------------
   Error / Alert States
   ---------------------------------------------------------- */
.error {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(192, 57, 43, .25);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  margin-bottom: var(--sp-5);
}

/* ----------------------------------------------------------
   Login Screen Layout
   ---------------------------------------------------------- */
/* Center the login card vertically on the page */
body:has(.login-wrapper) main.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding-top: var(--sp-8);
  padding-bottom: var(--sp-8);
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  padding: 0 var(--sp-2);
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: block;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* Brand mark in the topbar (app icon next to the wordmark) */
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  vertical-align: -7px;
  margin-right: 2px;
}

.login-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.02em;
  line-height: 1.1;
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--sp-1);
  font-weight: 500;
}

.login-card {
  padding: var(--sp-8);
  box-shadow: var(--shadow-lg);
}

/* ----------------------------------------------------------
   Topbar (used by Tasks 7–9, defined here for consistency)
   ---------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  font-weight: 800;
  font-size: var(--font-size-lg);
  color: var(--accent);
  letter-spacing: -.01em;
  text-decoration: none;
}

.topbar-spacer {
  flex: 1;
}

/* ----------------------------------------------------------
   Segment / Tab Controls (Tasks 7–9)
   ---------------------------------------------------------- */
.seg {
  display: inline-flex;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: var(--sp-1);
  gap: var(--sp-1);
}

.seg a,
.seg button {
  min-height: 36px;
  padding: var(--sp-1) var(--sp-4);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-500);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  width: auto;
}

.seg a:hover,
.seg button:hover {
  color: var(--gray-900);
  background: var(--color-surface);
}

.seg a.active,
.seg button.active {
  background: var(--color-surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------
   Badge (Tasks 7–9)
   ---------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  line-height: 1.4;
}

.badge-accent   { background: var(--accent-light); color: var(--accent); }
.badge-success  { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning  { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-error    { background: var(--color-error-bg); color: var(--color-error); }
.badge-neutral  { background: var(--gray-100); color: var(--gray-500); }

/* ----------------------------------------------------------
   Board / Table (Tasks 7–9)
   ---------------------------------------------------------- */
.board {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.board th,
.board td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.board th {
  font-weight: 700;
  color: var(--gray-500);
  font-size: var(--font-size-xs);
  letter-spacing: .05em;
  text-transform: uppercase;
  background: var(--gray-50);
}

.board tbody tr:hover {
  background: var(--gray-50);
}

.board td:last-child,
.board th:last-child {
  text-align: right;
}

/* ----------------------------------------------------------
   Utilities
   ---------------------------------------------------------- */
.text-muted  { color: var(--color-text-muted); }
.text-sm     { font-size: var(--font-size-sm); }
.text-xs     { font-size: var(--font-size-xs); }
.font-bold   { font-weight: 700; }
.mt-4        { margin-top: var(--sp-4); }
.mt-6        { margin-top: var(--sp-6); }
.mb-4        { margin-bottom: var(--sp-4); }
.w-full      { width: 100%; }

/* ============================================================
   Task 7 — Score Entry Screen
   ============================================================ */

/* --- Topbar navigation links & controls --- */
.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  min-height: var(--touch-min);
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.topbar-back:hover { color: var(--accent-hover); }
.topbar-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar-judge {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.topbar-link {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  transition: background var(--transition-fast);
}

.topbar-link:hover { background: var(--accent-light); }

.topbar-logout-form { display: inline; }

.btn-link {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  padding: var(--sp-1) var(--sp-3);
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  display: inline-flex;
  align-items: center;
}

.btn-link:hover { color: var(--color-text); background: var(--gray-100); }

/* Sticky running total in topbar */
.sticky-total {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--gray-700);
  background: var(--accent-light);
  color: var(--accent);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.sticky-total strong {
  font-size: var(--font-size-lg);
}

/* --- Score Page (company list) --- */
.score-page {
  padding-top: var(--sp-4);
}

.score-page-header {
  margin-bottom: var(--sp-4);
}

.score-page-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

.score-page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--sp-1);
}

.company-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.company-list-item { /* wrapper li */ }

.company-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  min-height: var(--touch-min);
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.company-row:hover {
  background: var(--gray-50);
  box-shadow: var(--shadow-md);
}

.company-row:active {
  transform: scale(.995);
}

.company-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.company-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.company-name {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-presenter {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 400;
}

.company-badge {
  flex-shrink: 0;
  font-size: var(--font-size-sm);
  padding: var(--sp-1) var(--sp-3);
  min-width: 56px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.company-badge.done {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* --- Company Scoring Screen --- */
.company-score-page {
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-12);
}

.company-header {
  margin-bottom: var(--sp-5);
}

.company-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

.company-meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.company-url {
  color: var(--accent);
  word-break: break-all;
}

/* Criterion cards */
.criterion {
  margin-bottom: var(--sp-4);
}

.criterion-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.criterion-label {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.criterion-max {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Score lines (question + segmented buttons) */
.score-line {
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--color-border);
}

.score-line:last-of-type { /* don't rely on this — use comment-label border instead */ }

.qtext {
  font-size: var(--font-size-sm);
  color: var(--gray-700);
  line-height: 1.4;
  margin-bottom: var(--sp-2);
}

/* --- Segmented score buttons --- */
.segments {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--sp-2);
}

/* Override global .seg (which is a container) for score buttons inside .segments */
.segments .seg {
  /* Reset the container styles that .seg sets */
  display: inline-flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 0;
  gap: 0;

  /* Score button sizing — must meet --touch-min */
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--touch-min);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--gray-700);
  border: 1.5px solid var(--color-border);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  /* Cancel out the inherited global button width:auto override */
  width: auto;
}

.segments .seg:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
  color: var(--gray-900);
}

.segments .seg.selected {
  background: var(--accent);
  color: var(--color-on-accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.segments .seg.selected:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.segments .seg:active {
  transform: scale(.94);
}

.segments .seg:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(61, 90, 241, .30);
}

/* Notes/comment area */
.comment-label {
  display: block;
  margin-top: var(--sp-3);
  margin-bottom: 0;
}

.comment-label-text {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: var(--sp-1);
}

.comment-textarea {
  resize: vertical;
  min-height: 60px;
  font-size: var(--font-size-sm);
  color: var(--gray-700);
}

/* Save status bar */
.save-status-bar {
  position: fixed;
  bottom: var(--sp-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}

.save-status {
  display: inline-block;
  padding: var(--sp-1) var(--sp-4);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 600;
  min-height: 0;
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(26, 127, 90, .2);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.save-status:not(:empty) {
  opacity: 1;
}

.save-status.error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: rgba(192, 57, 43, .2);
}

/* --- Responsive adjustments --- */
@media (max-width: 480px) {
  .company-row {
    padding: var(--sp-3) var(--sp-4);
  }

  .criterion-label {
    font-size: var(--font-size-base);
  }

  .segments .seg {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }
}

/* ----------------------------------------------------------
   Responsive — no horizontal scroll at 390px
   ---------------------------------------------------------- */
@media (max-width: 480px) {
  .card {
    border-radius: var(--radius-md);
    padding: var(--sp-5);
  }

  .login-card {
    padding: var(--sp-5);
    box-shadow: var(--shadow-md);
  }

  .login-title {
    font-size: var(--font-size-xl);
  }

  .topbar {
    padding: var(--sp-2) var(--sp-3);
  }
}

/* ============================================================
   Task 8 — Live Results Leaderboard
   ============================================================ */

/* --- Page layout --- */
.results-page {
  padding-top: var(--sp-4);
  padding-bottom: var(--sp-12);
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.results-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

/* --- Live pulse indicator --- */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-success);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  padding: 3px var(--sp-2);
  border-radius: var(--radius-pill);
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--color-success);
  border-radius: 50%;
  flex-shrink: 0;
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.75); }
}

/* --- Leaderboard list --- */
.board {
  /* override the table styles set by the global .board rule */
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  list-style: none;
  padding: 0;
  width: auto;
  border-collapse: unset;
  font-size: var(--font-size-base);
}

/* Reset global .board th/.board td rules scoped to table usage */
.board.board th,
.board.board td {
  padding: 0;
  text-align: unset;
  border-bottom: none;
}

/* --- Board row card --- */
.board-row {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.board-row:hover {
  box-shadow: var(--shadow-md);
}

/* Top-ranked row — subtle accent border treatment */
.board-row--top {
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 0 0 1px var(--accent-light), var(--shadow-sm);
}

/* --- Summary (always-visible row) --- */
.board-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  min-height: var(--touch-min);
  list-style: none; /* hide WebKit disclosure triangle */
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast);
}

.board-summary::-webkit-details-marker { display: none; }

.board-summary:hover {
  background: var(--gray-50);
}

.board-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

details[open] .board-summary {
  border-bottom: 1px solid var(--color-border);
}

/* --- Rank number --- */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 28px;
  flex-shrink: 0;
  font-size: var(--font-size-sm);
  font-weight: 800;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
}

.rank--top {
  color: var(--accent);
}

.rank--first {
  background: var(--gold);
  color: var(--gray-900);
  border-radius: var(--radius-pill);
  width: auto;
  padding: 0 var(--sp-2);
}

/* --- Company name + presenter --- */
.board-row .company-info {
  flex: 1;
  min-width: 0;
}

.board-row .company-name {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--gray-900);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-row .company-presenter {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Amalgamated average --- */
.avg {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  letter-spacing: -.01em;
}

.board-row--top .avg {
  font-size: var(--font-size-2xl);
}

.avg-denom {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-left: 1px;
}

/* --- Expand chevron --- */
.board-chevron {
  font-size: 20px;
  color: var(--gray-400);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  line-height: 1;
}

details[open] .board-chevron {
  transform: rotate(90deg);
}

/* --- Breakdown panel --- */
.breakdown {
  padding: var(--sp-4) var(--sp-5);
}

.breakdown-count {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: var(--sp-2);
}

.breakdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.breakdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
  min-height: var(--touch-min);
}

.breakdown-item:first-child {
  border-top: none;
}

.breakdown-judge {
  color: var(--gray-700);
  font-weight: 500;
}

.breakdown-total {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--gray-900);
  font-size: var(--font-size-base);
}

.breakdown-item--empty {
  color: var(--color-text-muted);
  font-style: italic;
  justify-content: center;
}

/* --- Responsive adjustments --- */
@media (max-width: 480px) {
  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .board-summary {
    padding: var(--sp-3) var(--sp-4);
    gap: var(--sp-2);
  }

  .breakdown {
    padding: var(--sp-3) var(--sp-4);
  }

  .avg {
    font-size: var(--font-size-lg);
  }

  .board-row--top .avg {
    font-size: var(--font-size-xl);
  }
}

/* ============================================================
   Task 9 — Admin Panel
   ============================================================ */

/* --- Page shell --- */
.admin-page {
  padding-top: var(--sp-6);
  padding-bottom: var(--sp-12);
}

/* --- Section blocks --- */
.admin-section {
  margin-bottom: var(--sp-8);
}

.admin-section-header {
  margin-bottom: var(--sp-4);
}

.admin-section-title {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

.admin-section-sub {
  margin-top: var(--sp-1);
}

.admin-subsection-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: var(--sp-4);
}

/* --- Company edit grid --- */
.company-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}

.company-edit {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.company-edit-header {
  margin-bottom: var(--sp-2);
}

.company-edit-num {
  display: inline-block;
  background: var(--gray-100);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-pill);
  font-weight: 600;
  letter-spacing: .04em;
}

.required-star {
  color: var(--color-error);
}

.btn-save {
  margin-top: var(--sp-2);
}

/* --- Add judge card --- */
.admin-add-judge {
  margin-bottom: var(--sp-4);
}

.add-judge-form {
  max-width: 400px;
}

/* --- Judges card list --- */
.judge-cards {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.judge-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.judge-card--disabled {
  opacity: 0.72;
}

.judge-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.judge-card-name {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--gray-900);
}

.judge-card--disabled .judge-card-name {
  color: var(--color-text-muted);
}

.judge-card-badges {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.judge-card-meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.judge-username {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.judge-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: flex-start;
  padding-top: var(--sp-2);
  border-top: 1px solid var(--color-border);
}

/* Reset-password inline form */
.reset-pw-form {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

.reset-pw-form input {
  flex: 1;
  min-width: 120px;
  min-height: var(--touch-min);
  font-size: var(--font-size-sm);
  padding: var(--sp-2) var(--sp-3);
}

.btn-set-pw {
  min-height: var(--touch-min);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--font-size-sm);
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  width: auto;
  white-space: nowrap;
  box-shadow: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-set-pw:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* --- Danger zone --- */
.danger-zone {
  border-color: var(--color-warning);
  border-width: 1.5px;
  background: var(--color-warning-bg);
}

.danger-zone-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid color-mix(in srgb, var(--color-warning) 30%, transparent);
}

.danger-zone-icon {
  font-size: 24px;
  color: var(--color-warning);
  flex-shrink: 0;
  line-height: 1.2;
}

.danger-zone-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-warning);
  margin-bottom: var(--sp-1);
}

.danger-zone-sub {
  font-size: var(--font-size-sm);
  color: var(--color-warning);
  opacity: .8;
}

.danger-zone-body { }

.danger-action {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.danger-action-desc {
  color: var(--gray-700);
}

.danger-confirm-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
}

.danger-confirm-label {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
}

.danger-confirm-input {
  margin-top: var(--sp-2);
  border-color: color-mix(in srgb, var(--color-warning) 40%, transparent);
  background: var(--color-surface);
}

.danger-confirm-input:focus-visible {
  border-color: var(--color-warning);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-warning) 20%, transparent);
}

.btn-danger,
button[type="submit"].btn-danger {
  background: var(--color-error);
  color: var(--color-on-accent);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  border-radius: var(--radius-md);
  width: auto;
  min-height: var(--touch-min);
  padding: var(--sp-3) var(--sp-5);
}

.btn-danger:hover,
button[type="submit"].btn-danger:hover {
  background: color-mix(in srgb, var(--color-error) 85%, black);
  box-shadow: var(--shadow-md);
}

.btn-danger:active,
button[type="submit"].btn-danger:active {
  background: color-mix(in srgb, var(--color-error) 70%, black);
  transform: translateY(1px);
  box-shadow: none;
}

.btn-danger:focus-visible,
button[type="submit"].btn-danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-error) 35%, transparent);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .company-edit-grid {
    grid-template-columns: 1fr;
  }

  .danger-confirm-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-danger {
    width: 100%;
  }

  .judge-card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .judge-card-actions .btn-secondary,
  .judge-card-actions .btn-danger {
    width: 100%;
  }

  .reset-pw-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .reset-pw-form input {
    min-width: 0;
    width: 100%;
  }

  .btn-set-pw {
    width: 100%;
    min-height: var(--touch-min);
  }
}

/* ── SMTP Settings ─────────────────────────────────────────── */
.smtp-settings-card {
  padding: var(--sp-6);
}

.smtp-fields {
  display: grid;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.smtp-test-row {
  border-top: 1px solid var(--color-border);
  padding-top: var(--sp-5);
  margin-top: var(--sp-5);
}

.smtp-test-form {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.smtp-test-form .field-label {
  flex: 1;
  min-width: 200px;
}

.smtp-notice {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: var(--font-size-sm);
}

.field-label--inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-3);
}

.field-label--inline .label-text {
  margin-bottom: 0;
}

.checkbox {
  width: 18px;
  height: 18px;
  min-height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.btn-secondary {
  min-height: var(--touch-min);
  padding: 0 var(--sp-5);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-300);
  background: var(--color-surface);
  color: var(--gray-700);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Inline helper hint under a form field */
.field-hint {
  display: block;
  margin-top: var(--sp-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}
