/* =====================================================================
   BikeTracker — app.css
   Ein einziges Design-System, kein Framework, keine externen Ressourcen.

   Grundthema ist dunkel (Bedienung draussen auf dem Motorrad).
   Bei "prefers-color-scheme: light" wird auf eine helle Variante umgestellt
   (Historie/Admin am Rechner). Zusaetzlich kann ueber
   <html data-theme="dark|light"> hart umgeschaltet werden.

   Mobile first. Bedienflaechen mind. 56 px hoch, sehr hoher Kontrast,
   keine Funktion haengt an :hover.
   ===================================================================== */

/* ------------------------------------------------------- Farbvariablen */
:root {
  color-scheme: dark;

  /* Flaechen */
  --bg:            #111417;
  --bg-2:          #191e23;
  --bg-3:          #232b32;
  --bg-inset:      #0b0e10;
  --border:        #333d46;
  --border-strong: #4a565f;

  /* Schrift */
  --text:          #f0f3f5;
  --text-muted:    #9fabb6;
  --text-dim:      #74818c;

  /* Akzent (Orange/Amber) */
  --accent:        #ff8c1a;
  --accent-2:      #ffa94d;
  --accent-ink:    #1a1000;   /* Schrift auf Akzentflaeche */
  --accent-soft:   rgba(255, 140, 26, .16);

  /* Zustaende */
  --ok:            #35d07f;
  --ok-ink:        #06210f;
  --ok-soft:       rgba(53, 208, 127, .16);

  --warn:          #ffc400;
  --warn-ink:      #241a00;
  --warn-soft:     rgba(255, 196, 0, .16);

  --danger:        #ff5247;   /* Text/Rahmen auf dunklem Grund */
  --danger-bg:     #b81b0f;   /* Flaeche mit weisser Schrift */
  --danger-bg-2:   #d8261a;
  --danger-ink:    #ffffff;
  --danger-soft:   rgba(255, 82, 71, .16);

  --info:          #58a6ff;

  /* Masse */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --gap:   12px;
  --gap-lg: 18px;
  --pad:   14px;

  --tap:    56px;   /* Mindesthoehe fuer Handschuhbedienung */
  --tap-lg: 76px;

  --nav-h: 64px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --shadow: 0 2px 10px rgba(0, 0, 0, .45);
  --focus:  0 0 0 3px rgba(255, 140, 26, .55);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Helles Schema fuer den Rechner */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg:            #f4f6f8;
    --bg-2:          #ffffff;
    --bg-3:          #e7ebef;
    --bg-inset:      #eef1f4;
    --border:        #ccd4db;
    --border-strong: #9aa7b2;

    --text:          #12171c;
    --text-muted:    #55606b;
    --text-dim:      #6d7883;

    --accent:        #ff8c1a;
    --accent-2:      #a34f00;   /* Akzent als Schriftfarbe, kontraststark */
    --accent-ink:    #1a1000;
    --accent-soft:   rgba(255, 140, 26, .18);

    --ok:            #146c39;
    --ok-ink:        #ffffff;
    --ok-soft:       rgba(20, 108, 57, .12);

    --warn:          #8a6100;
    --warn-ink:      #ffffff;
    --warn-soft:     rgba(138, 97, 0, .12);

    --danger:        #b81b0f;
    --danger-bg:     #b81b0f;
    --danger-bg-2:   #d8261a;
    --danger-ink:    #ffffff;
    --danger-soft:   rgba(184, 27, 15, .12);

    --info:          #0b5fbd;

    --shadow: 0 2px 10px rgba(16, 24, 32, .12);
  }
}

/* Harte Umschaltung ueber das Wurzelelement */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  /* Platz fuer die untere Navigationsleiste (mobil) */
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
  min-height: 100vh;
  min-height: 100dvh;
}

/* Seiten ohne Navigation (Login, Setup) brauchen unten keinen Platz */
body.no-nav {
  padding-bottom: var(--safe-b);
  padding-top: var(--safe-t);
}

[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 .8em; }

a { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--focus);
}

img, svg { max-width: 100%; }
svg { display: block; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--gap-lg) 0;
}

code, kbd, samp, .mono { font-family: var(--mono); font-size: .92em; }

.wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--pad);
}
.wrap-wide { max-width: 1200px; }
.wrap-narrow { max-width: 480px; }

/* Hilfsklassen */
.row      { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: center; }
.row-tight{ gap: 8px; }
.col      { display: flex; flex-direction: column; gap: var(--gap); }
.grow     { flex: 1 1 auto; min-width: 0; }
.center   { text-align: center; }
.right    { text-align: right; }
.muted    { color: var(--text-muted); }
.dim      { color: var(--text-dim); }
.small    { font-size: .85rem; }
.big      { font-size: 1.25rem; }
.strong   { font-weight: 700; }
.nowrap   { white-space: nowrap; }
.mt   { margin-top: var(--gap); }
.mt-lg{ margin-top: var(--gap-lg); }
.mb   { margin-bottom: var(--gap); }
.mb-lg{ margin-bottom: var(--gap-lg); }
.hide { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.text-ok     { color: var(--ok); }
.text-warn   { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent-2); }

/* -------------------------------------------------------------- Buttons */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: var(--r);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .08s ease, filter .12s ease, background-color .12s ease;
}
.btn:active { transform: scale(.97); filter: brightness(.92); }
.btn[disabled], .btn.is-disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}
.btn svg { width: 22px; height: 22px; flex: none; }

.btn-lg {
  min-height: var(--tap-lg);
  font-size: 1.35rem;
  padding: 16px 24px;
  border-radius: var(--r-lg);
}
.btn-xl {
  min-height: 104px;
  font-size: 1.7rem;
  padding: 20px 24px;
  border-radius: var(--r-lg);
}
.btn-sm {
  min-height: 44px;
  font-size: .95rem;
  padding: 8px 14px;
  border-radius: var(--r-sm);
}
.btn-block { display: flex; width: 100%; }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-ink);
}
.btn-ok {
  background: var(--ok);
  color: var(--ok-ink);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:active { background: var(--bg-3); }

.btn-group { display: flex; gap: var(--gap); flex-wrap: wrap; }
.btn-group > .btn { flex: 1 1 140px; }

/* ---------------------------------------------------------------- Karten */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--pad);
  margin-bottom: var(--gap);
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-title {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.card-accent  { border-color: var(--accent); }
.card-danger  { border-color: var(--danger); background: var(--danger-soft); }
.card-ok      { border-color: var(--ok); background: var(--ok-soft); }
.card-warn    { border-color: var(--warn); background: var(--warn-soft); }
.card-flat    { box-shadow: none; }

/* --------------------------------------------------------------- Kennzahl */
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  min-width: 0;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  color: var(--text);
  white-space: nowrap;
}
.stat-unit {
  font-size: .8em;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: .18em;
}
.stat-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.stat.is-accent .stat-value { color: var(--accent-2); }
.stat.is-ok     .stat-value { color: var(--ok); }
.stat.is-warn   .stat-value { color: var(--warn); }
.stat.is-danger .stat-value { color: var(--danger); }

/* -------------------------------------------------- Grosse Geschwindigkeit */
.speed-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .15em;
  font-variant-numeric: tabular-nums;
  line-height: .95;
  letter-spacing: -.03em;
  font-weight: 800;
  font-size: clamp(4.5rem, 30vw, 9rem);
  color: var(--text);
  padding: 4px 0;
}
.speed-big .speed-unit {
  font-size: .2em;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.speed-big.is-moving { color: var(--ok); }
.speed-big.is-stopped { color: var(--warn); }

/* --------------------------------------------------------------- Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-3);
  color: var(--text);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-ok     { background: var(--ok-soft);     border-color: var(--ok);     color: var(--ok); }
.badge-warn   { background: var(--warn-soft);   border-color: var(--warn);   color: var(--warn); }
.badge-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.badge-accent { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.badge-dot::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* --------------------------------------------------------------- Toasts */
#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100vw - 24px));
  pointer-events: none;
}
/* Sichtbar ist der Ausgangszustand — eine Meldung darf nie an einer nicht
   gelaufenen Animation haengen bleiben. Ausgeblendet wird ueber .is-out. */
