/* RaceInfo – neue Oberfläche für Teambereich, Ergebnisse und Verwaltung.
   Livetiming.html benutzt dieses Stylesheet nicht; dort gilt allein racetable.css. */

/* Schrift Barlow, vom eigenen Server (Lizenz: fonts/LICENSE-Barlow.txt) */
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/barlow-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/fonts/barlow-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/fonts/barlow-latin-ext-500-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/fonts/barlow-latin-500-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/fonts/barlow-latin-ext-600-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap;
  src: url(/fonts/barlow-latin-600-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* ---------- Grundwerte ---------- */
:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --text: #1B1F24;
  --muted: #4D5661;
  --line: #E1E4E8;
  --field: #C5CAD1;
  --accent: #D4111E;
  --accent-text: #B00E19;
  --accent-soft: #FBEDEE;
  --radius-card: 14px;
  --radius-field: 12px;
  --header-height: 60px;
  --nav-width: 260px;
  --shadow: 0 1px 2px rgba(27, 31, 36, 0.08);
}

html { font-size: 17px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (min-width: 720px) { html { font-size: 16px; } }

body.app {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1rem;
  line-height: 1.4;
}
.app *, .app *::before, .app *::after { box-sizing: border-box; }
.app button, .app select, .app input, .app textarea { font: inherit; color: inherit; }
.app :focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }

