@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("../fonts/chakra-petch-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("../fonts/chakra-petch-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("../fonts/chakra-petch-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #070506;
  --bg-deep: #040304;
  --surface: #10090c;
  --surface-2: #160d11;
  --surface-3: #1d1116;
  --paper: #f8f3f4;
  --muted: #b8abb0;
  --muted-2: #8b7d82;
  --red: #df2531;
  --red-hot: #ff4b56;
  --red-soft: rgba(223, 37, 49, 0.13);
  --red-line: rgba(223, 37, 49, 0.42);
  --red-deep: #780f17;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.17);
  --ok: #69d8a0;
  --warn: #f0bd5c;
  --error: #ff7d85;
  --font-display: "Chakra Petch", "Arial Narrow", sans-serif;
  --font-body: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-card: 0 24px 70px rgba(0, 0, 0, 0.27);
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 55% 40% at 88% 0%, rgba(223, 37, 49, 0.16), transparent 68%),
    radial-gradient(ellipse 42% 38% at 0% 65%, rgba(223, 37, 49, 0.055), transparent 70%),
    var(--bg);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse at 55% 0%, #000 0%, transparent 72%);
}

::selection {
  background: rgba(223, 37, 49, 0.45);
  color: #fff;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.12;
}

h1 { font-size: clamp(1.7rem, 2.6vw, 2.35rem); letter-spacing: -0.025em; }
h2 { font-size: 1.22rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; }

p { margin: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--red-hot);
  outline-offset: 3px;
}

.ui-icon {
  flex: 0 0 auto;
  display: block;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--paper);
  color: #111;
  transform: translateY(-160%);
  transition: transform 160ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--red);
}

/* Shell ------------------------------------------------------------------ */
.admin-shell {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 17px 18px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(18, 10, 13, 0.92), rgba(7, 5, 6, 0.96)),
    var(--bg-deep);
  overflow: hidden;
}

.admin-sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 210px;
  background: linear-gradient(180deg, var(--red-line), transparent);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(223, 37, 49, 0.55);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(223, 37, 49, 0.24), transparent 70%);
  color: var(--red-hot);
  box-shadow: 0 0 0 5px rgba(223, 37, 49, 0.045);
}

.brand-mark svg { width: 27px; height: 27px; }

.brand-copy {
  display: flex;
  flex-direction: column;
  font-family: var(--font-display);
  line-height: 1;
}

.brand-copy strong { font-size: 1.15rem; letter-spacing: -0.01em; }
.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.sidebar-event {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 25px 3px 20px;
  padding: 13px 12px 12px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--red);
  border-radius: 0 10px 10px 0;
  background: linear-gradient(110deg, rgba(223, 37, 49, 0.09), rgba(255, 255, 255, 0.018));
}

.sidebar-label,
.nav-label {
  color: var(--muted-2);
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sidebar-event strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-event > span:not(.sidebar-label) {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-event a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: var(--red-hot);
  font-size: 0.74rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-event.is-empty {
  border-left-color: var(--line-strong);
}

.sidebar-event.is-empty a { color: var(--paper); }

.admin-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding-right: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.nav-label {
  margin: 13px 10px 5px;
}

.nav-label:first-child { margin-top: 0; }

.admin-nav a,
.nav-disabled {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.admin-nav a:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--paper);
}

.admin-nav a.active {
  border-color: rgba(223, 37, 49, 0.24);
  background: linear-gradient(90deg, rgba(223, 37, 49, 0.16), rgba(223, 37, 49, 0.03));
  color: var(--paper);
  box-shadow: inset 2px 0 0 var(--red);
}

.admin-nav a.active .ui-icon { color: var(--red-hot); }

.nav-disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 15px;
  padding: 15px 10px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-version {
  color: var(--muted-2);
  font-size: 0.67rem;
}

.admin-main {
  min-width: 0;
  padding: 27px clamp(18px, 3vw, 42px) 50px;
}

.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  max-width: 1480px;
  margin: 0 auto 23px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.title-block h1 { margin-top: 1px; }

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.event-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 330px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 9, 12, 0.84);
  color: var(--paper);
  font-size: 0.79rem;
  text-decoration: none;
}

