:root {
  --bg: #0f1115;
  --panel: #151823;
  --muted: #1d2230;
  --ink: #e9eef8;
  --ink-2: #b9c2d0;
  --acc: #5b9cff;
  --acc-2: #8ad1ff;
  --ok: #3ddc97;
  --warn: #ffd166;
  --bad: #ef476f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font: 14.5px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Arial,
    sans-serif;
  background: linear-gradient(180deg, #0e121a, #0a0d13 65%, #090b11);
  color: var(--ink);
}

.wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px 48px;
}

h1 {
  font-weight: 800;
  letter-spacing: 0.3px;
  margin: 8px 0 10px;
  font-size: 28px;
}

.sub {
  color: var(--ink-2);
  margin-bottom: 18px;
}

/* Auth banner */
.auth-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}

.auth-banner-guest {
  background: rgba(239, 71, 111, 0.09);
  border-color: rgba(239, 71, 111, 0.5);
  color: #ffb3c3;
}

.auth-banner-loggedin {
  background: rgba(61, 220, 151, 0.08);
  border-color: rgba(61, 220, 151, 0.45);
  color: #b1f2d6;
}

.auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Second header row (load controls) */
.header-row-secondary {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Make the select expand between the two buttons */
.header-row-secondary #savedRaces,
.header-row-secondary .saved-select {
  flex: 1 1 auto;
  min-width: 0;     /* prevents weird overflow */
  width: auto;      /* override any width:100% */
}

/* Buttons keep natural size */
.header-row-secondary button {
  flex: 0 0 auto;
}

.saved-select {
  min-width: 220px;
  max-width: 100%;
}

/* layout grid & cards */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: 320px 1fr;
  }
}

.card {
  background: linear-gradient(180deg, #171b27, #131826);
  border: 1px solid #1e2433;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.card .hd {
  padding: 14px 16px;
  border-bottom: 1px solid #1f2535;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card .bd {
  padding: 14px 16px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

label.small {
  font-size: 12px;
  color: var(--ink-2);
  display: block;
  margin-bottom: 6px;
}

input,
select,
button,
textarea {
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #2a3246;
  background: #121726;
  color: var(--ink);
  border-radius: 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #355fbe;
  box-shadow: 0 0 0 3px #1a2a52;
}

button {
  background: #161616;
  border: 1px solid #283149;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button.primary {
  background: linear-gradient(180deg, #2a57ff, #2047cf);
  border-color: #2a57ff;
}

button.ghost {
  background: transparent;
  border-color: #283149;
}

button.menu {
  background: #161616;
  border-color: #283149;
}

.kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi .it {
  background: #101520;
  border: 1px solid #20283b;
  border-radius: 12px;
  padding: 10px 12px;
}

.kpi .it b {
  font-size: 18px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #21293d;
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  background: #141a28;
  z-index: 1;
}

.right {
  text-align: right;
}

.center {
  text-align: center;
}

.smallnote {
  font-size: 12px;
  color: var(--ink-2);
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #2a3350;
  border-radius: 999px;
  background: #11172a;
  font-size: 12px;
}

.danger {
  background: linear-gradient(180deg, #3b0f1b, #2a0b14);
  border-color: #5a1d2d;
}

.footer {
  opacity: 0.8;
  margin-top: 16px;
  font-size: 12px;
}

.sep {
  height: 1px;
  background: #1f2739;
  margin: 8px 0 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nowrap {
  white-space: nowrap;
}

#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: block;
}

/* Mobile polish */
button {
  white-space: normal;
  line-height: 1.2;
}

header > .row {
  margin-top: 8px;
}

.card .hd {
  gap: 10px;
}

.sub,
button,
input,
select,
textarea,
th,
td {
  word-break: break-word;
}

.table-wrap,
[style*="overflow:auto"] {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 560px) {
  .wrap {
    padding: 0 12px calc(36px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 22px;
    margin: 6px 0 10px;
  }

  .sub {
    font-size: 13px;
  }

  header > .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  header > .row > button {
    width: 100%;
    min-height: 44px;
  }

  .card .hd {
    flex-wrap: wrap;
  }

  .card .hd .row {
    width: 100%;
    gap: 8px;
  }

  [data-driver] .hd .row {
    flex-direction: column;
    align-items: stretch;
  }

  input[data-name],
  input[data-customcomp] {
    width: 100% !important;
  }

  input,
  select,
  textarea {
    min-height: 44px;
  }

  .kpi {
    grid-template-columns: 1fr 1fr;
  }

  th,
  td {
    padding: 8px 6px;
    font-size: 13px;
  }

  .chip {
    font-size: 11px;
    padding: 2px 6px;
  }

  .saved-select {
    min-width: 100%;
  }
}

@media (max-width: 360px) {
  header > .row {
    grid-template-columns: 1fr;
  }

  .kpi {
    grid-template-columns: 1fr;
  }
}

/* Rijder-kolom smal + ellipsis */
#resultTable td:first-child,
#resultTable th:first-child {
  white-space: nowrap;
  word-break: normal;
  hyphens: none;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  #resultTable td:first-child,
  #resultTable th:first-child {
    max-width: 120px;
  }
}

@media (max-width: 360px) {
  #resultTable td:first-child,
  #resultTable th:first-child {
    max-width: 96px;
  }
}

/* € en bedrag op één lijn */
#resultTable td b {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* Utility spacing / layout */
.mt-14 {
  margin-top: 14px;
}

.mt-18 {
  margin-top: 18px;
}

.mt-8 {
  margin-top: 8px;
}

.flex-1-200 {
  flex: 1 1 200px;
}

.flex-1-160 {
  flex: 1 1 160px;
}

.flex-0-130 {
  flex: 0 0 130px;
}

.flex-1-220 {
  flex: 1 1 220px;
}

/* used for pitstop inputs */
.flex-1-180 {
  flex: 1 1 180px;
}

/* row helpers */
.row-center {
  align-items: center;
}

.row-gap-12 {
  gap: 12px;
}

.row-gap-8 {
  gap: 8px;
}

.overflow-auto {
  overflow: auto;
}

/* width utilities for inputs */
.w-180 {
  width: 180px;
}

.w-110 {
  width: 110px;
}

/* footer link */
.kb-link {
  text-decoration: none;
  color: rgb(0, 92, 189);
}

/* helper to hide elements */
.hidden {
  display: none;
}

/* Notifications / toasts */
.notify-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.notify-item {
  background: #151823;
  border-radius: 10px;
  padding: 9px 11px;
  border: 1px solid #283149;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  animation: notify-in 0.18s ease-out forwards;
}

.notify-item::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 100%;
  border-radius: 999px;
  background: #5b9cff;
}

/* Variants */
.notify-item.info::before {
  background: #5b9cff;
}
.notify-item.success::before {
  background: #3ddc97;
}
.notify-item.error::before {
  background: #ef476f;
}
.notify-item.warn::before {
  background: #ffd166;
}

.notify-item.leaving {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* slide-in anim */
@keyframes notify-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Clickable title link */
.kb-title-link {
  color: inherit;
  text-decoration: none;
}
.kb-title-link:hover {
  color: var(--acc);
}

/* Login row under subtitle (guest) */
.header-login-row {
  margin-top: 8px;
}

/* Inline form so the button behaves like a normal button row item */
.inline-form {
  margin: 0;
}