/* ---------- Kopfzeile ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: var(--header-height); padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.app-logo { display: flex; align-items: center; min-height: 44px; }
.app-logo img { display: block; width: auto; height: 28px; max-width: 56vw; mix-blend-mode: multiply; }
.app-back {
  display: flex; align-items: center; gap: 2px; flex: none;
  min-height: 44px; padding-right: 8px;
  color: var(--accent-text); font-weight: 600; text-decoration: none;
}
.app-back svg { width: 20px; height: 20px; }
.app-title {
  flex: 1 1 auto; min-width: 0; margin: 0;
  font-size: 1.15rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-user {
  flex: none; margin-left: auto; padding: 8px 14px; border-radius: 999px;
  background: var(--bg); color: var(--text);
  font-size: 0.9rem; font-weight: 600; white-space: nowrap; text-decoration: none;
}
a.app-user { display: flex; align-items: center; min-height: 44px; color: var(--accent-text); }
.app-page .app-logo { display: none; }

/* ---------- Menü: Kacheln auf der Startseite ---------- */
.app-nav { max-width: 960px; margin: 0 auto; padding: 20px 16px 32px; }
.app-page .app-nav { display: none; }
.app-bewerb { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.app-bewerb label { font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.app .app-bewerb select { width: 100%; max-width: 420px; margin: 0; }
.app-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .app-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .app-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.app .app-tile {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 8px;
  min-height: 96px; padding: 14px;
  border: 0; border-radius: var(--radius-card);
  background: var(--surface); box-shadow: var(--shadow);
  color: var(--text); font-weight: 400; text-align: left; cursor: pointer;
}
.app .app-tile:hover { background: var(--surface); box-shadow: 0 2px 8px rgba(27, 31, 36, 0.14); }
.app-tile-label { font-size: 1.1rem; font-weight: 600; }
.app-tile-sub { font-size: 0.85rem; color: var(--muted); }
.app .app-logout {
  display: block; width: 100%; height: 48px; margin-top: 16px;
  border: 0; background: transparent; color: var(--accent-text); font-weight: 600; cursor: pointer;
}

/* ---------- Menü: Liste links auf Unterseiten am PC ---------- */
@media (min-width: 1024px) {
  body.app-page { padding-left: var(--nav-width); }
  .app-page .app-header { margin-left: calc(-1 * var(--nav-width)); }
  .app-page .app-back { display: none; }
  /* Logo über dem Menü, Seitentitel über dem Inhalt */
  .app-page .app-logo { display: flex; order: -1; flex: 0 0 calc(var(--nav-width) - 12px); }
  .app-page .app-nav {
    display: block; position: fixed; top: var(--header-height); bottom: 0; left: 0;
    width: var(--nav-width); max-width: none; margin: 0; padding: 16px 12px; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .app-page .app-tiles { display: flex; flex-direction: column; gap: 2px; }
  .app-page .app-tile {
    justify-content: center; min-height: 44px; padding: 10px 12px;
    border-radius: 10px; background: transparent; box-shadow: none;
  }
  .app-page .app-tile:hover { background: var(--bg); box-shadow: none; }
  .app-page .app-tile-label { font-size: 1rem; font-weight: 500; }
  .app-page .app-tile-sub { display: none; }
  .app-page .app-tile[aria-current="page"] { background: var(--bg); }
  .app-page .app-tile[aria-current="page"] .app-tile-label { color: var(--accent-text); font-weight: 600; }
  .app-page .app-logout { padding: 0 12px; text-align: left; }
}

/* ---------- Inhalt ---------- */
#mainwindow, .mainwindowpos { padding: 16px; }
#mainwindow > div, .mainwindowpos { max-width: 100%; overflow-x: auto; }
/* Zeitnehmung: .mainwindowpos umschließt den ganzen Editor; die Tabelle rollt selbst seitlich,
   sonst sitzt der Rollbalken erst unter dem Sichern-Knopf (1px rechts: halber Rand der Zellen) */
.mainwindowpos > table.EditRaceTable { display: block; width: max-content; max-width: 100%; padding-right: 1px; overflow-x: auto; }
#mainwindow h1 { margin: 0 0 12px; font-size: 1.4rem; font-weight: 600; }
#headdiv { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
#headdiv h1 { margin: 0; }

/* Knöpfe */
.app button {
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--accent-text); border-radius: var(--radius-field);
  background: var(--surface); color: var(--accent-text); font-weight: 600; cursor: pointer;
}
.app button:hover { background: var(--accent-soft); }
.app .savebutton, .app #saveresult, .app .resultsavebutton, .app .dialogOKbutton {
  min-height: 48px; border-color: var(--accent); background: var(--accent); color: #FFFFFF;
}
.app .savebutton:hover, .app #saveresult:hover, .app .resultsavebutton:hover, .app .dialogOKbutton:hover { background: var(--accent-text); }
.app .savebutton, .app .addrowbutton, .app #driveredit, .app #saveresult { margin: 0 8px 12px 0; }
.app .addrowbutton { min-width: 44px; }
.app .rowbutton {
  width: 44px; min-width: 44px; padding: 0; border: 0;
  background: transparent url(/images/trash.png) center / 22px 22px no-repeat;
}
.app .rowbutton:hover { background-color: var(--accent-soft); }
.app .rowbutton.addtoprot { border: 1px solid var(--accent-text); background-image: none; }

/* Eingabefelder */
.app select, .app input[type="text"], .app input[type="password"], .app input:not([type]) {
  min-height: 44px; padding: 0 12px;
  border: 1px solid var(--field); border-radius: var(--radius-field); background: var(--surface);
}
.app input[type="checkbox"] { width: 22px; height: 22px; margin: 4px 8px; vertical-align: middle; accent-color: var(--accent); }

/* Tabellen */
.app table { border-collapse: collapse; margin: 0 0 16px; background: var(--surface); }
.app th, .app td { padding: 10px 12px; border: 1px solid var(--line); text-align: left; }
.app th { background: var(--bg); font-weight: 600; white-space: nowrap; }
.app tr.even td { background: #FAFBFC; }
.app td[contenteditable="true"] { min-width: 3em; background: var(--surface); cursor: text; }
.app td[contenteditable="true"]:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.app td[readonly="true"], .app td[contenteditable="false"] { background: var(--bg); color: var(--muted); }
.app table.rtable th { writing-mode: vertical-rl; text-align: right; vertical-align: bottom; }
.app table.rtable th.Name, .app table.rtable th.Nr { writing-mode: horizontal-tb; text-align: left; }
.app td.Name, .app td.Gesamtpunkte { font-weight: 600; }

/* Dateilisten und PDF */
.app .filebutton {
  display: block; max-width: 720px; min-height: 48px; margin: 0 0 8px; padding: 13px 16px;
  border-radius: var(--radius-field); background: var(--surface); box-shadow: var(--shadow);
  font-weight: 600; overflow-wrap: anywhere; cursor: pointer;
}
/* die Dateiknöpfe sind div direkt in #mainwindow; sonst gilt dort max-width: 100% */
#mainwindow > .filebutton { max-width: 720px; }
.app .filebutton:hover { color: var(--accent-text); }
.app .Files br { display: none; }
.app iframe { display: block; width: 100%; height: 80vh; border: 0; background: var(--surface); }

/* Hinweis für die Zeitnehmung, z. B. Laufname nicht in Rennen.csv */
.app .laufwarnung {
  margin: 0 0 12px; padding: 12px 16px; border-radius: var(--radius-field);
  background: var(--accent-text); color: #FFFFFF; font-weight: 600;
}
.app #runningtext, .app #aktbewerb { margin: 4px 8px 12px; }

/* Resultat hinzu: die Elemente stehen ohne Hülle in der Seite; ab der zweiten Auswahl
   liegen sie in dem Absatz, den das offene <p> nach .restext erzeugt */
.app > .restext + p { margin: 0; }
.app .addresultdd1, .app .addresultdd2 { display: block; width: calc(100% - 32px); max-width: 480px; margin: 16px 16px 0; }
.app > .restext { margin: 16px 16px 0; }
.app .isdriver { display: inline-block; margin: 16px 0 16px 16px; }
.app .resultsavebutton { display: block; margin: 0 16px 16px; }

/* ---------- Meldungsfenster ---------- */
.app .modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(27, 31, 36, 0.5);
}
.app .modal-content {
  width: 100%; max-width: 420px; padding: 20px;
  border-radius: var(--radius-card); background: var(--surface); box-shadow: 0 8px 32px rgba(27, 31, 36, 0.25);
}
.app .modal-content p { margin: 0 0 16px; font-size: 1.05rem; }
.app .modal-content button { min-width: 110px; margin-right: 8px; }
/* Rückfrage „Ist das …?“ (fahrernummern.js): Knöpfe untereinander, auch lange Namen passen aufs Handy */
.app .modal-content.fnr-wahl { display: flex; flex-direction: column; gap: 8px; }
.app .modal-content.fnr-wahl p { margin-bottom: 8px; }
.app .modal-content.fnr-wahl button { margin-right: 0; }

/* ---------- Anmeldung ---------- */
.app-login .app-header { justify-content: center; }
.app-card {
  max-width: 420px; margin: 24px auto; padding: 24px 20px;
  border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow);
}
@media (max-width: 452px) { .app-card { margin: 16px; } }
.app-card-title { margin: 0 0 16px; font-size: 1.4rem; font-weight: 600; }
.app-card p { margin: 0 0 14px; }
.app-card label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.app .app-card input, .app .app-card select { width: 100%; height: 48px; }
.app .app-card button { width: 100%; height: 48px; }
.loginmessage { color: var(--accent-text); font-weight: 600; }