.event-pill:hover { border-color: var(--line-strong); }
.event-pill-name {
  overflow: hidden;
  max-width: 180px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-pill.is-empty { color: var(--muted); }

.live-dot,
.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(223, 37, 49, 0.13);
}

.status-dot {
  background: var(--muted-2);
  box-shadow: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 5px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 9, 12, 0.68);
}

.user-avatar {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
}

.user-copy {
  display: flex;
  flex-direction: column;
  max-width: 180px;
  line-height: 1.15;
}

.user-copy strong {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy small {
  color: var(--muted-2);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 120ms var(--ease-out);
}

.icon-button:hover { background: rgba(255, 255, 255, 0.07); color: var(--paper); }
.icon-button:active { transform: scale(0.94); }

.admin-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
}

/* Surfaces --------------------------------------------------------------- */
.panel,
.overview-card,
.setup-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(25, 14, 18, 0.9), rgba(10, 6, 8, 0.94)),
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.028), var(--shadow-card);
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-head p { margin-top: 4px; }
.panel-head h2 { margin-top: 1px; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.text-link:hover { color: var(--paper); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}

.content-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.narrow-panel { max-width: 940px; }
.side-panel h2 { margin-bottom: 12px; }

.side-links {
  display: grid;
  gap: 0;
}

.side-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.side-links a::after {
  content: "→";
  color: var(--red-hot);
  font-family: var(--font-display);
  opacity: 0.6;
}

.side-links a:hover { color: var(--paper); }

/* Tables ----------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.11);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: rgba(255, 255, 255, 0.026);
  color: var(--muted-2);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.027); }
tr:last-child td { border-bottom: 0; }
tr.row-active { background: rgba(223, 37, 49, 0.075); }
tr.row-error { background: rgba(255, 125, 133, 0.06); }

td small {
  display: block;
  margin-top: 1px;
  color: var(--muted-2);
  font-size: 0.7rem;
}

td a,
.table-primary {
  color: var(--paper);
  font-weight: 500;
  text-decoration: none;
}

td a:hover,
.table-primary:hover { color: var(--red-hot); }

td.bib,
.bib {
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

/* Badges ----------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-live,
.badge-running {
  border-color: rgba(223, 37, 49, 0.52);
  background: rgba(223, 37, 49, 0.17);
  color: #ff9ba2;
}

.badge-published,
.badge-confirmed,
.badge-active,
.badge-finished {
  border-color: rgba(105, 216, 160, 0.34);
  background: rgba(105, 216, 160, 0.08);
  color: var(--ok);
}

.badge-cancelled,
.badge-withdrawn,
.badge-disqualified,
.badge-inactive {
  border-color: rgba(240, 189, 92, 0.34);
  background: rgba(240, 189, 92, 0.075);
  color: var(--warn);
}

.badge-draft,
.badge-registered,
.badge-scheduled,
.badge-assigned {
  color: var(--muted);
}

/* Alerts ----------------------------------------------------------------- */
.alerts {
  display: grid;
  gap: 6px;
  max-width: 1480px;
  margin: 0 auto 16px;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 7px;
  background: rgba(18, 11, 14, 0.82);
  color: var(--muted);
  font-size: 0.84rem;
}

.alert .ui-icon { margin-top: 1px; }
.alert-success { border-left-color: var(--ok); color: #b8efd2; }
.alert-error { border-left-color: var(--error); color: #ffc1c5; }
.alert-warning { border-left-color: var(--warn); color: #f8d99a; }
.alert-info { border-left-color: #7ab8ff; }

/* Empty state ------------------------------------------------------------ */
.empty-state {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 190px;
  padding: 36px 20px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  background: radial-gradient(circle at 50% 50%, rgba(223, 37, 49, 0.045), transparent 58%);
}

.empty-state::before,
.empty-state::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(223, 37, 49, 0.1);
  border-radius: 50%;
  pointer-events: none;
}

.empty-state::before { width: 300px; height: 300px; }
.empty-state::after { width: 190px; height: 190px; }
.empty-state > * { position: relative; z-index: 1; }

.empty-state.compact {
  flex-direction: row;
  min-height: 0;
  justify-content: flex-start;
  padding: 18px;
  text-align: left;
}

.empty-state.compact::before,
.empty-state.compact::after { display: none; }

.empty-state p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
}

.empty-state .btn { margin-top: 5px; }
.empty-state.compact .btn { margin-left: auto; margin-top: 0; }

.empty-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: rgba(223, 37, 49, 0.1);
  color: var(--red-hot);
}

.empty-state.compact strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.9rem;
}

/* Forms ------------------------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label,
.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.79rem;
}

.span-2 { grid-column: span 2; }

input,
select,
textarea {
  width: 100%;
  min-height: 39px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: #0c080a;
  color: var(--paper);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input::placeholder,
textarea::placeholder { color: #695d61; }

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(223, 37, 49, 0.75);
  box-shadow: 0 0 0 3px rgba(223, 37, 49, 0.12);
}

textarea { resize: vertical; }

input[type="file"] {
  padding: 8px;
  color: var(--muted);
}

small { color: var(--muted-2); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
}

.compact-form { gap: 10px; }

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.readout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.82rem;
}

.readout span { color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 9px;
  margin-bottom: 14px;
}

.toolbar input[type="search"] { max-width: 440px; }
.toolbar-large input[type="search"] { max-width: 520px; }
.toolbar label { min-width: 200px; }

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.lane-form input {
  width: 64px;
  min-height: 29px;
  padding: 4px 7px;
}

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms var(--ease-out);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  border-color: rgba(255, 96, 106, 0.45);
  background: linear-gradient(180deg, #ef3440, #c71d29);
  color: #fff;
  box-shadow: 0 7px 20px rgba(223, 37, 49, 0.19);
}

.btn-primary:hover { background: linear-gradient(180deg, #ff4b56, #d92330); }

.btn-secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.025);
  color: var(--paper);
}

.btn-secondary:hover { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.06); }

.btn-danger {
  border-color: rgba(255, 125, 133, 0.38);
  background: transparent;
  color: var(--error);
}

.btn-danger:hover { background: rgba(255, 125, 133, 0.09); }

.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--paper); }

.btn-small {
  min-height: 29px;
  padding: 4px 8px;
  font-size: 0.71rem;
}

.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* Search ----------------------------------------------------------------- */
.search-result {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(223, 37, 49, 0.07), rgba(255, 255, 255, 0.018));
}