.toast {
  pointer-events: auto;
  background: var(--bg-3);
  color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 1;
  transform: translateY(0);
  transition: opacity .18s ease, transform .18s ease;
}
body.no-nav #toasts { top: auto; bottom: calc(var(--safe-b) + 12px); }
.toast.is-out { opacity: 0; transform: translateY(10px); }
.toast-ok     { border-color: var(--ok);     background: var(--bg-2); color: var(--ok); }
.toast-warn   { border-color: var(--warn);   background: var(--bg-2); color: var(--warn); }
.toast-error  { border-color: var(--danger); background: var(--bg-2); color: var(--danger); }
.toast-info   { border-color: var(--accent); background: var(--bg-2); color: var(--accent-2); }

/* -------------------------------------------------------------- Tabellen */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  background: var(--bg-2);
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-3);
  white-space: nowrap;
}
.table td.num, .table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-alarm { background: var(--danger-soft); }
.table-zebra tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-3) 45%, transparent); }

/* ------------------------------------------------------------ Formulare */
.field { display: block; margin-bottom: var(--gap); }
.field > .label,
.label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.hint { display: block; font-size: .82rem; color: var(--text-dim); margin-top: 5px; }

.input, .select, textarea.input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--bg-inset);
  border: 2px solid var(--border-strong);
  border-radius: var(--r-sm);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.4; }
.input::placeholder { color: var(--text-dim); }
.input:disabled, .select:disabled { opacity: .55; }
.select {
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--gap);
}
.form-error {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-weight: 700;
  margin-bottom: var(--gap);
}
.form-ok {
  border: 2px solid var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-weight: 700;
  margin-bottom: var(--gap);
}

/* --------------------------------------------------------------- Schalter */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
}
.switch-track {
  position: relative;
  flex: none;
  width: 62px;
  height: 34px;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  border: 2px solid var(--border-strong);
  transition: background-color .15s ease, border-color .15s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform .15s ease, background-color .15s ease;
}
.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(28px);
  background: var(--accent-ink);
}
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.switch-label { font-weight: 600; }

/* ------------------------------------------------------------- Navigation */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 800;
  display: flex;
  align-items: stretch;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .35);
}
.nav-brand { display: none; }
.nav-items {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav-item {
  flex: 1 1 0;
  display: flex;
  min-width: 0;
}
.nav-link {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--nav-h);
  padding: 6px 2px;
  border: 0;
  border-top: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-link svg { width: 24px; height: 24px; flex: none; }
.nav-link:active { background: var(--bg-3); }
.nav-link.is-active {
  color: var(--accent-2);
  border-top-color: var(--accent);
  background: var(--accent-soft);
}
.nav-logout { display: flex; flex: 1 1 0; min-width: 0; margin: 0; }

/* Ab Tablet: Leiste nach oben */
@media (min-width: 721px) {
  body {
    padding-bottom: var(--safe-b);
    padding-top: calc(var(--nav-h) + var(--safe-t));
  }
  .nav {
    top: 0;
    bottom: auto;
    padding-top: var(--safe-t);
    padding-bottom: 0;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
    align-items: center;
    gap: 8px;
    padding-left: max(16px, var(--safe-l));
    padding-right: max(16px, var(--safe-r));
  }
  .nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
  }
  .nav-brand svg { width: 26px; height: 26px; color: var(--accent); }
  .nav-items { flex: 0 1 auto; margin-left: auto; }
  .nav-item { flex: 0 0 auto; }
  .nav-logout { flex: 0 0 auto; }
  .nav-link {
    flex-direction: row;
    gap: 8px;
    padding: 0 14px;
    font-size: .95rem;
    border-top: 0;
    border-bottom: 3px solid transparent;
  }
  .nav-link.is-active { border-bottom-color: var(--accent); }
  #toasts { bottom: auto; top: calc(var(--nav-h) + var(--safe-t) + 12px); }
}

/* ----------------------------------------------------------------- Karte */
.map {
  width: 100%;
  height: 55vh;
  height: 55dvh;
  min-height: 240px;
  background: var(--bg-inset);
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
  z-index: 0;
}
/* Fuellt den Rest des Fensters unter der Navigation */
.map-full {
  height: calc(100vh - var(--nav-h) - var(--map-offset, 0px));
  height: calc(100dvh - var(--nav-h) - var(--safe-b) - var(--safe-t) - var(--map-offset, 0px));
  min-height: 260px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}
