/* Admin panel: neutral, quiet look. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #5f5e5a;
  --border: rgba(0, 0, 0, .12);
  --accent: #1f6feb;
  --on-accent: #ffffff;
  --danger: #c4314b;
  --ok: #2f7d32;
  --warn: #8a5a00;
  --hover: rgba(0, 0, 0, .04);
  --radius: 6px;
  --gutter: 16px;
  --control: 40px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1f1f1d;
    --text: #f0efe9;
    --muted: #a8a69e;
    --border: rgba(255, 255, 255, .14);
    --accent: #6ea8fe;
    --on-accent: #141413;
    --hover: rgba(255, 255, 255, .06);
    --danger: #ff8a9b;
    --ok: #7fd18a;
    --warn: #f0b429;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; } /* .btn and friends set display, which would otherwise win */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.125rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[tabindex="-1"]:focus { outline: none; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */

.wrap, .topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.wrap { padding-bottom: 48px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }

.login {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 0 var(--gutter);
  display: grid;
  gap: 16px;
}
.login-form { display: grid; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  min-height: 44px;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; }
.panel:focus-visible { outline-offset: 4px; }

/* ---------- Controls ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-small { min-height: var(--control); padding: 0 10px; font-size: .875rem; }
.btn-icon { min-width: var(--control); padding: 0; font-size: 1.05rem; }

input[type="text"], input[type="email"], input[type="url"], input[type="number"],
input[type="date"], input[type="file"], select {
  width: 100%;
  min-height: var(--control);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input[type="file"] { padding: 6px; }
select { padding-right: 28px; }
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent); }

.field { display: grid; gap: 4px; min-width: 0; }
.field > label, legend { font-weight: 500; font-size: .875rem; }
.hint { color: var(--muted); font-size: .8125rem; }

.check { display: flex; align-items: center; gap: 8px; min-height: var(--control); }
.check input, .switch { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.check label { cursor: pointer; }

.switch-wrap { display: flex; align-items: center; min-height: var(--control); }
.switch {
  appearance: none;
  position: relative;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--hover);
  cursor: pointer;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s ease;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--on-accent); }
@media (prefers-reduced-motion: reduce) { .switch::after { transition: none; } }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 4px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.toolbar .field { flex: 1 1 200px; max-width: 320px; }
.toolbar-end { margin-left: auto; }

/* ---------- States and messages ---------- */

.state { padding: 16px 0; color: var(--muted); }
.state-error {
  color: var(--text);
  border-left: 3px solid var(--danger);
  padding: 8px 12px;
  margin: 8px 0;
  display: grid;
  gap: 8px;
  justify-items: start;
}
.inline-state:empty { display: none; }
.msg { min-height: 0; font-size: .9375rem; }
.msg:empty { display: none; }
.msg-ok { color: var(--ok); }
.msg-error { color: var(--danger); }
.msg .btn { margin-top: 6px; }

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table thead th { font-size: .8125rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; font-weight: 600; }
.table .num { text-align: right; white-space: nowrap; }
.contact { display: flex; align-items: center; gap: 8px; }
.contact-text { overflow-wrap: anywhere; min-width: 8em; }

/* ---------- Banners ---------- */

.ad-list, .order-list, .game-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 8px; }