.search-number {
  display: grid;
  min-height: 130px;
  place-items: center;
  border: 1px solid rgba(223, 37, 49, 0.52);
  border-radius: 11px;
  background: radial-gradient(circle at 50% 45%, rgba(223, 37, 49, 0.18), rgba(223, 37, 49, 0.04));
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.search-data h2 { margin-bottom: 12px; }

.search-data dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0 0 16px;
}

.search-data dt {
  color: var(--muted-2);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.search-data dd { margin: 2px 0 0; font-size: 0.9rem; }

/* Import ----------------------------------------------------------------- */
.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 16px;
}

.upload-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
}

.upload-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.upload-label strong { font-family: var(--font-display); font-size: 0.9rem; }
.upload-label span { color: var(--muted); font-size: 0.78rem; }
.upload-label input { margin-top: 8px; }

.import-help {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
}

.check-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.check-list li { margin-bottom: 4px; }

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.mapping-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.79rem;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.preview-table table { font-size: 0.78rem; }
.preview-table th,
.preview-table td { padding: 8px 9px; }

.error-list,
.warning-list {
  margin: 0;
  padding-left: 15px;
}

.error-list { color: var(--error); }
.warning-list { color: var(--warn); }
.ok { color: var(--ok); }

/* Stacked links ---------------------------------------------------------- */
.stack-list { display: grid; gap: 0; }
.stack-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.stack-item strong { font-family: var(--font-display); font-size: 0.82rem; }
.stack-item span { color: var(--muted); font-size: 0.76rem; }
.stack-item small { color: var(--muted-2); font-size: 0.7rem; }

