/* =====================================================================
 * style.css — Münnich Motorsport · VBOX Telemetrie-Analyse
 * Markenpalette: schwarz / weiss / grau + Münnich-Rot #E2003D / #A00006
 * Light- & Dark-Theme über  <html data-theme="light|dark">
 * ===================================================================== */
:root {
  --red: #E2003D;
  --red-dark: #A00006;
  --red-soft: rgba(226, 0, 61, 0.10);
  --ink: #13151a;
  --ink-2: #2a2d34;
  --gray: #6b7077;
  --gray-2: #9aa0a6;
  --line: #e6e8eb;
  --line-2: #eef0f2;
  --bg: #f3f4f6;
  --card: #ffffff;
  --card-2: #fafbfc;
  --good: #1f9d4d;

  --topbar-bg: #ffffff;
  --topbar-fg: #13151a;
  --topbar-sub: #9aa0a6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 23, 28, 0.06), 0 1px 3px rgba(20, 23, 28, 0.05);
  --shadow-lg: 0 4px 14px rgba(20, 23, 28, 0.10);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Chart-Farben (von charts.js gelesen) */
  --chart-bg: #ffffff;
  --chart-grid: rgba(0, 0, 0, 0.06);
  --chart-grid-strong: rgba(0, 0, 0, 0.16);
  --chart-text: #54585f;
  --chart-axis: #9aa0a6;
  --chart-ink: #13151a;
  --chart-tip: rgba(255, 255, 255, 0.97);
  --map-bg: #fafafa;
  --speed-slow: 70, 74, 80;
  --speed-mid: 154, 32, 48;
  --speed-fast: 226, 0, 61;
}

:root[data-theme="dark"] {
  --red: #ff2d63;
  --red-dark: #c70030;
  --red-soft: rgba(255, 45, 99, 0.16);
  --ink: #eef1f4;
  --ink-2: #c4c9d0;
  --gray: #99a0a8;
  --gray-2: #6e757e;
  --line: #2a2f38;
  --line-2: #222730;
  --bg: #0d0f13;
  --card: #171a21;
  --card-2: #1d212a;
  --good: #34c46b;

  --topbar-bg: #13161c;
  --topbar-fg: #ffffff;
  --topbar-sub: #8b919a;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.55);

  --chart-bg: #171a21;
  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-grid-strong: rgba(255, 255, 255, 0.16);
  --chart-text: #99a0a8;
  --chart-axis: #6e757e;
  --chart-ink: #eef1f4;
  --chart-tip: rgba(28, 32, 40, 0.97);
  --map-bg: #12151b;
  --speed-slow: 140, 146, 154;
  --speed-mid: 200, 44, 74;
  --speed-fast: 255, 45, 99;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

/* ---------- Topbar ---------- */
.topbar {
  height: 60px;
  background: var(--topbar-bg);
  color: var(--topbar-fg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-top: 3px solid var(--red);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-bar { width: 6px; height: 32px; background: var(--red); display: inline-block; border-radius: 2px; }
.brand-text { line-height: 1.15; letter-spacing: .04em; font-size: 15px; color: var(--topbar-fg); }
.brand-text strong { font-weight: 800; }
.brand-sub { display: block; font-size: 10.5px; color: var(--topbar-sub); letter-spacing: .14em; text-transform: uppercase; margin-top: 2px; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-meta { font-size: 12px; color: var(--topbar-sub); text-align: right; }
.topbar-meta b { color: var(--topbar-fg); font-weight: 600; }

.best-badge { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1;
  padding-left: 14px; border-left: 1px solid var(--line); }
.best-badge .bb-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--topbar-sub); }
.best-badge .bb-val { font-size: 18px; font-weight: 800; color: var(--red); font-variant-numeric: tabular-nums; }

.icon-row { display: flex; gap: 4px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--topbar-fg);
  display: flex; align-items: center; justify-content: center; font-size: 16px; padding: 0;
  transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--card-2); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }

.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line); }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.user-chip .user-text { line-height: 1.15; }
.user-chip .user-text b { display: block; font-size: 13px; color: var(--topbar-fg); }
.user-chip .user-text small { font-size: 11px; color: var(--topbar-sub); }

/* ---------- Layout ---------- */
.layout { display: flex; height: calc(100vh - 60px); }
.sidebar {
  width: 296px; min-width: 296px;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Sidebar ---------- */
.sidebar-head {
  padding: 16px 16px 12px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--gray); margin: 0; }
