:root {
  --bg: #0f1720;
  --panel: #17212b;
  --border: #2a3947;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --accent: #2f81f7;
  --danger: #f85149;
  --ok: #3fb950;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header h1 { font-size: 18px; margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tabs button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}

button.secondary { background: #30363d; }
button.danger { background: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th { color: var(--muted); font-weight: 600; }

input, select, textarea {
  background: #0d1117;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px;
  width: 100%;
  font-size: 14px;
}

label { display: block; margin: 8px 0 4px; color: var(--muted); font-size: 13px; }

/* Checkboxes/radios must not stretch to full width like text inputs. */
input[type="checkbox"], input[type="radio"] { width: auto; }

/* Small inline pill/badge (e.g. "Skjult" marker in the competition list). */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  line-height: 18px;
}
.tag-hidden { background: #7a2e2e; color: #ffd9d9; }

/* Vertical list of checkbox options: box first, label text on the same line. */
.check-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.check-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check-label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.profile-editor textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
.profile-actions { margin-top: 12px; flex-wrap: wrap; }
.profile-section-title { margin-top: 20px; margin-bottom: 4px; }
.profile-section-title h3 { margin: 0; }
.profile-quick-setup { margin-top: 16px; }
.profile-quick-setup .profile-section-title { margin-top: 0; }
.quick-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.quick-grid label { min-height: 30px; }
.quick-grid input { min-width: 0; }
.map-legend { display: flex; gap: 10px; color: var(--muted); font-size: 12px; }
.map-legend span::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.legend-area::before { background: #58a6ff; }
.legend-zone::before { background: #d29922; }
.legend-resource::before { background: #3fb950; }
.profile-map { display: block; width: 100%; min-height: 840px; margin: 8px 0 16px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.profile-map text { fill: var(--text); font-size: 14px; pointer-events: none; }
.profile-map .map-empty { fill: var(--muted); font-size: 16px; }
.profile-map .map-empty-help { fill: var(--muted); font-size: 13px; }
.profile-map foreignObject button { width: 100%; }
.profile-map .map-item { cursor: pointer; }
.profile-map .map-item.draggable { cursor: move; }
.profile-map .map-item.selected { filter: brightness(1.35); }
.profile-empty { padding: 12px 0; }
.resource-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.resource-row { display: grid; grid-template-columns: 1.3fr 1.5fr 1fr 0.7fr 0.7fr 0.8fr auto; gap: 8px; align-items: end; padding: 10px; background: #0d1117; border: 1px solid var(--border); border-radius: 6px; }
.resource-row label { margin-top: 0; }
.resource-row .r-delete { padding: 8px 10px; }
.resource-row .r-angle, .resource-row .r-scale { min-width: 70px; }
.geometry-details { grid-column: 1 / -1; }
.geometry-details summary { color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px 0; }
.geometry-details textarea { min-height: 72px; font-size: 12px; }

@media (max-width: 700px) {
  .grid2 { grid-template-columns: 1fr; }
  main { padding: 12px; }
  .profile-editor textarea { min-height: 360px; }
  .profile-map { min-height: 620px; }
  .resource-row { grid-template-columns: 1fr 1fr; }
  .resource-row .r-delete { grid-column: 1 / -1; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.error { color: var(--danger); margin-top: 8px; }
.ok { color: var(--ok); }
.muted { color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

.year-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}
.year-group > summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
  background: var(--panel);
  user-select: none;
}
.year-group > summary:hover { background: #161b22; }
.year-group[open] > summary { border-bottom: 1px solid var(--border); }
.year-group > table { margin-top: 0; }
.year-group > table th { padding-top: 10px; }

.online-badge {
  display: inline-block;
  margin: 2px 10px 2px 0;
  color: var(--text);
}
.online-badge::first-letter { color: var(--ok); }
.access-row > td { background: #0d1117; }
.access-section { margin-top: 16px; padding: 12px; border: 1px solid var(--border); border-left: 4px solid var(--accent); background: #111a22; }
.access-section h4 { margin: 0 0 8px; }
.access-section-opprop { border-left-color: var(--ok); }
.access-section-rreg { border-left-color: #a63d40; }
.rreg-permissions { margin-top: 8px; }
.user-filters .toolbar { flex-wrap: wrap; }
.user-filters select { width: auto; min-width: 150px; }
.user-filters input { width: min(280px, 100%); }
.access-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.access-badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.access-stevne { background: #1f6feb; color: #fff; }
.access-opprop { background: #238636; color: #fff; }
.access-opprop-global { background: #0f766e; color: #fff; }
.access-rreg { background: #a63d40; color: #fff; }
.access-both { background: #8957e5; color: #fff; }
.access-role-list { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.access-role { display: block; width: fit-content; padding: 2px 6px; border-radius: 4px; font-size: 11px; }
.role-manager { background: #b85c00; color: #fff; }
.role-viewer { background: #536d7a; color: #fff; }
.role-rreg { background: #a63d40; color: #fff; }

/* Inline competition edit form (opens under the row being edited). */
.inline-edit-row > td { background: #0d1117; padding: 12px; }
.inline-edit-row .card { margin-bottom: 0; }
.inline-new-form .card { margin: 10px 0; }

/* LiveRes4 view-access code shown in the competition list. */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.code { letter-spacing: 0.5px; white-space: nowrap; user-select: all; }
.sub { font-size: 12px; margin-top: 2px; }

.qr-page { max-width: 760px; margin: 0 auto; }
.qr-controls { display: flex; align-items: end; gap: 12px; margin-bottom: 16px; }
.qr-controls > div { flex: 1; }
.qr-sheet {
  background: #fff;
  color: #111;
  border-radius: 8px;
  padding: clamp(24px, 6vw, 56px);
  text-align: center;
}
.qr-kicker { margin: 0 0 8px; font-size: 18px; font-weight: 700; text-transform: uppercase; }
.qr-sheet h2 { margin: 0; font-size: clamp(26px, 5vw, 42px); }
.qr-date { margin: 8px 0 24px; font-size: 18px; }
.qr-sheet img { display: block; width: min(100%, 440px); height: auto; aspect-ratio: 1; margin: 0 auto; }
.qr-instruction { margin: 20px 0 8px; font-size: 24px; font-weight: 700; }
.qr-url { color: #1756a9; overflow-wrap: anywhere; }
.qr-access-code { margin: 16px 0 0; font-size: 18px; }

@media print {
  body { background: #fff; }
  header, .tabs, .no-print { display: none !important; }
  main { max-width: none; margin: 0; padding: 0; }
  .qr-page { max-width: none; }
  .qr-sheet { padding: 12mm; }
}

.datefield { display: flex; gap: 6px; align-items: center; }
.datefield .d-text { flex: 1 1 auto; }
.datefield .d-pick { flex: 0 0 auto; width: 44px; padding: 8px 4px; color: transparent; }
.datefield .d-pick::-webkit-datetime-edit { display: none; }
.datefield .d-pick::-webkit-calendar-picker-indicator { opacity: 1; }

pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
  max-height: 400px;
  font-size: 12px;
}