/* Login ----------------------------------------------------------------- */
.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 45% 55% at 80% 15%, rgba(223, 37, 49, 0.18), transparent 68%),
    var(--bg);
}

.login-wrap { width: min(100%, 430px); }

.login-card {
  position: relative;
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(28, 15, 20, 0.96), rgba(8, 5, 6, 0.98));
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.42);
}

.login-card::before {
  content: "";
  position: absolute;
  top: -110px;
  right: -100px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(223, 37, 49, 0.22);
  border-radius: 50%;
  pointer-events: none;
}

.login-brand { margin-bottom: 24px; padding: 0; }
.login-card h1 { margin: 4px 0 6px; }
.login-card .muted { margin-bottom: 18px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 0.78rem; }
.login-foot a { color: var(--muted); }

/* Timer ------------------------------------------------------------------ */
.timer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.timer-panel { overflow: hidden; }

.timer-app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border: 1px solid rgba(223, 37, 49, 0.25);
  border-radius: 10px;
  background:
    radial-gradient(ellipse 70% 150% at 80% 50%, rgba(223, 37, 49, 0.14), transparent 70%),
    #0b0709;
}

.timer-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.timer-label {
  color: var(--muted-2);
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.timer-display {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: clamp(3rem, 7.4vw, 5.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1;
  text-shadow: 0 0 40px rgba(223, 37, 49, 0.18);
}

.timer-state {
  margin-top: 4px;
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
}

.timer-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.timer-button {
  min-width: 108px;
  min-height: 64px;
}

.timer-sync {
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.76rem;
}

.timer-hint {
  margin-top: 12px;
  line-height: 1.5;
}

.arrival-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.arrival-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.arrival-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.arrival-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.arrival-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 64px;
  padding: 10px;
}

.arrival-button.is-captured {
  border-color: var(--ok);
  color: var(--ok);
}

.arrival-index {
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
}

.arrival-time {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: center;
}

.time-edit {
  width: 100%;
  min-width: 120px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #0c080a;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.time-edit:focus {
  border-color: var(--red-line);
  outline: none;
}

.time-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 700px) {
  .arrival-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .arrival-grid {
    grid-template-columns: 1fr;
  }
}

.obs-url {
  display: block;
  margin: 10px 0;
  padding: 9px 10px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c080a;
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 0.7rem;
}

.next-heat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 18px 0;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.next-heat a {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-decoration: none;
}

.next-heat a:hover { color: var(--red-hot); }

.timer-results { margin-top: 4px; }
.timer-results th:first-child,
.timer-results td:first-child { width: 68px; }

.podium-index {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid rgba(223, 37, 49, 0.42);
  border-radius: 50%;
  background: rgba(223, 37, 49, 0.1);
  color: var(--red-hot);
  font-family: var(--font-display);
  font-weight: 700;
}

.bib-input {
  width: 92px;
  min-height: 36px;
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.athlete-cell {
  display: flex;
  min-width: 190px;
  flex-direction: column;
  gap: 1px;
}

.athlete-cell strong { font-size: 0.84rem; font-weight: 500; }
.athlete-cell small { font-size: 0.7rem; }

.time-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 190px;
}