.sidebar-actions { display: flex; gap: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mini {
  font: inherit; font-size: 11px; font-weight: 600; padding: 4px 11px; cursor: pointer;
  background: transparent; border: none; color: var(--gray); border-right: 1px solid var(--line);
}
.mini:last-child { border-right: none; }
.mini:hover { background: var(--card); color: var(--ink); }
.file-tree { flex: 1; overflow-y: auto; padding: 8px 8px 14px; }
.loading, .empty-hint { color: var(--gray); font-size: 13px; padding: 16px; line-height: 1.5; }

/* Gruppen-Header in der Sidebar: Fahrer › Gerät › Strecke (einklappbar) */
.grp { display: flex; align-items: center; gap: 7px; padding: 5px 8px; margin: 1px 2px; border-radius: 6px; cursor: pointer; user-select: none; }
.grp:hover { background: var(--card-2); }
.grp-tw { flex: 0 0 auto; width: 10px; color: var(--gray-2); font-size: 14px; line-height: 1; text-align: center; transition: transform .15s; transform: rotate(90deg); }
.grp.collapsed .grp-tw { transform: rotate(0deg); }
.grp-ic { flex: 0 0 auto; display: flex; color: var(--gray-2); }
.grp-label { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grp-driver .grp-label { font-size: 12px; }
.grp-device .grp-label, .grp-track .grp-label { font-weight: 600; color: var(--gray); }
.grp-count { flex: 0 0 auto; color: var(--gray-2); font-weight: 700; background: var(--card-2); border: 1px solid var(--line); border-radius: 20px; padding: 0 7px; font-size: 10.5px; }

.file-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; margin: 1px 2px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent;
  box-shadow: inset 3px 0 0 var(--accent, transparent);
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.file-row:hover { background: var(--card-2); }
.file-row.selected { background: var(--card-2); border-color: var(--accent, var(--red)); box-shadow: inset 4px 0 0 var(--accent, var(--red)), var(--shadow); }
.file-row .swatch { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: 0 0 auto; background: var(--accent, var(--gray-2)); opacity: .85; }
.file-main { min-width: 0; flex: 1; }
.file-name { font-weight: 700; font-size: 12.5px; color: var(--ink); }
.file-when { font-weight: 700; font-size: 12px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.file-meta { font-size: 10.5px; color: var(--gray); margin-top: 1px; line-height: 1.3; }
.file-meta .tag { white-space: nowrap; }
.file-meta .tag b { color: var(--ink-2); font-weight: 700; }
/* aufgeräumte, gestapelte Meta-Zeilen (Fahrer · Wann/Wo · Kennzahlen) */
.fm-driver { font-weight: 700; font-size: 11.5px; color: var(--ink-2); }
.fm-line { white-space: normal; }
.fm-ctx { color: var(--ink-2); }
.fm-ctx .fm-evt { font-weight: 700; }
.fm-stats { color: var(--gray); font-variant-numeric: tabular-nums; }
.fm-i { white-space: nowrap; }
.fm-sep { color: var(--gray-2); }
.spinner-mini { font-size: 11px; color: var(--gray-2); }

/* Eigene Checkboxen (rund-eckig mit Haken) */
.file-row input[type=checkbox], .sub-row input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: 0 0 auto; margin: 0;
  width: 17px; height: 17px; border: 1.5px solid var(--gray-2); border-radius: 5px;
  background: var(--card); cursor: pointer; position: relative; transition: background-color .12s, border-color .12s;
}
.file-row input[type=checkbox] { margin-top: 1px; }
.file-row input[type=checkbox]:checked, .sub-row input[type=checkbox]:checked {
  background: var(--accent, var(--red)); border-color: var(--accent, var(--red));
}
.file-row input[type=checkbox]:checked::after, .sub-row input[type=checkbox]:checked::after {
  content: ''; position: absolute; left: 5px; top: 1.5px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* Aufklapp-Pfeil + Unterzeilen (einzelne Runden / Starts) */
.expander {
  font: inherit; font-size: 16px; line-height: 1; cursor: pointer;
  background: none; border: none; color: var(--gray-2);
  padding: 0 2px; margin-left: 4px; flex: 0 0 auto; align-self: center;
  transition: transform .15s, color .15s; transform: rotate(0deg);
}
.expander:hover { color: var(--ink); }
.expander.open { transform: rotate(90deg); color: var(--red); }
.file-children { margin: 0 4px 8px 32px; border-left: 2px solid var(--line); padding-left: 8px; }
.sub-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--gray-2); font-weight: 700; padding: 7px 4px 3px;
}
.sub-row {
  display: flex; align-items: center; gap: 8px; padding: 5px 7px;
  border-radius: 6px; cursor: pointer; font-size: 12px; flex-wrap: wrap;
}
.sub-row:hover { background: var(--card-2); }
.sub-row.selected { background: var(--card-2); box-shadow: inset 2px 0 0 var(--accent, var(--red)); }
.sub-row .sub-swatch { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; visibility: hidden; }
.sub-row.selected .sub-swatch { visibility: visible; }
.sub-row .sub-name { font-weight: 600; color: var(--ink); }
.sub-row .sub-val { margin-left: auto; color: var(--gray); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub-row.best .sub-val { color: var(--red); font-weight: 700; }
.sub-val .delta { font-style: normal; color: var(--gray-2); font-size: 10.5px; font-weight: 400; margin-right: 6px; }
.sub-row .sub-tag {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 1.5px 6px; border-radius: 4px; flex: 0 0 auto;
}
.sub-row .sub-tag.best { color: var(--red); background: var(--red-soft); }
.sub-row .sub-tag.inv { color: var(--gray-2); border: 1px solid var(--line); }
.sub-row.invalid .sub-name, .sub-row.invalid .sub-val { color: var(--gray-2); }
.sub-row.invalid .sub-name { text-decoration: line-through; }
/* Sektor-Chips auf eigener Zeile unter dem Rundennamen (Sidebar ist schmal) */
.sub-sectors { display: inline-flex; gap: 4px; flex-basis: 100%; order: 5; margin-left: 30px; flex-wrap: wrap; }
.sub-sectors .sec {
  font-style: normal; font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--gray); padding: 1px 5px; border-radius: 4px;
  background: var(--card-2); border: 1px solid var(--line);
}
.sub-sectors .sec.best { color: #fff; background: var(--red); border-color: var(--red); font-weight: 600; }
.sub-sectors .sec.na { opacity: .4; }

/* Fahrerfarbe: Punkt in der Tabelle + Farbwähler im Formular */
.md-dvr-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 8px; vertical-align: middle; border: 1px solid rgba(0,0,0,.18); }
.md-dvr-dot.md-dvr-none { background: repeating-linear-gradient(45deg, var(--line-2), var(--line-2) 3px, var(--card) 3px, var(--card) 6px); }
.md-color { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.md-cswatches { display: flex; gap: 5px; flex-wrap: wrap; }
.md-csw { width: 22px; height: 22px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }
.md-csw[aria-current="true"] { border-color: var(--ink); }
.md-cpick { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: pointer; }
/* Legenden-Linie (Farbe + Strichart) – ersetzt den alten Farbpunkt */
.ln-svg { vertical-align: middle; margin-right: 6px; flex: 0 0 auto; }

.tab-badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px;
  padding: 0 5px; margin-left: 6px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; text-align: center; vertical-align: middle;
}

.sidebar-foot { padding: 11px 16px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--gray); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; background: var(--card); border-bottom: 1px solid var(--line); padding: 0 12px; }
.tab {
  font: inherit; font-size: 13px; font-weight: 600;
  background: none; border: none; cursor: pointer;
  padding: 14px 15px; color: var(--gray);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  display: flex; align-items: center; gap: 7px;
}
.tab svg { width: 16px; height: 16px; opacity: .9; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

.tab-body { flex: 1; overflow-y: auto; padding: 20px; }
.panel { display: none; }
.panel.active { display: block; }

/* ---------- Controls ---------- */
.panel-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  margin-bottom: 16px; padding: 11px 15px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-controls label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.panel-controls select, .panel-controls input[type=number] {
  font: inherit; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--ink);
}
.panel-controls input[type=number] { width: 64px; }
.panel-controls .chk { gap: 7px; }
.panel-controls input[type=checkbox] { accent-color: var(--red); width: 16px; height: 16px; }
.hint-inline { font-size: 12px; color: var(--gray-2); margin-left: auto; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow);
}
.card .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--gray); }
.card .v { font-size: 25px; font-weight: 800; margin-top: 5px; color: var(--ink); font-variant-numeric: tabular-nums; }
.card .v small { font-size: 13px; font-weight: 600; color: var(--gray); }
.card .sub { font-size: 11px; color: var(--gray-2); margin-top: 3px; }
.card.accent { border-top: 3px solid var(--red); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 13px; text-align: right; white-space: nowrap; }
.data-table th {
  background: var(--card-2); color: var(--gray); font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table td { border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; color: var(--ink); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--card-2); }
