:root {
  --primary: #00b4ef;
  --primary-hover: #0099cc;
  --primary-active: #0077a3;
  --primary-subtle-bg: #e6f7fd;
  --bg-main: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-default: #e2e8f0;
  --border-strong: #cbd5e1;
  --focus-ring: #00b4ef;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  background:
    radial-gradient(circle at 0% 0%, var(--primary-subtle-bg), transparent 42%),
    radial-gradient(circle at 100% 100%, #eff6ff, transparent 38%),
    var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: 1rem;
  gap: 0.8rem;
}

.top-nav {
  width: min(1180px, 100%);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  border-radius: 14px;
  padding: 0.6rem;
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  align-items: center;
}

.top-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.top-nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: var(--bg-secondary);
}

.top-nav-links a.is-active,
.top-nav-links a[aria-current="page"] {
  color: var(--bg-card);
  background: var(--primary);
  border-color: var(--primary-active);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--primary-active);
}

.top-nav-links a:hover {
  background: var(--primary-subtle-bg);
  border-color: var(--focus-ring);
  color: var(--text-primary);
}

.top-nav-links a.is-active:hover,
.top-nav-links a[aria-current="page"]:hover,
.top-nav-links a.is-active:focus-visible,
.top-nav-links a[aria-current="page"]:focus-visible {
  color: var(--bg-card);
  background: var(--primary);
  border-color: var(--primary-active);
}

.card {
  width: min(680px, 100%);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 20px 35px rgb(15 23 42 / 6%);
}

.card-wide {
  width: min(1180px, 100%);
}

.panel-header {
  margin-bottom: 1rem;
}

.controls {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.admin-actions {
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.latency-banner {
  align-self: end;
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #3b82f6;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border-default);
  padding: 0.55rem;
  text-align: left;
}

.data-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.row-blocked td {
  text-decoration: line-through;
  color: var(--text-muted);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-danger {
  background: var(--error);
  color: #ffffff;
}

.large-row {
  font-size: 1.25rem;
}

.btn-xl {
  font-size: 1.2rem;
  padding: 0.95rem 1.25rem;
}

.toestel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  font-size: 0.9rem;
}

h1 {
  margin-top: 0;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-secondary);
  margin-top: 0;
  margin-bottom: 1rem;
}

.button-grid {
  display: grid;
  gap: 0.75rem;
}

.stack {
  display: grid;
  gap: 0.6rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tabs a {
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: var(--bg-secondary);
}

input,
select {
  width: 100%;
  font-size: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  color: var(--text-primary);
  background: #ffffff;
}

input:focus,
select:focus {
  outline: 2px solid color-mix(in oklab, var(--focus-ring), white 45%);
  outline-offset: 1px;
  border-color: var(--focus-ring);
}

.btn {
  border: 0;
  border-radius: 11px;
  font-size: 1rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  background: var(--primary-active);
}

.muted {
  min-height: 1.5rem;
  margin: 0;
  color: var(--text-muted);
}

.feedback-info {
  color: #1e3a8a;
}

.feedback-success {
  color: #166534;
}

.feedback-warning {
  color: #92400e;
}

.feedback-error {
  color: #991b1b;
  font-weight: 600;
}

.score-input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgb(239 68 68 / 20%);
}

.data-table input[data-jury] {
  width: 4.6rem;
  min-width: 0;
  max-width: 100%;
  padding: 0.5rem 0.45rem;
  text-align: center;
}

.dual-input-stack {
  display: grid;
  gap: 0.2rem;
}

.dual-input-row {
  display: grid;
  grid-template-columns: 0.9rem 1fr;
  align-items: center;
  gap: 0.2rem;
}

.dual-input-row span {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
}

.dual-input-row input[data-jury] {
  width: 100%;
}

.jury-medaille {
  display: block;
  margin-top: 0.08rem;
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.1;
}

.score-input-success {
  border-color: #22c55e;
  background: #ecfdf5;
  color: #166534;
  box-shadow: 0 0 0 2px rgb(34 197 94 / 20%);
}

.status-chip {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 999px;
  font-weight: 800;
  border: 1px solid transparent;
  cursor: pointer;
}

.status-chip:focus-visible,
.status-chip.is-active {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.status-chip.status-ok {
  color: #166534;
  background: #ecfdf5;
  border-color: #22c55e;
}

.status-chip.status-missing {
  color: #991b1b;
  background: #fef2f2;
  border-color: #ef4444;
}

.status-chip.status-progress {
  color: #92400e;
  background: #fffbeb;
  border-color: #f59e0b;
}

.ranking-row {
  cursor: pointer;
}

.ranking-row:hover {
  background: #f8fafc;
}

.rank-gold td:first-child {
  background: #facc15;
  color: #422006;
  font-weight: 700;
}

.rank-silver td:first-child {
  background: #d1d5db;
  color: #1f2937;
  font-weight: 700;
}

.rank-bronze td:first-child {
  background: #d97706;
  color: #fff7ed;
  font-weight: 700;
}

.recent-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

.recent-score-card {
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 0.75rem;
  background: #ffffff;
}

.recent-score-card header {
  font-weight: 700;
}

.recent-score-toestel {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.recent-score-value {
  margin: 0.45rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0b4a6f;
}

.ranking-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(2 6 23 / 55%);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 1200;
}

.ranking-modal {
  width: min(560px, 100%);
  border-radius: 14px;
  border: 1px solid var(--border-default);
  background: #ffffff;
  padding: 1rem;
  position: relative;
}

.ranking-modal h3 {
  margin-top: 0;
  margin-bottom: 0.3rem;
}

.status-detail-modal {
  width: min(640px, 100%);
}

.status-modal-text {
  margin: 0.4rem 0 0;
  padding: 0.75rem;
  border: 1px solid var(--border-default);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text-primary);
  white-space: pre-line;
  max-height: min(65vh, 480px);
  overflow: auto;
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  font-size: 0.96rem;
  line-height: 1.45;
}

.ranking-modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  cursor: pointer;
}

