/* 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;
  --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;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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; }

.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); }
.games-set { display: flex; flex-wrap: wrap; column-gap: 24px; }
.games-set legend { width: 100%; }
.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;
}
.game-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.game-form .msg { grid-column: 1 / -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; }
  .grid-2 { grid-template-columns: 1fr; }
  .game-form { grid-template-columns: 1fr 1fr; }
  .field-name, .field-prize { grid-column: 1 / -1; }
  .toolbar .field { max-width: none; }
  .toolbar-end { margin-left: 0; }
  .login { margin-top: 8vh; }
}