.data-table .best { color: var(--red); font-weight: 800; }
.data-table .muted { color: var(--gray-2); }
.data-table .swatch-cell { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 5px; background: var(--line); color: var(--gray); margin-left: 6px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.badge.in-out { background: var(--red-soft); color: var(--red); }
.badge.invalid { background: rgba(180, 130, 20, 0.18); color: #c4901f; }

/* ---------- Charts ---------- */
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); position: relative; }
.chart-box canvas { width: 100%; height: 360px; display: block; touch-action: none; }
.chart-box.small canvas { height: 280px; }
.chart-box.tall canvas { height: 520px; }
.chart-box.track-box canvas { height: 160px; }

/* Start-Replay (Slot-Car-Ansicht) */
#launch-replay { margin-top: 20px; }
.replay-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.replay-ctrls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.replay-ctrls label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.replay-ctrls select { font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }
#replay-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--gray); min-width: 66px; text-align: right; }
#replay-play { min-width: 84px; }
#replay-scrub { width: 100%; margin: 2px 0 6px; accent-color: var(--red); cursor: pointer; }
#replay-readout { margin-top: 10px; gap: 4px 14px; }

/* Start-Replay-Modal (GPS · Bahn · Speed) — füllt den Platz, kein Scrollen */
.modal.replay-modal-card { width: min(1720px, 98vw); height: 97vh; }
.rep-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px 0; }
.rep-controls label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.rep-controls select { font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); }
.rep-controls #rep-play { min-width: 86px; }
.rep-controls #rep-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--gray); min-width: 70px; text-align: right; margin-left: auto; }
#rep-scrub { margin: 8px 18px 4px; width: calc(100% - 36px); accent-color: var(--red); cursor: pointer; }
.modal-body.rep-body { flex: 1; flex-direction: column; gap: 10px; padding: 4px 18px 14px; overflow: hidden; min-height: 0; }
.rep-block { display: flex; flex-direction: column; min-height: 0; flex: 0 0 auto; }   /* feste Blöcke (z. B. Bahn) behalten ihre Höhe */
.rep-block.rep-grow { flex: 1 1 0; min-height: 120px; }   /* GPS-Karte + Speed teilen sich die freie Höhe */
.rep-mapbox.rep-block.rep-grow, .rep-block.rep-grow.rep-map-block { flex-grow: 1.7; }
.rep-block.rep-grow .chart-box { flex: 1; min-height: 0; }
.rep-block.rep-grow .chart-box canvas { height: 100%; }
.rep-h { margin: 0 0 5px; font-size: 12px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; }
.rep-trackbox canvas { height: 150px; }
#rep-readout { margin-top: 8px; gap: 4px 14px; }

/* Chart-Werkzeuge (Vollbild / Zoom-Reset) */
.chart-tools { position: absolute; top: 8px; right: 10px; display: flex; gap: 5px; z-index: 4; opacity: 0; transition: opacity .15s; }
.chart-box:hover .chart-tools { opacity: 1; }
.chart-btn {
  font: inherit; font-size: 14px; line-height: 1; width: 28px; height: 26px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; padding: 0; box-shadow: var(--shadow);
}
.chart-btn:hover { border-color: var(--red); color: var(--red); }

/* Vollbild (native API) */
.chart-box:fullscreen, .chart-box:-webkit-full-screen { width: 100vw; height: 100vh; padding: 16px; background: var(--card); border-radius: 0; }
.chart-box:fullscreen canvas { height: calc(100vh - 32px) !important; }
.chart-box:-webkit-full-screen canvas { height: calc(100vh - 32px) !important; }
.chart-box:fullscreen .chart-tools, .chart-box:-webkit-full-screen .chart-tools { opacity: 1; }

/* Vollbild (CSS-Fallback) */
.chart-box.maximized {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1000;
  padding: 16px; margin: 0; border-radius: 0; box-shadow: none;
}
.chart-box.maximized canvas { height: calc(100vh - 32px) !important; }
.chart-box.maximized .chart-tools { opacity: 1; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 4px; }
.two-col .sub, .sub { font-size: 13px; font-weight: 700; margin: 2px 0 9px; color: var(--ink-2); }

/* ---------- Legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 11px; font-size: 12px; color: var(--ink-2); }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .ln { width: 16px; height: 3px; border-radius: 2px; }

.mini-stats { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.mini-stats .ms { display: flex; align-items: center; gap: 7px; }
.mini-stats .dot { width: 10px; height: 10px; border-radius: 50%; }
.mini-stats b { font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- Map legend ---------- */
.map-legend { display: flex; align-items: center; gap: 10px; margin-top: 11px; font-size: 12px; color: var(--gray); }
.map-grad { height: 12px; width: 220px; border-radius: 3px;
  background: linear-gradient(90deg, rgb(var(--speed-slow)), rgb(var(--speed-mid)), rgb(var(--speed-fast))); }

/* ---------- Toast (immer über Modal & Dialogen) ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--card); padding: 12px 20px; border-radius: 9px;
  font-size: 13px; font-weight: 600; max-width: 90vw; text-align: center;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 3000;
  border-left: 3px solid var(--red); box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); color: #fff; border-left-color: #fff; }

/* ---------- Buttons ---------- */
.btn-primary {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--red); color: #fff; border: none; border-radius: 8px; padding: 8px 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.mini.danger { color: var(--red); }
.mini.danger:hover { background: var(--red-soft); }
.sidebar-manage { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }

/* Eintrag im Arbeitsset entfernen */
.file-remove {
  border: none; background: none; cursor: pointer; color: var(--gray-2);
  font-size: 15px; line-height: 1; padding: 2px 3px; border-radius: 5px; align-self: center; flex: 0 0 auto;
  visibility: hidden;
}
.file-row:hover .file-remove { visibility: visible; }
.file-remove:hover { color: var(--red); background: var(--red-soft); }