.ranking-score-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.ranking-score-list > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.8rem;
  align-items: baseline;
  border-bottom: 1px solid var(--border-default);
  padding-bottom: 0.35rem;
}

.ranking-score-list > div small {
  grid-column: 1 / -1;
  color: var(--text-secondary);
}

@media (min-width: 768px) {
  .card {
    padding: 1.5rem;
  }

  .button-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .large-row {
    font-size: 1.45rem;
  }

  .btn-xl {
    font-size: 1.3rem;
    min-width: 170px;
  }

  .recent-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  html,
  body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .page {
    padding: 0.65rem;
    width: 100%;
    max-width: 100vw;
  }

  .card,
  .card-wide,
  .top-nav {
    width: 100%;
    max-width: 100vw;
  }

  .card,
  .card-wide {
    padding: 0.85rem;
  }

  .top-nav {
    flex-direction: column;
    align-items: stretch;
  }

  #logout-btn {
    width: 100%;
  }

  .data-table {
    min-width: 560px;
    font-size: 0.9rem;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table th,
  .data-table td {
    padding: 0.4rem;
  }

  [data-page="jury"] .data-table {
    min-width: 0;
    font-size: 0.82rem;
    table-layout: auto;
  }

  [data-page="status"] .data-table {
    min-width: 350px;
    font-size: 0.82rem;
  }

  [data-page="ranking"] .data-table,
  [data-page="recente_scores"] .data-table {
    min-width: 0;
    font-size: 0.86rem;
  }

  [data-page="jury"] .data-table th,
  [data-page="jury"] .data-table td,
  [data-page="status"] .data-table th,
  [data-page="status"] .data-table td,
  [data-page="ranking"] .data-table th,
  [data-page="ranking"] .data-table td,
  [data-page="recente_scores"] .data-table th,
  [data-page="recente_scores"] .data-table td {
    padding: 0.28rem;
  }

  [data-page="jury"] .data-table th:nth-child(3),
  [data-page="jury"] .data-table td:nth-child(3) {
    display: none;
  }

  [data-page="jury"] .data-table th:first-child,
  [data-page="jury"] .data-table td:first-child {
    width: 2.7rem;
    white-space: nowrap;
  }

  [data-page="jury"] .data-table th:nth-child(2),
  [data-page="jury"] .data-table td:nth-child(2) {
    width: auto;
    max-width: none;
    overflow: visible;
    text-overflow: initial;
    white-space: normal;
    line-height: 1.15;
    word-break: break-word;
  }

  [data-page="jury"] .jury-medaille {
    font-size: 0.62rem;
  }

  [data-page="jury"] .data-table th:nth-child(4),
  [data-page="jury"] .data-table td:nth-child(4),
  [data-page="jury"] .data-table th:nth-child(5),
  [data-page="jury"] .data-table td:nth-child(5) {
    width: 4.1rem;
    min-width: 4.1rem;
  }

  .data-table input[data-jury] {
    width: 3.1rem;
    padding: 0.34rem 0.2rem;
    font-size: 0.86rem;
  }

  .dual-input-row {
    grid-template-columns: 0.62rem 1fr;
    gap: 0.08rem;
  }

  .dual-input-row span {
    font-size: 0.65rem;
  }

  .toestel-grid {
    grid-template-columns: 1fr;
  }

  .status-modal-text {
    font-size: 0.9rem;
  }
}