.result-time {
  min-width: 92px;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.row-state {
  display: inline-flex;
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.66rem;
  white-space: nowrap;
}

.row-state-ready {
  border-color: rgba(105, 216, 160, 0.34);
  color: var(--ok);
}

.form-message {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.form-message.is-ok { color: var(--ok); }
/* Responsive ------------------------------------------------------------- */
@media (max-width: 1120px) {
  .overview-card { grid-template-columns: minmax(0, 1fr) 290px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid,
  .content-grid.two,
  .import-layout { grid-template-columns: minmax(0, 1fr); }
  .mapping-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .admin-shell { display: block; }
  .admin-sidebar {
    position: static;
    height: auto;
    padding: 15px 16px 13px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .admin-sidebar::after { display: none; }
  .sidebar-event { display: none; }
  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 12px;
    padding-bottom: 3px;
    overflow: visible;
  }
  .admin-nav .nav-label { display: none; }
  .admin-nav a,
  .nav-disabled {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 5px 8px;
    border-color: transparent;
    border-radius: 6px;
    white-space: nowrap;
  }
  .admin-nav a.active { box-shadow: none; border-color: rgba(223, 37, 49, 0.3); }
  .sidebar-footer { display: none; }
  .admin-main { padding: 21px 16px 38px; }
  .admin-topbar { align-items: flex-start; }
}

@media (max-width: 760px) {
  .admin-topbar { flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .event-pill { max-width: calc(100% - 52px); }
  .overview-card { grid-template-columns: 1fr; }
  .overview-visual { display: none; }
  .overview-copy { padding: 23px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .search-result { grid-template-columns: 1fr; }
  .search-data dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapping-grid { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .empty-state.compact { flex-wrap: wrap; }
  .empty-state.compact .btn { margin-left: 48px; }
}

@media (max-width: 540px) {
  .stats-grid,
  .quick-grid,
  .setup-steps { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .user-copy { display: none; }
  .search-data dl { grid-template-columns: 1fr; }
  .login-card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  .btn:active,
  .quick-link:hover > .ui-icon:last-child { transform: none; }
}

/* Unified timer ----------------------------------------------------------- */
.timer-selector-panel { margin-bottom: 16px; }

.test-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.test-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.test-tab:hover,
.test-tab.active {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--paper);
}

.battery-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.battery-form label {
  flex: 1 1 260px;
  min-width: 0;
}

.battery-form select {
  width: 100%;
  min-height: 48px;
}

.battery-participants {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.battery-participants summary {
  color: var(--paper);
  cursor: pointer;
}

.battery-participants ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
  max-height: 160px;
  margin: 8px 0 0;
  padding-left: 18px;
  overflow-y: auto;
}

.battery-participants .bib {
  color: var(--red-hot);
  font-family: var(--font-display);
  font-weight: 600;
}

.timer-capture {
  display: flex;
  flex: 2 1 260px;
  min-height: 96px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 20px;
  font-size: 0.86rem;
  letter-spacing: 0.1em;
}

.timer-capture strong {
  color: var(--red-hot);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.timer-capture:disabled strong { color: var(--muted); }

.arrival-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.arrival-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.015);
}

.arrival-row span {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.arrival-row output {
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.arrival-row.is-captured {
  border-color: rgba(105, 216, 160, 0.34);
}

.arrival-row.is-captured output { color: var(--ok); }

@media (max-width: 760px) {
  .test-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .test-tab { min-height: 56px; padding: 8px 6px; font-size: 0.75rem; }
  .battery-form { align-items: stretch; }
  .battery-form label { flex-basis: 100%; }
  .battery-participants ul { grid-template-columns: 1fr; }
  .timer-layout { grid-template-columns: 1fr; }
  .timer-aside { display: none; }
  .timer-app { padding: 14px; gap: 14px; }
  .timer-display { font-size: clamp(2.7rem, 14vw, 4.5rem); }
  .timer-controls { flex-direction: column; gap: 10px; }
  .timer-button,
  .timer-capture { width: 100%; min-height: 64px; }
  .timer-capture { min-height: 92px; flex-basis: auto; }
  .arrival-list { grid-template-columns: 1fr; }
  .arrival-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .arrival-row output { font-size: 1.2rem; }
}