/* ---------- Strafen auf der Ergebnisansicht ---------- */
.penalty-area { margin: 16px 0; padding: 16px; border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); }
.penalty-row { margin: 0 0 8px; }
.penalty-revoked { color: var(--muted); text-decoration: line-through; }
.penalty-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.app .penalty-form input, .app .penalty-form select { height: 44px; }
.app .penalty-revoke { min-height: 32px; padding: 0 8px; }

/* ---------- Eigene Zeitnehmung (Steuerbereich auf /edit/timing) ---------- */
.timing-control { margin: 0 0 16px; padding: 16px; border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); }
.timing-control > div { margin-bottom: 10px; }
.timing-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #B0B0B0; vertical-align: middle; }
.timing-dot.timing-on { background: #2E8B57; }
.timing-dot.timing-off { background: #C0392B; }
.timing-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.app .timing-button { min-height: 44px; }
.app #timing-start, .app #timing-finish { border-color: var(--accent); background: var(--accent); color: #FFFFFF; }
.app .timing-button:disabled { opacity: 0.45; cursor: default; }
.timing-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.app .timing-form input, .app .timing-form select { height: 44px; }
.timing-warning { color: var(--accent-text); font-weight: 600; }
.timing-revoked { color: var(--muted); text-decoration: line-through; }
.timing-row { display: grid; grid-template-columns: 1.2fr 1.2fr 0.8fr 0.6fr 1fr 2fr; gap: 6px; align-items: center; padding: 2px 0; border-bottom: 1px solid var(--accent-soft); }
.timing-head { font-weight: 600; color: var(--muted); }
.app .timing-row .timing-button { min-height: 32px; padding: 0 8px; }
.timing-dot.timing-gruen { background: #2E8B57; }
.timing-dot.timing-gelb { background: #E0A800; }
.timing-dot.timing-rot { background: #C0392B; }
.timing-vergleich { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--accent-soft); }
.timing-vergleich-head { font-weight: 600; }
.timing-vergleich-lauf, .timing-vergleich-hinweis { color: var(--muted); }

/* ---------- Einstellungen (/edit/Einstellungen) ---------- */
.settings { max-width: 880px; }
.settings-intro { margin: 0 0 16px; color: var(--muted); }
.settings-section { margin: 0 0 16px; padding: 16px; border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow); }
.settings-section h2 { margin: 0 0 12px; font-size: 1.15rem; font-weight: 600; }
.settings-section summary { display: flex; align-items: center; min-height: 44px; font-size: 1.15rem; font-weight: 600; cursor: pointer; }
.settings-group { min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.settings-group legend { margin-bottom: 4px; padding: 0; font-weight: 600; color: var(--accent-text); }
.settings-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 6px; }
.settings-label { font-weight: 500; overflow-wrap: anywhere; }
.settings-key { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.settings-stufe { padding: 1px 8px; border-radius: 999px; background: var(--bg); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.settings-stufe-sofort { background: #E6F4EC; color: #1E6B42; }
.settings-stufe-neustart { background: var(--accent-soft); color: var(--accent-text); }
.settings-ohne .settings-label { color: var(--muted); }
.settings-help { margin: 0 0 6px; font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
.app .settings-control input[type="text"], .app .settings-control input[type="password"], .app .settings-control select { width: 100%; max-width: 480px; height: 44px; margin: 0; }
.app input.settings-switch {
  -webkit-appearance: none; appearance: none; position: relative; width: 52px; height: 30px; margin: 0;
  border-radius: 15px; background: var(--field); cursor: pointer; vertical-align: middle; transition: background 0.15s;
}
.app input.settings-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgba(27, 31, 36, 0.3); transition: left 0.15s;
}
.app input.settings-switch:checked { background: var(--accent); }
.app input.settings-switch:checked::after { left: 25px; }
.settings-secret { display: block; margin-bottom: 6px; font-weight: 500; }
.settings-remove { display: flex; align-items: center; min-height: 44px; font-size: 0.875rem; }
.settings-fehler { margin: 4px 0 0; color: var(--accent-text); font-weight: 600; }
.settings-fehler:empty { display: none; }
.app .settings-ungueltig input[type="text"], .app .settings-ungueltig input[type="password"], .app .settings-ungueltig select { border-color: var(--accent); outline: 2px solid var(--accent); }
.settings-trenner { margin: 12px 0; border: 0; border-top: 2px solid var(--line); }
.settings-actions { position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); }
.app .settings-actions .savebutton { margin: 0; }
.settings-message p { margin: 0 0 8px; }
.settings-message ul { margin: 0 0 12px; padding-left: 20px; }
.settings-message a { overflow-wrap: anywhere; color: var(--accent-text); }
.settings-message-fehler p { color: var(--accent-text); font-weight: 600; }
.settings-warnung { color: var(--accent-text); font-weight: 600; }

/* Fahrer und Fahrernennung am Handy, nur für Teams (app.js setzt app-team): ohne Fahrernummer und Team,
   Tabelle in Bildschirmbreite statt seitlich scrollen */
@media (max-width: 719px) {
  .app-team table.DriverTable .Fahrernummer, .app-team table.DriverTable .Team,
  .app-team table.DriverProtTable .Fahrernummer, .app-team table.DriverProtTable .Team,
  .app-team table.DriverAddTable .Fahrernummer, .app-team table.DriverAddTable .Team { display: none; }
  .app-team .mainwindowpos > table.EditTable, .app-team table.EditTable { width: calc(100% - 1px); max-width: 100%; font-size: 13px; }
  .app-team table.EditTable th, .app-team table.EditTable td { padding: 6px 3px; overflow-wrap: anywhere; }
  .app-team table.EditTable th { white-space: normal; }
  .app-team table.EditTable td[contenteditable="true"] { min-width: 0; }
  .app-team table.EditTable .Leicht, .app-team table.EditTable .Schwer, .app-team table.EditTable .Master,
  .app-team table.EditTable .Senior, .app-team table.EditTable .Junior, .app-team table.EditTable .Lady { text-align: center; }
  .app-team table.EditTable th.Leicht, .app-team table.EditTable th.Schwer, .app-team table.EditTable th.Master,
  .app-team table.EditTable th.Senior, .app-team table.EditTable th.Junior, .app-team table.EditTable th.Lady {
    writing-mode: vertical-rl; transform: rotate(180deg); vertical-align: bottom; }
  .app-team table.EditTable td.Rennen select { width: 100%; min-width: 0; max-width: 42vw; padding: 0 4px; }
  .app-team table.EditTable .rowbutton { width: 36px; min-width: 36px; }
  .app-team table.EditTable td:last-child { padding: 2px; }
}

/* Seite Durchfahrten (/edit/Durchfahrten) */
.passings [hidden] { display: none !important; }
.passings-intro { margin: 0 0 12px; color: var(--muted); }
.passings-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.app .passings-bar select, .app .passings-bar input[type=text] { height: 44px; }
.app .passings-button { min-height: 44px; }
.passings-message { min-height: 1.4em; margin: 0 0 8px; }
.passings-error { color: var(--accent-text); font-weight: 600; }
.passings-scroll { overflow-x: auto; margin: 0 0 16px; }
.passings-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.passings-table th, .passings-table td { padding: 4px 8px; border-bottom: 1px solid var(--accent-soft); text-align: left; white-space: nowrap; }
.passings-table th { color: var(--muted); font-weight: 600; }
.passings-grey td { color: var(--muted); }
.passings-unknown td { background: #FFF3B0; }
.app .passings-table .passings-button { min-height: 32px; padding: 0 8px; }
.passings-revoked { color: var(--muted); text-decoration: line-through; }
.passings-warning { color: var(--accent-text); }
