/* =====================================================================
   Events (events.html): Rennwochenenden eines Teams. Baut auf portal.css auf (Farben, Knöpfe, Karten).
   ===================================================================== */

.ev-page .s-main { max-width: 1320px; }
.ev-page h2 { font-size: 18px; margin: 0; }
.ev-page h3 { margin: 0; }
.ev-page .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ev-page .s-err:empty { display: none; }
.ev-page hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------------------------------------------------------------- Liste */
.ev-home { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.ev-new { margin: 0; max-width: none; position: sticky; top: 84px; }
.ev-new .s-form { border-radius: var(--r-lg); }
.ev-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ev-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.ev-empty { padding: 22px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); }

.ev-card {
  position: relative; display: grid; gap: 6px; padding: 18px 18px 16px; border-radius: var(--r-lg);
  background: var(--panel); border: 1px solid var(--line); color: inherit !important; text-decoration: none;
  overflow: hidden; transition: border-color .15s, transform .15s;
}
.ev-card::before { /* Zielflagge oben rechts */
  content: ""; position: absolute; right: 0; top: 0; width: 64px; height: 18px; background: var(--checker); opacity: .07;
}
.ev-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.ev-card.live { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 25%, transparent) inset; }
.ev-card.past { opacity: .72; }
.ev-card h3 { font-size: 20px; line-height: 1.2; }
.ev-card p { margin: 0; }
.ev-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; min-height: 22px; }
.ev-team { font-size: 12px; font-weight: 700; color: var(--team); letter-spacing: .04em; text-transform: uppercase; }
.ev-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }

.ev-live {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--red) 18%, var(--panel-3)); color: #ffb3ad; font: 700 11px/1.6 var(--f-ui); letter-spacing: .06em;
}
.ev-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: ev-pulse 1.4s ease-in-out infinite; }
@keyframes ev-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .ev-live::before { animation: none; } }
.ev-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--panel-3); color: var(--muted); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.ev-tag.ok { color: var(--green); }
.ev-tag.bad { color: var(--err); }

/* ---------------------------------------------------------------- ein Event: Kopf */
.ev-back { display: inline-block; margin-bottom: 10px; font-size: 13.5px; font-weight: 600; }
.ev-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 28px; align-items: end;
  padding: 22px 24px; border-radius: 22px; background:
    linear-gradient(120deg, color-mix(in srgb, var(--team) 10%, var(--panel)), var(--panel) 55%);
  border: 1px solid var(--line); margin-bottom: 14px; position: relative; overflow: hidden;
}
.ev-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--team), transparent 60%); }
.ev-hero h1 { font-size: clamp(26px, 3.4vw, 40px); line-height: 1.05; margin: 2px 0 6px; }
.ev-hero p { margin: 0; }
.ev-hero-sub { font-size: 15.5px; color: var(--text); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px !important; }
.ev-count { padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--team) 16%, var(--panel-3)); font: 700 12.5px/1.6 var(--f-mono); }
.ev-now { display: grid; gap: 4px; min-width: 260px; max-width: 340px; padding: 14px 16px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line-2); }
.ev-now.live { border-color: color-mix(in srgb, var(--red) 50%, var(--line-2)); }
.ev-now b { font-size: 18px; }
.ev-now .row { margin-top: 6px; }
.ev-now-k { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.ev-now.live .ev-now-k { color: #ffb3ad; }

.ev-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.ev-tabs::-webkit-scrollbar { display: none; }
.ev-tabs button {
  appearance: none; border: 0; background: none; color: var(--muted); font: 600 14.5px var(--f-ui); padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.ev-tabs button:hover { color: var(--text); }
.ev-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--team); }
.ev-tabs button:focus-visible { outline: 2px solid var(--team); outline-offset: -2px; }

.ev-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ev-side { display: grid; gap: 16px; }
.ev-card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.ev-page .p-card > .small.muted { margin: 0 0 14px; max-width: 80ch; }

/* ---------------------------------------------------------------- Ablauf */
.ev-sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ev-ses {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--k, var(--team));
}
.ev-ses.live { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); border-left-color: var(--red); background: color-mix(in srgb, var(--red) 6%, var(--panel-2)); }
.ev-ses.editing { display: block; border-left-color: var(--team); }
.ev-ses-k {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--k) 18%, var(--panel-3)); color: var(--k); font: 700 14px var(--f-mono);
}
.ev-ses-t { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 15.5px; }
.ev-ses-act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ev-ses-notes { margin-top: 4px; color: var(--text); opacity: .85; }
.ev-dl { margin: 6px 0 12px; display: grid; gap: 1px; background: var(--line); border-radius: 12px; overflow: hidden; }
.ev-dl > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 9px 12px; background: var(--panel-2); }
.ev-dl dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.ev-dl dd { margin: 0; font-weight: 700; font-size: 14px; }
.ev-notes { padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-size: 14px; margin-bottom: 10px; }