/* ---------- Modal / Datei-Browser ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1200; background: rgba(8, 10, 14, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.modal {
  width: min(1480px, 97vw); height: min(940px, 95vh);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head-info { font-size: 12px; color: var(--gray); }
.modal-x { margin-left: auto; border: none; background: none; cursor: pointer; font-size: 18px; color: var(--gray); width: 32px; height: 32px; border-radius: 8px; }
.modal-x:hover { background: var(--card-2); color: var(--ink); }
.modal-body { flex: 1; display: flex; min-height: 0; }
.fb-left { width: 272px; min-width: 272px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--card-2); }
.fb-modes { display: flex; flex-wrap: wrap; gap: 4px; padding: 9px; border-bottom: 1px solid var(--line); }
.fb-mode { flex: 1 1 30%; font: inherit; font-size: 11px; font-weight: 600; padding: 6px 4px; border: 1px solid var(--line); background: var(--card); color: var(--gray); border-radius: 7px; cursor: pointer; white-space: nowrap; }
.fb-mode:hover { color: var(--ink); }
.fb-mode.active { background: var(--red); color: #fff; border-color: var(--red); }
.fb-tree { flex: 1; overflow-y: auto; padding: 10px 8px; }
.fb-scan { padding: 22px 12px; text-align: center; color: var(--gray); font-size: 13px; line-height: 1.7; }
.fb-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.fb-bar { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.fb-crumb { font-size: 13px; font-weight: 600; color: var(--ink); min-width: 0; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.fb-crumb .muted { color: var(--gray-2); font-weight: 400; }
.fb-crumb .fb-count { color: var(--gray-2); font-weight: 400; font-size: 12px; }
.fb-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 5px 3px 9px; border-radius: 14px; background: var(--red-soft); color: var(--red); border: 1px solid transparent; cursor: pointer; }
.fb-chip .fb-chip-x { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--red); color: #fff; font-size: 10px; }
.fb-chip.fb-chip-reset { background: transparent; color: var(--gray); border-color: var(--line); font-weight: 500; padding: 3px 9px; }
.fb-chip.fb-chip-reset:hover { color: var(--ink); border-color: var(--gray-2); }
.fb-search { font: inherit; font-size: 13px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); width: 230px; max-width: 40vw; }
.fb-search:focus { outline: none; border-color: var(--red); }
.fb-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.fb-list-wrap { flex: 1; overflow: auto; padding: 6px 10px 12px; }
.fb-empty { padding: 28px 16px; color: var(--gray); font-size: 13px; text-align: center; }
.modal-foot { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.modal-foot .muted-text { font-size: 12px; color: var(--gray); }
.fb-selall { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; cursor: pointer; }
.fb-selall input, .fb-table input[type=checkbox] { accent-color: var(--red); width: 16px; height: 16px; }

/* Ordnerbaum */
.fb-node { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink); }
.fb-node:hover { background: var(--card); }
.fb-node.active { background: var(--red-soft); color: var(--red); font-weight: 700; }
.fb-node .fb-caret { width: 14px; flex: 0 0 auto; color: var(--gray-2); transition: transform .12s; font-size: 11px; }
.fb-node.open .fb-caret { transform: rotate(90deg); }
.fb-node .fb-folder { flex: 0 0 auto; opacity: .8; }
.fb-node .fb-cnt { font-size: 11px; color: var(--gray-2); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 7px; }
.fb-node.active .fb-cnt { color: var(--red); border-color: var(--red); background: transparent; }
.fb-node .fb-node-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.fb-node .fb-node-imp { visibility: hidden; border: none; background: var(--red); color: #fff; font-size: 13px; line-height: 1; width: 22px; height: 22px; border-radius: 6px; cursor: pointer; padding: 0; }
.fb-node:hover .fb-node-imp { visibility: visible; }
.fb-node .fb-node-imp:hover { background: var(--red-dark); }
.fb-import-folder { padding: 6px 12px !important; }
.fb-children { margin-left: 12px; }

/* Hover-Tooltip im Datei-Browser (Tabellen: Meta / Runden / Starts) */
.fb-tip {
  position: fixed; z-index: 1300; pointer-events: none;
  width: 440px; max-width: 92vw; background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 13px 15px; font-size: 12px; line-height: 1.45;
}
.fb-tip .tip-title { font-size: 14px; font-weight: 800; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.fb-tip .tip-grp { font-weight: 500; color: var(--gray-2); font-size: 11px; margin-left: 8px; }
.fb-tip .tip-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--gray); font-weight: 700; margin: 10px 0 3px; display: flex; justify-content: space-between; }
.fb-tip .tip-sec .tip-best { color: var(--red); text-transform: none; letter-spacing: 0; }
.fb-tip .tip-none { color: var(--gray-2); margin-top: 2px; }

.fb-tip table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fb-tip .tip-kv td { padding: 2px 0; vertical-align: top; }
.fb-tip .tip-kv td:first-child { color: var(--gray); width: 84px; }
.fb-tip .tip-kv td:last-child { color: var(--ink); font-weight: 600; }
.fb-tip .tip-tbl { margin-top: 2px; }
.fb-tip .tip-tbl th { text-align: right; color: var(--gray); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-bottom: 1px solid var(--line); }
.fb-tip .tip-tbl th:first-child { text-align: left; }
.fb-tip .tip-tbl td { text-align: right; padding: 2.5px 7px; color: var(--ink-2); border-bottom: 1px solid var(--line-2); }
.fb-tip .tip-tbl td:first-child { text-align: left; color: var(--ink); }
.fb-tip .tip-tbl tr:last-child td { border-bottom: none; }
.fb-tip .tip-tbl tr.best td { color: var(--red); font-weight: 800; }
.fb-tip .tip-tbl tr.dim td { color: var(--gray-2); }

/* Datum/Zeit-Zelle in der Datei-Tabelle */
.fb-table .cell-when .when-date { color: var(--ink-2); }
.fb-table .cell-when .when-time { color: var(--gray-2); font-size: 11px; }