.map-fill { flex: 1 1 auto; min-height: 200px; height: auto; }

/* Leaflet-Feinschliff (Standardmarker werden nie benutzt) */
.leaflet-container {
  background: var(--bg-inset);
  font-family: var(--font);
  font-size: .9rem;
}
.leaflet-control-attribution {
  background: rgba(0, 0, 0, .65) !important;
  color: #e8ecef !important;
  font-size: 11px !important;
  padding: 2px 6px !important;
}
.leaflet-control-attribution a { color: #ffb066 !important; }
@media (prefers-color-scheme: light) {
  .leaflet-control-attribution {
    background: rgba(255, 255, 255, .85) !important;
    color: #22282e !important;
  }
  .leaflet-control-attribution a { color: #a34f00 !important; }
}
.leaflet-bar a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 20px !important;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 10px 12px; font-size: .95rem; }
.leaflet-popup-content b { color: var(--accent-2); }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); }

/* Eigene Marker (L.divIcon) */
.bt-icon { background: none !important; border: 0 !important; }
.bt-arrow {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .7));
}
.bt-arrow-inner {
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 26px solid currentColor;
  transform-origin: 50% 65%;
}
.bt-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: currentColor;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .7);
}
.bt-label {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .75);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* ------------------------------------------------------------ Alarm-Overlay */
.alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-lg);
  padding: calc(var(--safe-t) + 18px) 18px calc(var(--safe-b) + 18px);
  background: var(--danger-bg);
  color: #fff;
  text-align: center;
  overflow-y: auto;
  animation: bt-alarm-pulse 1.1s ease-in-out infinite alternate;
}
@keyframes bt-alarm-pulse {
  from { background-color: #8c1108; }
  to   { background-color: #e02b1d; }
}
.alarm-overlay .alarm-title {
  font-size: clamp(2.4rem, 13vw, 4.5rem);
  font-weight: 900;
  letter-spacing: .04em;
  line-height: 1;
  margin: 0;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.alarm-overlay .alarm-sub {
  font-size: clamp(1.25rem, 6vw, 2rem);
  font-weight: 800;
  margin: 0;
}
.alarm-overlay .alarm-detail {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  max-width: 34rem;
  margin: 0;
}
.alarm-overlay a { color: #fff; font-weight: 800; }
.alarm-overlay .btn {
  background: #fff;
  color: #8c1108;
  border-color: #fff;
  min-width: min(340px, 100%);
}
.alarm-overlay .btn-ghost {
  background: transparent;
  color: #fff;
  border-color: #fff;
}
.alarm-actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: min(420px, 100%);
}

/* --------------------------------------------------------------- Spinner */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: bt-spin .8s linear infinite;
  vertical-align: -4px;
}
.spinner-lg { width: 42px; height: 42px; border-width: 4px; }
@keyframes bt-spin { to { transform: rotate(360deg); } }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Impuls fuer "lebt noch"-Anzeigen */
.pulse { animation: bt-pulse 1.6s ease-in-out infinite; }
@keyframes bt-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------------------------------------------------------- Listeneintrag */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex;
  align-items: center;
  gap: var(--gap);
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: inherit;
  text-decoration: none;
}
.list-item:active { background: var(--bg-3); }
.list-item.is-alarm { border-color: var(--danger); }
.list-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r);
}

/* Fortschritts-/Countdownbalken */
.bar {
  position: relative;
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
  transition: width .3s linear, background-color .3s linear;
}
.bar.is-warn > span   { background: var(--warn); }
.bar.is-danger > span { background: var(--danger); }

/* Diagramme (Canvas) */
.chart {
  width: 100%;
  height: 160px;
  display: block;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

/* -------------------------------------------------- Bewegung reduzieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .alarm-overlay { background: #b3130a; }
  .spinner { border-top-color: var(--accent); animation: none; }
  .btn:active { transform: none; }
}

/* --------------------------------------------------------------- Drucken */
@media print {
  .nav, #toasts, .alarm-overlay, .btn { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .card { border-color: #999; box-shadow: none; }
}