.ad-row {
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ad-row-saved { border-color: var(--ok); }
.thumb {
  aspect-ratio: 6 / 1;
  width: 100%;
  overflow: hidden;
  border-radius: 4px;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb img, .thumb video, .preview img, .preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-missing { font-size: .8125rem; }
.ad-info { display: grid; gap: 2px; min-width: 0; }
.ad-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ad-link { overflow-wrap: anywhere; }
.ad-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ad-proposal {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--warn);
  border-radius: 4px;
  background: var(--hover);
}
.ad-proposal-body { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: center; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.5;
}
.badge-actief { color: var(--ok); }
.badge-gepland { color: var(--accent); }
.badge-verlopen, .badge-uit { color: var(--muted); }

.form { display: grid; gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.preview:empty { display: none; }
.preview { aspect-ratio: 6 / 1; max-width: 600px; overflow: hidden; border-radius: 4px; border: 1px solid var(--border); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.order-list { margin: 0; }
.order-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.order-pos { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; }
.order-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.order-buttons { display: flex; gap: 4px; }
.card > h3 { margin-bottom: 12px; }
.card .msg { margin-top: 12px; }

/* ---------- Games ---------- */

.game-row { display: grid; gap: 12px; }
.game-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.game-form {
  display: grid;
  grid-template-columns: 1fr 1.6fr auto 96px;
  gap: 12px 16px;
  align-items: start;
}
.field-website-url { grid-column: 2 / -1; }
.game-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.game-form .msg { grid-column: 1 / -1; }

/* ---------- Prijzen en Ladder ---------- */

.section { margin-bottom: 40px; }
.section > h3 { margin-bottom: 12px; }
.group-title { margin: 20px 0 8px; font-size: .9375rem; color: var(--muted); }
.group-empty { margin-bottom: 8px; }
.form h4 { font-size: 1rem; font-weight: 600; }

.item-list { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 8px; }
.item-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.item-info { display: grid; gap: 2px; min-width: 0; }
.item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-link { overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.item-actions-start { justify-content: flex-start; }
.item-logins {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.item-logins[hidden] { display: none; }
.item-logins h4 { font-size: .9375rem; font-weight: 600; }
.login-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.login-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.login-email { overflow-wrap: anywhere; font-weight: 600; }
.login-row .item-actions { margin-left: auto; }
.login-form { display: grid; gap: 12px; max-width: 480px; }
.thumb-sq {
  width: 72px;
  height: 72px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: .75rem;
}
.thumb-sq img, .preview-sq img { display: block; width: 100%; height: 100%; object-fit: contain; }
.picker { display: grid; gap: 8px; }
.preview-sq:empty { display: none; }
.preview-sq {
  width: 120px;
  height: 120px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--hover);
}
.checks { display: flex; flex-wrap: wrap; column-gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.warn-text { color: var(--warn); font-size: .875rem; }
.warn-text:empty { display: none; }
.block { display: block; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; white-space: nowrap; }

.badge-ok, .badge-confirmed, .badge-redeemed { color: var(--ok); }
.badge-muted, .badge-no_winner, .badge-expired { color: var(--muted); }
.badge-warn, .badge-pending { color: var(--warn); }
.badge-issued { color: var(--accent); }
.badge-blocked { color: var(--danger); }

.prize-checks { display: grid; gap: 0 24px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.prize-checks .check { align-items: flex-start; padding: 8px 0; }
.prize-checks .check input { margin-top: 2px; }
.period-nav { display: flex; align-items: center; gap: 8px; }
.period-text { min-width: 11em; text-align: center; }
.toolbar .hint { align-self: center; }

.confirm-wide { flex-direction: column; align-items: stretch; min-width: 220px; }
.confirm-buttons { display: flex; gap: 8px; }
.action-msg:empty { display: none; }
.more { margin-top: 12px; }
.link-row > td { background: var(--hover); }
.link-box { display: grid; gap: 8px; max-width: 720px; }

/* ---------- Zaken: intro and read-only name ---------- */

.section-intro { margin-bottom: 12px; max-width: 70ch; }
.field-label { font-weight: 500; font-size: .875rem; }
.readonly-value { font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Aanbod: icon or photo ---------- */

.visual-picker { display: grid; gap: 12px; }
.visual-choice { display: grid; gap: 4px; }

/* Segmented radio group: the native radios stay in the tab order and take arrow keys. */
.segmented {
  display: inline-flex;
  justify-self: start;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.segment { position: relative; display: flex; }
.segment + .segment { border-left: 1px solid var(--border); }
.segment input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.segment label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control);
  padding: 0 16px;
  font-weight: 500;
  font-size: .9375rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.segment input:checked + label { background: var(--accent); color: var(--on-accent); }
.segment input:not(:checked):hover + label { background: var(--hover); color: var(--text); }
.segment input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -4px; }
.segment input:checked:focus-visible + label { outline-color: var(--on-accent); }

.icon-panel { display: grid; gap: 12px; max-width: 560px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-btn {
  appearance: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn[aria-pressed="true"] {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--hover);
}
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn[aria-pressed="true"]:focus-visible { outline-offset: 2px; box-shadow: inset 0 0 0 2px var(--accent); }
.icon-input { max-width: 14em; font-size: 1.125rem; }
.icon-preview-row { display: flex; align-items: center; gap: 12px; }
.icon-preview {
  min-width: 64px;
  min-height: 64px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--hover);
  font-size: .875rem;
}
.icon-preview-emoji { font-size: 40px; line-height: 1; }
.thumb-emoji { font-size: 40px; line-height: 1; }

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
  .tab { padding: 0 9px; }
}

@media (max-width: 720px) {
  .ad-row { grid-template-columns: 1fr; }
  .ad-actions { justify-content: flex-start; }
  .ad-proposal-body { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 72px 1fr; }
  .item-row .item-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .period-text { min-width: 0; flex: 1; }
  .game-form { grid-template-columns: 1fr 1fr; }
  .field-name, .field-prize, .field-website-label, .field-website-url { grid-column: 1 / -1; }
  .toolbar .field { max-width: none; }
  .toolbar-end { margin-left: 0; }
  .login { margin-top: 8vh; }
}

/* ---------- Spelers ---------- */

.avatar-cell { width: 52px; }
.avatar-box { display: block; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--hover); }
.avatar-box svg { display: block; width: 100%; height: 100%; }
.player-email { overflow-wrap: anywhere; }