.ev-form { display: grid; gap: 12px; }
.ev-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ev-form textarea { resize: vertical; min-height: 90px; font: inherit; }

/* ---------------------------------------------------------------- Autos */
.ev-cars { display: grid; gap: 10px; }
.ev-car {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: start;
  padding: 14px 16px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--c);
}
.ev-car.editing { display: block; border-left-color: var(--team); }
.ev-car-no {
  width: 64px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 22%, var(--panel-3)); font: 700 22px var(--f-mono); color: var(--text);
}
.ev-car-t { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 16px; }
.ev-cls { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 30%, var(--panel-3)); }
.ev-car-ppl { display: grid; gap: 6px; margin-top: 10px; }
.ev-car-ppl > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ev-lab { width: 120px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ev-person { display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 10px; border-radius: 999px; background: var(--panel-3); font-size: 13px; font-weight: 600; }
.ev-person small { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.ev-person.eng { background: color-mix(in srgb, var(--team) 14%, var(--panel-3)); }
.ev-ord { font: 700 11px var(--f-mono); color: var(--dim); margin-right: -2px; }
.ev-pick { border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.ev-pick legend { padding: 0 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.ev-chk { display: inline-flex !important; grid-auto-flow: column; align-items: center; gap: 6px !important; padding: 5px 10px; border-radius: 999px; background: var(--panel-3); cursor: pointer; color: var(--text) !important; }
.ev-chk input { accent-color: var(--team); }
.ev-chk small { color: var(--muted); }
.ev-chk i { font: 700 11px var(--f-mono); font-style: normal; color: var(--team); }
.ev-chk:has(input:checked) { background: color-mix(in srgb, var(--team) 20%, var(--panel-3)); }

/* ---------------------------------------------------------------- Dateien */
.ev-fgroup { margin-top: 14px; padding-left: 12px; border-left: 3px solid var(--c); }
.ev-fgroup h3 { font-size: 15px; margin-bottom: 8px; }
.ev-ftable td:first-child { white-space: normal; min-width: 180px; }
.ev-drop {
  display: grid !important; place-items: center; text-align: center; padding: 22px 12px; border-radius: 14px; cursor: pointer;
  border: 1.5px dashed var(--line-2); background: var(--panel-2); color: var(--text) !important; position: relative;
}
.ev-drop.over, .ev-drop:hover { border-color: var(--team); background: color-mix(in srgb, var(--team) 6%, var(--panel-2)); }
.ev-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------------------------------------------------------------- Daten */
.ev-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.ev-chip {
  appearance: none; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); border-radius: 999px;
  padding: 5px 12px; font: 600 13px var(--f-ui); cursor: pointer; border-left: 3px solid var(--k);
}
.ev-chip small { color: var(--muted); font-family: var(--f-mono); margin-left: 4px; }
.ev-chip.on { background: color-mix(in srgb, var(--k) 20%, var(--panel-3)); border-color: var(--k); }
.ev-chip[disabled] { opacity: .4; cursor: default; }
.ev-dcar { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.ev-dcar:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.ev-dcar h3 { font-size: 17px; display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.ev-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ev-tiles > div { padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); display: grid; gap: 1px; }
.ev-tiles span { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.ev-tiles b { font: 700 18px/1.25 var(--f-mono); }
.ev-tiles small { color: var(--muted); font-size: 12px; min-height: 1em; }
.ev-dtable td.pb { color: var(--purple); font-weight: 700; }
.ev-dtable tr.inv td { opacity: .55; }
.ev-dtable tr.inv td.mono:nth-child(4) { text-decoration: line-through; color: var(--err); }
.ev-laps { margin-top: 10px; }
.ev-laps summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 6px 0; }

/* ---------------------------------------------------------------- Meldeliste */
.ev-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px 16px; margin: 14px 0 0; }
.ev-roles dt { font-weight: 700; color: var(--text); }
.ev-roles dd { margin: 0; }

/* ---------------------------------------------------------------- Öffnen ohne Schlüssel, Meldung */
.ev-unlock { display: grid; place-items: center; padding: 8vh 0; }
.ev-unlock-card { width: min(440px, 100%); }
.ev-toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; width: min(640px, calc(100% - 32px));
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 16px;
  background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); font-size: 14px;
}
.ev-toast > div { flex: 1; }
.ev-toast[hidden] { display: none; }

@media (max-width: 1060px) {
  .ev-home, .ev-cols { grid-template-columns: 1fr; }
  .ev-new { position: static; }
  .ev-hero { grid-template-columns: 1fr; }
  .ev-now { max-width: none; }
}
@media (max-width: 640px) {
  .ev-ses { grid-template-columns: 36px minmax(0, 1fr); }
  .ev-ses-k { width: 36px; height: 36px; }
  .ev-ses-act { grid-column: 1 / -1; justify-content: flex-start; }
  .ev-car { grid-template-columns: 52px minmax(0, 1fr); }
  .ev-car-no { width: 52px; height: 44px; font-size: 18px; }
  .ev-car-act { grid-column: 1 / -1; }
  .ev-lab { width: 100%; }
  .ev-2 { grid-template-columns: 1fr; }
  .ev-hero { padding: 18px 16px; }
}

/* ---------------------------------------------------------------- Setup-Verlauf (Agenda) */
.ev-agenda { list-style: none; margin: 6px 0 0; padding: 0; position: relative; }
.ev-agenda::before { content: ""; position: absolute; left: 131px; top: 6px; bottom: 6px; width: 2px; background: var(--line-2); }
.ag { position: relative; display: grid; grid-template-columns: 120px 24px minmax(0, 1fr); gap: 0; align-items: start; padding: 6px 0; }
.ag-t { font: 600 12.5px/1.4 var(--f-mono); color: var(--muted); text-align: right; padding: 4px 8px 0 0; }
.ag-dot { justify-self: center; margin-top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line-2); position: relative; z-index: 1; }
.ag-body { min-width: 0; }
.ag-ses .ag-dot { border-color: var(--k); background: var(--k); width: 10px; height: 10px; margin-top: 7px; }
.ag-ses .ag-body { padding: 3px 0; color: var(--muted); }
.ag-ses .ag-body b { color: var(--text); }
.ag-switch .ag-dot { border-style: dashed; border-color: var(--team); }
.ag-switch .ag-body { padding-top: 4px; color: var(--muted); }
.ag-setup .ag-dot { width: 16px; height: 16px; margin-top: 12px; border-color: var(--team); background: color-mix(in srgb, var(--team) 25%, var(--panel)); }
.ag-setup.cur .ag-dot { background: var(--team); box-shadow: 0 0 10px var(--team); }
.ag-setup .ag-body { padding: 12px 14px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); }
.ag-setup.cur .ag-body { border-color: color-mix(in srgb, var(--team) 50%, var(--line)); }
.ag-setup .ag-t { padding-top: 12px; }
.ag-h { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.ag-h b { font-size: 15.5px; overflow-wrap: anywhere; }
.ag-nr { font: 700 11px var(--f-mono); padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--team) 18%, var(--panel-3)); color: var(--team); }
.ag-note { margin: 6px 0 0; font-size: 14px; }
.ag-laps { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 10px; }
.ag-laps > div { padding: 6px 9px; border-radius: 10px; background: var(--panel-3); min-width: 0; }
.ag-laps > div.wide { grid-column: span 2; }
.ag-laps span { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ag-laps b { font: 700 14px/1.3 var(--f-mono); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-laps .wide b { font-family: var(--f-ui); }
.ag-laps b.pb { color: var(--purple); }
.ag-laps p { margin: 0; grid-column: 1 / -1; }
.ag-act { margin-top: 10px; }
.ag-diff { margin-top: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.ag-diff label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ag-diff select { width: 100%; max-width: 520px; min-width: 0; }
.ag-dtable td.old { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--red) 60%, transparent); }
.ag-dtable td.new { color: var(--text); font-weight: 700; }
@media (max-width: 640px) {
  .ev-agenda::before { left: 7px; }
  .ag { grid-template-columns: 16px minmax(0, 1fr); }
  .ag-t { grid-column: 2; text-align: left; padding: 0 0 2px; order: -1; }
  .ag-dot { grid-row: 1 / span 2; grid-column: 1; }
  .ag-body { grid-column: 2; }
}
/* Setups aus dem Teambereich übernehmen */
.ev-tpick { display: grid; gap: 6px; max-height: 300px; overflow: auto; }
.ev-tpick .ev-chk { display: flex !important; align-items: flex-start; gap: 10px !important; border-radius: 12px; padding: 8px 12px; }
.ev-tpick .ev-chk input { margin-top: 3px; }
.ev-tpick .ev-chk span { display: grid; gap: 2px; min-width: 0; }
.ev-tpick .ev-chk b { overflow-wrap: anywhere; }
/* Teamordner im Event */
.ev-fmain { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.ev-fmain > * { min-width: 0; }
.ev-tfold .ev-tbar { margin: 6px 0 10px; }
.ev-tlist { max-height: 460px; overflow: auto; }
.ev-tlist tr.ev-tin td { opacity: .75; }
.ev-tlist td:first-child input { accent-color: var(--team); }
.ev-tlist th:first-child, .ev-tlist td:first-child { width: 34px; }