/* In-App-Dialoge (Prompt / Confirm / Verschieben) */
.dlg-overlay { position: fixed; inset: 0; z-index: 1400; background: rgba(8,10,14,.5); display: flex; align-items: center; justify-content: center; padding: 20px; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dlg { width: min(460px, 94vw); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.dlg-title { font-size: 15px; font-weight: 800; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--ink); }
.dlg-body { padding: 16px 18px; font-size: 13px; color: var(--ink-2); }
.dlg-body .dlg-msg { line-height: 1.55; }
.dlg-body .dlg-msg b { color: var(--ink); }
.dlg-label { font-size: 12px; color: var(--gray); margin-bottom: 4px; }
.dlg-input { width: 100%; font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }
.dlg-input:focus { outline: none; border-color: var(--red); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

/* Upload: Button-Icon + Drag&Drop-Markierung im Datei-Browser */
#fb-upload svg { vertical-align: -2px; margin-right: 4px; }
.modal-overlay.fbx-dragover .fbx { outline: 2px dashed var(--red); outline-offset: -6px; }

/* Upload-Prüfung: erkannte Zuordnung anzeigen + korrigieren */
.dlg.dlg-upr { width: min(640px, 95vw); }
.upr-list { display: flex; flex-direction: column; gap: 12px; max-height: 56vh; overflow: auto; padding-right: 2px; }
.upr-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.upr-name { font-weight: 700; color: var(--ink); font-size: 13px; }
.upr-sub { font-size: 11.5px; color: var(--gray); margin: 2px 0 8px; }
.upr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.upr-grid label { display: block; font-size: 11px; color: var(--gray); }
.upr-grid select.dlg-input { margin-top: 3px; font-size: 12.5px; padding: 6px 8px; }
.upr-dups { margin-top: 12px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 10px; line-height: 1.6; }
.upr-dups b { color: var(--ink); }
.upr-dups .mini { margin-top: 6px; }
@media (max-width: 560px) { .upr-grid { grid-template-columns: 1fr; } }

/* Datei-Tabelle im Modal */
.fb-table .actcell { white-space: nowrap; }
.fb-table .best { color: var(--red); font-weight: 800; }
.fb-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.fb-table th.sortable:hover { color: var(--ink); }
.fb-table th.sortable.active { color: var(--red); }
.fb-table th .sort-ind { font-size: 9px; }
.fb-fname { font-weight: 600; color: var(--ink); }
.fb-subpath { font-size: 11px; color: var(--gray-2); margin-top: 1px; }
.fb-iconbtn { border: none; background: none; cursor: pointer; color: var(--gray); font-size: 13px; padding: 3px 6px; border-radius: 6px; }
.fb-iconbtn:hover { background: var(--card-2); color: var(--ink); }
.fb-iconbtn.danger:hover { color: var(--red); background: var(--red-soft); }
.fb-row-imported td:first-child { box-shadow: inset 3px 0 0 var(--good); }
.fb-tag-imported { font-size: 10px; color: var(--good); font-weight: 700; margin-left: 7px; text-transform: uppercase; letter-spacing: .04em; }

/* --- Erkennung: Fahrer/Strecke/Event-Chips in der Dateiliste --- */
.fb-recog { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.fb-recog .rec { font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.fb-recog .rec-d { background: var(--red-soft); border-color: transparent; color: var(--red); }
.fb-recog .rec-tag { background: transparent; color: var(--gray); }
.fb-recog .rec-bad { background: var(--red); color: #fff; border-color: transparent; }
.fb-recog .rec-note { cursor: help; }
.fb-table tr.fb-row-invalid td { opacity: .55; }
.fb-table tr.fb-row-invalid .fb-fname { text-decoration: line-through; text-decoration-color: var(--gray-2); }
.fb-migrate-btn { background: var(--red); color: #fff; border-color: var(--red); font-weight: 700; white-space: nowrap; }
.fb-migrate-btn:hover { background: var(--red-dark); }
.fb-migrate-btn:disabled { opacity: .6; cursor: default; }
.file-meta .tag.tag-driver { background: var(--red-soft); color: var(--red); font-weight: 700; padding: 0 7px; border-radius: 9px; }
.fb-node.fb-node-none { opacity: .72; }
.fb-tip .tip-kv .tip-rec td:first-child { color: var(--red); font-weight: 700; }
.fb-tip .tip-kv .tip-rec td { color: var(--ink); }

/* --- Stammdaten-Modal --- */
.modal.modal-md { width: min(1080px, 96vw); height: min(820px, 93vh); }
.md-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.md-tab { font: inherit; font-size: 13px; font-weight: 600; padding: 12px 16px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--gray); cursor: pointer; }
.md-tab:hover { color: var(--ink); }
.md-tab.active { color: var(--red); border-bottom-color: var(--red); }
.md-modal-body { display: block; overflow-y: auto; padding: 16px 18px; }
.md-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.md-hint { font-size: 12px; color: var(--gray-2); }
.md-status { display: flex; align-items: center; gap: 6px; }
.md-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.md-dot.ok { background: var(--good); } .md-dot.bad { background: var(--red); }
.md-suggest { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; }
.md-suggest-h { font-size: 11.5px; color: var(--gray); font-weight: 600; margin-bottom: 8px; }
.md-sugg-tbl { background: var(--card); }
.md-sugg-tbl td { vertical-align: middle; }
.md-sugg-name { width: auto; min-width: 160px; max-width: 240px; padding: 5px 9px !important; font-size: 13px; }
.md-sugg-add { white-space: nowrap; }
.md-sat-row td { background: var(--card-2); padding: 12px !important; }
.md-sat { display: flex; gap: 14px; align-items: center; }
.md-sat-img { position: relative; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card-2); }
.md-sat-img img { pointer-events: none; user-select: none; }
.md-sat-dot { position: absolute; z-index: 2; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--red); border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.md-sat-zoom { position: absolute; z-index: 3; right: 8px; bottom: 8px; display: flex; gap: 4px; }
.md-zb { width: 26px; height: 26px; border: none; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; font-size: 17px; line-height: 1; cursor: pointer; }
.md-zb:hover { background: rgba(0,0,0,.8); }
.md-sat-info { font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.md-sat-info a { color: var(--red); }
.md-ign-note { font-size: 12px; color: var(--gray); margin-top: 8px; }
.md-ign-note a { color: var(--red); }
/* Strecken-Geo-Editor (Start/Ziel + Sektoren auf Satellit) */
.dlg.dlg-geo { width: auto; max-width: 96vw; }
.geo-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.geo-tools .spacer { flex: 1; }
.geo-mode.active { background: var(--red); color: #fff; border-color: var(--red); }
.geo-hint { font-size: 12px; color: var(--gray); }
.geo-map { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--card-2); }
.geo-map img { position: absolute; width: 256px; height: 256px; pointer-events: none; }
.geo-svg { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; }
.geo-click { position: absolute; inset: 0; z-index: 3; cursor: crosshair; }
.geo-legend { font-size: 12px; color: var(--gray); margin-top: 8px; }
.geo-legend .gl-line { color: var(--red); }
.md-chip { font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; margin: 0 6px 6px 0; border-radius: 14px; background: var(--red-soft); color: var(--red); border: 1px solid transparent; cursor: pointer; }
.md-chip:hover { background: var(--red); color: #fff; }
.md-chip .md-chip-n { opacity: .7; font-weight: 700; margin-left: 3px; }
.md-tablewrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.md-list { width: 100%; }
.md-list th, .md-list td { padding: 9px 12px; text-align: left; font-size: 13px; }
.md-list .md-num { font-weight: 800; color: var(--ink); }
.md-list .md-mono { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.md-list .md-c { text-align: center; color: var(--gray); }
.md-list .md-act { text-align: right; white-space: nowrap; }
.md-list tr.md-inactive { opacity: .5; }
.md-none { text-align: center; color: var(--gray-2); padding: 26px !important; }
.md-empty { padding: 40px 20px; text-align: center; color: var(--gray); line-height: 1.7; }
.md-empty b { color: var(--ink); display: block; margin-bottom: 4px; font-size: 15px; }
.md-empty code { background: var(--card-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

/* --- Mehrfeld-Formular-Dialog (Stammdaten anlegen/bearbeiten) --- */
.dlg.dlg-wide { width: min(580px, 95vw); }
.md-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 14px; }
.md-field { display: flex; flex-direction: column; gap: 5px; }
.md-field-wide { grid-column: 1 / -1; }
.md-flabel { font-size: 11px; font-weight: 600; color: var(--gray); }
.md-field textarea.dlg-input { resize: vertical; font-size: 13px; }
.md-chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding-top: 7px; }
.md-chk input { accent-color: var(--red); width: 16px; height: 16px; }

@media (max-width: 1000px) {
  .two-col { grid-template-columns: 1fr; }
  .sidebar { width: 240px; min-width: 240px; }
  .user-chip .user-text { display: none; }
  .best-badge { display: none; }
  .fb-left { width: 200px; min-width: 200px; }
  .md-grid { grid-template-columns: 1fr; }
}

/* --- Strich-Icons: Ausrichtung in Buttons/Chips --- */
.ic { display: inline-block; flex: 0 0 auto; vertical-align: -0.16em; }
.fb-mode { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.fb-mode .ic { opacity: .85; }
.md-tab { display: inline-flex; align-items: center; gap: 7px; }
.mini { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.fb-iconbtn { display: inline-flex; align-items: center; justify-content: center; }
.fb-node-imp { align-items: center; justify-content: center; }
.fb-recog .rec { display: inline-flex; align-items: center; gap: 3px; }
.fb-recog .rec .ic { opacity: .9; }
.md-suggest-h { display: flex; align-items: center; gap: 6px; }
.fb-chip .ic { opacity: .9; }
.fb-scan .ic { opacity: .6; }

/* ============ Datei-Browser-Modal · 4-Spalten-Redesign ============ */
.modal.fbx { width: min(1500px, 97vw); height: min(900px, 95vh); padding: 0; background: var(--card); }
.fbx { display: flex; flex-direction: column; }
.fbx-head { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.fbx-head h3 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.fbx-sub { font-size: 13px; color: var(--gray); }
.fbx-x { margin-left: auto; border: none; background: none; cursor: pointer; color: var(--gray-2); width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
.fbx-x:hover { background: var(--card-2); color: var(--ink); }
.fbx-x2 { margin-left: 0; } /* zweiter Kopf-Button (X) direkt neben dem Vollbild-Button */
/* Vollbild-Modus des Datei-Browsers */
#modal.fbx-fullov { padding: 0; }
.modal.fbx.fbx-full { width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; border: none; }

/* Filter-Topbar */
.fbx-filters { display: flex; align-items: center; gap: 9px; padding: 12px 22px; border-bottom: 1px solid var(--line); flex: 0 0 auto; flex-wrap: wrap; }
.fbx-filters-main { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.fbx-pill { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; cursor: pointer; white-space: nowrap; position: relative; }
.fbx-pill:hover { border-color: var(--gray-2); }
.fbx-pill .ic { color: var(--gray-2); }
.fbx-pill .fbx-cv { color: var(--gray-2); margin-left: 2px; }
.fbx-pill.active { color: var(--red); background: var(--red-soft); border-color: transparent; }
.fbx-pill.active .ic { color: var(--red); }
.fbx-search { display: flex; align-items: center; gap: 8px; margin-left: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0 11px; min-width: 200px; }
.fbx-search .fbx-search-ic { color: var(--gray-2); display: inline-flex; }
.fbx-search input { border: none; background: none; outline: none; font: inherit; font-size: 13px; color: var(--ink); padding: 9px 0; width: 100%; }
.fbx-view { flex: 0 0 auto; }

/* Body: rail | groups | list | details */
.fbx-body { flex: 1; display: flex; min-height: 0; }
.fbx-rail { width: 86px; flex: 0 0 auto; border-right: 1px solid var(--line); padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; background: var(--card-2); }
.fbx-rail-item { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px; border-radius: 11px; cursor: pointer; color: var(--gray); font-size: 11px; font-weight: 600; border: none; background: none; position: relative; }
.fbx-rail-item:hover { background: var(--card); color: var(--ink); }
.fbx-rail-item.active { color: var(--red); background: var(--red-soft); }
.fbx-rail-item.active::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.fbx-rail-item .ic { width: 22px; height: 22px; }

/* Gruppen-Spalte */
.fbx-groups { width: 244px; flex: 0 0 auto; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.fbx-gsearch { padding: 12px 12px 8px; }
.fbx-gsearch input { width: 100%; font: inherit; font-size: 13px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); }
.fbx-gsearch input:focus { outline: none; border-color: var(--red); }
.fbx-glist { flex: 1; overflow-y: auto; padding: 2px 10px 8px; }
.fbx-gcard { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: 11px; cursor: pointer; margin-bottom: 3px; border: 1px solid transparent; }
.fbx-gcard:hover { background: var(--card-2); }
.fbx-gcard.active { background: var(--red-soft); border-color: transparent; box-shadow: inset 3px 0 0 var(--red); }
.fbx-gav { width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2); }
.fbx-gcard.active .fbx-gav { background: var(--red); color: #fff; border-color: transparent; }
.fbx-gav .ic { width: 19px; height: 19px; }
.fbx-gmeta { min-width: 0; flex: 1; }
.fbx-gname { font-size: 13.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fbx-gsub { font-size: 11.5px; color: var(--gray); margin-top: 1px; }
.fbx-gdot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: 0 0 auto; }
.fbx-gadd { margin: 8px 12px 12px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: none; color: var(--gray); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.fbx-gadd:hover { border-color: var(--red); color: var(--red); }
.fbx-gempty { padding: 20px 14px; color: var(--gray-2); font-size: 12.5px; text-align: center; line-height: 1.6; }

/* Dateiliste */
.fbx-list { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.fbx-list-top { display: flex; align-items: center; gap: 10px; padding: 13px 18px 9px; }
.fbx-found { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.fbx-up { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.fbx-up:hover { border-color: var(--gray-2); }
/* Zuordnungs-Übersicht: Mini-Button, Massen-Zuweisen, Detail-Satellitenkarte */
.fbx-mini-btn { font: inherit; font-size: 12px; font-weight: 600; color: var(--red); background: transparent; border: none; cursor: pointer; padding: 2px 4px; }
.fbx-mini-btn:hover { text-decoration: underline; }
.fbx-btn-assign:not([disabled]) { color: #fff; background: var(--ink-2); border-color: var(--ink-2); }
.fbx-btn[disabled] { opacity: .45; cursor: not-allowed; }
.fbx-det-actions { display: flex; gap: 8px; margin-top: 14px; }
.fbx-det-actions .fbx-up { flex: 1; justify-content: center; }
.fbx-det-map { margin: 10px 0 4px; }
.fbx-det-mapwrap { position: relative; width: 100%; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); background: var(--map-bg); }
.fbx-det-svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.fbx-det-maphint { font-size: 12px; color: var(--gray-2); padding: 16px 0; text-align: center; }
.fbx-det-maplink { display: inline-block; font-size: 11px; color: var(--gray); margin-top: 4px; text-decoration: none; }
.fbx-det-maplink:hover { color: var(--red); }
.md-note { font-size: 12px; color: var(--gray); line-height: 1.45; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.fbx-mig { font: inherit; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--red); border: 1px solid var(--red); border-radius: 9px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fbx-mig:hover { background: var(--red-dark); }
.fbx-list-scroll { flex: 1; overflow-y: auto; padding: 0 10px 10px; }
.fbx-table { width: 100%; border-collapse: collapse; }
.fbx-table thead th { position: sticky; top: 0; background: var(--card); z-index: 2; text-align: left; font-size: 11px; font-weight: 700; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.fbx-table th.sortable { cursor: pointer; }
.fbx-table th.sortable:hover { color: var(--ink); }
.fbx-table th.num, .fbx-table td.num { text-align: right; }
.fbx-table tbody tr { cursor: pointer; border-bottom: 1px solid var(--line-2); }
.fbx-table tbody tr:hover { background: var(--card-2); }
.fbx-table tbody tr.sel { background: var(--red-soft); }
.fbx-table tbody tr.focus { box-shadow: inset 3px 0 0 var(--red); }
.fbx-table tbody tr.invalid .fbx-fname { text-decoration: line-through; color: var(--gray-2); }
.fbx-table td { padding: 11px 12px; font-size: 13px; color: var(--ink); vertical-align: middle; font-variant-numeric: tabular-nums; }
.fbx-rsel { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--gray-2); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.fbx-table tr.sel .fbx-rsel { border-color: var(--red); background: var(--red); }
.fbx-table tr.sel .fbx-rsel::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.fbx-fname { font-weight: 700; color: var(--ink); }
.fbx-fsub { font-size: 11.5px; color: var(--gray); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.fbx-when-d { font-weight: 600; }
.fbx-when-t { font-size: 11.5px; color: var(--gray); margin-top: 1px; }
.fbx-best { color: var(--red); font-weight: 800; }
.fbx-star { color: var(--red); margin-left: 3px; }
.fbx-rowmenu { border: none; background: none; cursor: pointer; color: var(--gray-2); width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.fbx-rowmenu:hover { background: var(--line); color: var(--ink); }
.fbx-empty { padding: 40px 20px; text-align: center; color: var(--gray-2); font-size: 13.5px; line-height: 1.6; }

/* Detail-Panel */
.fbx-details { width: 312px; flex: 0 0 auto; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--card); }
.fbx-details.hidden { display: none; }
.fbx-det-head { display: flex; align-items: center; padding: 15px 18px 12px; }
.fbx-det-head h4 { margin: 0; font-size: 14px; font-weight: 800; }
.fbx-det-x { margin-left: auto; border: none; background: none; cursor: pointer; color: var(--gray-2); width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.fbx-det-x:hover { background: var(--card-2); color: var(--ink); }
.fbx-det-body { flex: 1; overflow-y: auto; padding: 4px 18px 18px; }
.fbx-det-label { font-size: 11px; color: var(--gray-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.fbx-det-file { font-size: 19px; font-weight: 800; margin: 5px 0 2px; letter-spacing: -.01em; }
.fbx-det-path { font-size: 12px; color: var(--gray); margin-bottom: 11px; }
.fbx-det-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.fbx-det-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); color: var(--ink-2); }
.fbx-det-chip.driver { background: var(--red-soft); border-color: transparent; color: var(--red); }
.fbx-det-sec { font-size: 12px; font-weight: 800; color: var(--ink); margin: 16px 0 9px; }
.fbx-kv { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 9px 12px; }
.fbx-kv dt { font-size: 12.5px; color: var(--gray); }
.fbx-kv dd { font-size: 12.5px; color: var(--ink); margin: 0; text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
.fbx-kv dd.red { color: var(--red); font-weight: 700; }
.fbx-det-div { height: 1px; background: var(--line); margin: 15px 0; }
.fbx-det-none { padding: 50px 20px; text-align: center; color: var(--gray-2); font-size: 13px; line-height: 1.6; }

/* Footer */
.fbx-foot { display: flex; align-items: center; gap: 12px; padding: 13px 22px; border-top: 1px solid var(--line); flex: 0 0 auto; }
.fbx-foot-sel { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: nowrap; white-space: nowrap; }
.fbx-foot-count { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 13px; font-weight: 700; color: var(--red); background: var(--red-soft); padding: 7px 12px; border-radius: 9px; border: none; cursor: pointer; }
.fbx-foot-count:hover { filter: brightness(.96); }
.fbx-foot-reset { color: var(--gray); font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.fbx-foot-reset:hover { color: var(--red); }
/* Aufklappbare Liste der ausgewählten Dateien (über dem Footer) */
.fbx-selpop { position: fixed; z-index: 3200; width: min(440px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.fbx-selpop-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--ink); padding: 7px 9px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.fbx-selpop-list { max-height: 42vh; overflow-y: auto; }
.fbx-selrow { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px; font-size: 12.5px; color: var(--ink-2); }
.fbx-selrow:hover { background: var(--card-2); }
.fbx-selrow b { color: var(--ink); white-space: nowrap; }
.fbx-selrow .sub { flex: 1; color: var(--gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.fbx-selrow .rm { cursor: pointer; color: var(--gray-2); display: inline-flex; flex: 0 0 auto; }
.fbx-selrow .rm:hover { color: var(--red); }
.fbx-btn { font: inherit; font-size: 13.5px; font-weight: 700; padding: 10px 18px; border-radius: 10px; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.fbx-btn:hover { border-color: var(--gray-2); }
.fbx-btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.fbx-btn-primary:hover { background: var(--red-dark); }

/* Filter-Dropdown-Popup */
.fbx-pop { position: fixed; z-index: 3200; background: var(--card); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 190px; max-height: 320px; overflow-y: auto; }
.fbx-pop-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink); }
.fbx-pop-item:hover { background: var(--card-2); }
.fbx-pop-item.on { color: var(--red); font-weight: 700; }
.fbx-pop-item .cnt { margin-left: auto; font-size: 11.5px; color: var(--gray-2); }
.fbx-pop-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.fbx-pop-range { padding: 8px 10px; display: flex; flex-direction: column; gap: 7px; }
.fbx-pop-range label { font-size: 11px; color: var(--gray); display: flex; flex-direction: column; gap: 3px; }
.fbx-pop-range input { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); }

@media (max-width: 1180px) {
  .fbx-details { display: none; }
  .modal.fbx { width: 97vw; }
}

/* =====================================================================
 * Benutzerverwaltung + Passkey-Login
 * ===================================================================== */

/* --- Login- / Einladungsseite --- */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; background: var(--bg); margin: 0; }
.auth-wrap { width: 100%; max-width: 420px; padding: 24px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-text { color: var(--ink); }
.auth-brand .brand-sub { color: var(--gray); }
.auth-title { font-size: 20px; margin: 0 0 6px; color: var(--ink); }
.auth-sub { font-size: 13px; color: var(--gray); margin: 0 0 18px; line-height: 1.5; }
.auth-btn { width: 100%; justify-content: center; display: flex; align-items: center; gap: 9px; font-size: 14px; padding: 11px 14px; }
.auth-btn svg { width: 17px; height: 17px; }
.auth-alt { margin-top: 16px; font-size: 12.5px; color: var(--gray); }
.auth-alt summary { cursor: pointer; }
.auth-altbody { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.auth-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--gray); }
.auth-btn2 { align-self: flex-start; }
.auth-hint { font-size: 11.5px; color: var(--gray-2); margin: 10px 0 0; line-height: 1.45; }
.auth-msg { display: none; margin-top: 14px; font-size: 12.5px; color: var(--ink-2); padding: 9px 11px; border-radius: var(--radius-sm); background: var(--card-2); border: 1px solid var(--line); }
.auth-msg.show { display: block; }
.auth-msg.error { color: var(--red); border-color: var(--red); background: var(--red-soft); }

/* --- Kopfzeile: Abmelden --- */
.uc-logout { margin-left: 2px; }

/* --- Benutzer-Reiter im Stammdaten-Manager --- */
.md-add { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.u-setup { max-width: 460px; }
.u-setup-row { display: flex; gap: 9px; margin-top: 5px; }
.u-setup-row .dlg-input { flex: 1; }
.u-setup-row .btn-primary { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.u-nokey { color: var(--red); font-weight: 700; font-size: 12px; }
.u-invite-row { display: flex; gap: 8px; margin-top: 10px; }
.u-invite-row .dlg-input { flex: 1; font-size: 12px; }

/* Formular: Events- / Kanal-Listen */
.dlg-user { width: min(620px, 94vw); }
/* Benutzer-Dialog: Tabs (Konto / Anmeldung / Dateien / Events / Datenkanäle) —
 * alle Felder bleiben im DOM, inaktive Panes sind nur ausgeblendet. */
.dlg-user .dlg-title { border-bottom: none; padding-bottom: 6px; }
.u-tabs { padding: 0 12px; }
.u-tabs .md-tab { font-size: 12.5px; padding: 9px 11px; }
.u-pane { display: none; min-height: 250px; }
.u-pane.active { display: block; }
.u-pane > .u-sect:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.u-sect { margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.u-sect-h { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--gray); margin-bottom: 7px; }
.u-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 3px 14px; max-height: 170px; overflow-y: auto; margin-top: 7px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--card-2); }
.u-list.u-off { opacity: .45; }
#uf-uplimits.u-off { opacity: .45; }
.u-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.u-item input { accent-color: var(--red); }
.u-item .muted { color: var(--gray-2); font-size: 11px; }
.u-extra { margin-top: 9px; }
.u-pk { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); padding: 5px 0; border-bottom: 1px dashed var(--line-2); }
.u-pk:last-child { border-bottom: none; }

/* --- Viewer-Modus (Benutzer ohne Admin-Rechte): Verwaltungs-UI ausblenden.
 *     Die eigentliche Durchsetzung passiert serverseitig. --- */
body.viewer #btn-master,
body.viewer #fb-massassign,
body.viewer #fb-groups-add,
body.viewer .fbx-table .fb-iconbtn,
body.viewer .fbx-details .fb-iconbtn { display: none !important; }

/* --- Passwort-Alternative --- */
.auth-or { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: var(--gray-2); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: flex; flex-direction: column; gap: 7px; }
.auth-form .auth-btn2 {
  margin-top: 5px; width: 100%; padding: 10px 14px; font-size: 13.5px; font-weight: 700;
  background: none; border: 1.5px solid var(--red); color: var(--red); border-radius: var(--radius-sm); cursor: pointer;
}
.auth-form .auth-btn2:hover { background: var(--red-soft); }
.user-chip.clickable { cursor: pointer; border-radius: var(--radius-sm); }
.user-chip.clickable:hover .user-text b { color: var(--red); }
.u-pwrow { margin-top: 10px; }
.u-pwrow .md-field { margin: 0; }

/* --- Mein Konto: eigene Passkeys --- */
.ac-addrow { display: flex; gap: 8px; margin-top: 10px; }
.ac-addrow .dlg-input { flex: 1; }
.ac-addrow .mini { white-space: nowrap; }
