/* Status-Funk – hell und ruhig (iOS-artig) mit dunkelblauen Akzenten. */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --navy: #0f1b33;
  --navy-2: #1e2b47;
  --red: #dc2626;
  --ok: #16a34a;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 27, 51, 0.04), 0 4px 16px rgba(15, 27, 51, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 27, 51, 0.16);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.caps {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 8px 14px;
  border-radius: 10px;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: #f9fafb; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--red); }
.btn.on { color: var(--ok); }
.btn:disabled { opacity: 0.35; cursor: default; }

input[type='text'], input[type='password'] {
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  width: 100%;
}
input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15, 27, 51, 0.12); }

/* Verbindungsanzeige */
.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.conn::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.conn.open::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.conn.connecting::before { background: #f59e0b; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ================================================================== Start */

.start {
  min-height: 100dvh;
  max-width: 440px;
  margin: 0 auto;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--navy);
  position: relative;
  flex: none;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.3);
}
.brand h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.start a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.1s;
}
.start a:active { transform: scale(0.98); }
.start a b { display: block; font-size: 18px; font-weight: 700; }
.start a span { color: var(--muted); font-size: 14px; }
.start a i { font-style: normal; color: var(--faint); font-size: 20px; }

/* =============================================================== Betreuer */

.betreuer {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.linkbtn { border: 0; background: none; padding: 4px 0; font-weight: 600; font-size: 15px; color: var(--navy); }

.select-head { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 16px 0 2px; }
.select-sub { margin: 0 0 16px; color: var(--muted); }
.group-list { display: flex; flex-direction: column; gap: 10px; }
.group-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  border: 0;
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  font-size: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform 0.1s;
}
.group-list button::after { content: '›'; font-size: 24px; color: var(--faint); line-height: 1; }
.group-list button:active { transform: scale(0.98); }
.empty { color: var(--muted); text-align: center; padding: 24px; font-size: 14px; }

/* Dunkelblauer Kopfbereich */
.hero {
  background: var(--navy);
  color: #fff;
  border-radius: 22px;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.hero .caps { color: #94a3b8; }
.hero .conn { color: #cbd5e1; }
.callsign {
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 8px;
  word-break: break-word;
}
.lcd {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 10px 12px;
}
.lcd .pill {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--c);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}
.lcd .pill.dim { background: rgba(255, 255, 255, 0.12); color: #94a3b8; }
.lcd b { display: block; font-size: 16px; font-weight: 600; }
.lcd small { display: block; font-size: 12px; color: #94a3b8; margin-top: 1px; }
#gps-lcd.live { color: #4ade80; }
#gps-lcd.off { color: #fca5a5; }

/* Halten-zum-Senden */
.hold {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  --p: 0;
  --c: var(--navy);
  transition: transform 0.12s ease, opacity 0.2s;
}
.hold::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--c);
  opacity: 0.22;
  transform-origin: left;
  transform: scaleX(var(--p));
  pointer-events: none;
}
.hold > * { position: relative; z-index: 1; pointer-events: none; }
.hold.holding { transform: scale(0.96); }
.hold:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.ready-btn {
  width: 100%;
  padding: 22px 16px;
  background: var(--ok);
  color: #fff;
  --c: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ready-btn::after { opacity: 0.3; }
.ready-btn b { font-size: 22px; font-weight: 700; }
.ready-btn small { font-size: 13px; opacity: 0.85; }

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 300px;
}
.status-btn {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  padding: 14px 16px 16px;
  min-height: 128px;
}
.status-btn .band { display: none; }
.status-btn .n { font-size: 56px; font-weight: 800; line-height: 1; color: var(--c); letter-spacing: -0.03em; }
.status-btn .l { font-size: 14px; font-weight: 600; line-height: 1.25; color: #374151; }
.status-btn.active { background: var(--c); box-shadow: 0 6px 20px color-mix(in srgb, var(--c) 40%, transparent); }
.status-btn.active .n, .status-btn.active .l { color: #fff; }
.status-btn.active::after { background: #fff; }
.status-btn.active::before {
  content: 'Aktiv';
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  color: var(--c);
  background: #fff;
  padding: 3px 9px;
  border-radius: 99px;
}

.hint { text-align: center; color: var(--faint); font-size: 13px; margin: 0; }

.feedback {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: 492px;
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: var(--navy);
  box-shadow: var(--shadow-lg);
  text-align: center;
  z-index: 50;
  animation: rise 0.2s ease-out;
}
.feedback.ok { background: var(--ok); }
.feedback.err { background: var(--red); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

/* ========================================================= Einsatzleitung */

.leitung-header {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.leitung-header .title { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.leitung-header .title i {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--navy);
  position: relative;
}
.leitung-header .title i::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--red);
}
.leitung-header h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.leitung-header h1 small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.clock {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  padding: 0 6px;
}

.sound-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 24px 0;
  padding: 12px 16px;
  background: #fff7e6;
  border: 1px solid #fde4b0;
  border-radius: 14px;
  color: #92400e;
  font-weight: 500;
}
.sound-banner span { flex: 1; }

.leitung-main {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr);
  gap: 24px;
  padding: 20px 24px 32px;
}
@media (max-width: 1000px) { .leitung-main { grid-template-columns: 1fr; } }

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 10px; }
.section-head .count { font-size: 13px; color: var(--muted); font-weight: 500; }

.tiles {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Eine Zeile pro Gruppe: Kachel links, Notizen rechts */
.group-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}
@media (max-width: 760px) { .group-row { grid-template-columns: 1fr; } }
.note {
  min-height: 100%;
  height: auto;
  resize: none;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}
.note::placeholder { color: var(--faint); }
.note:hover { border-color: var(--line); }
.note:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15, 27, 51, 0.12); }

.tile {
  --c: var(--faint);
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  min-height: 128px;
  transition: transform 0.12s, box-shadow 0.2s;
}
.tile:hover { transform: translateY(-1px); }
.tile:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--navy); }
.tile .num {
  background: var(--c);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.tile.idle .num { background: #f3f4f6; color: var(--faint); }
.tile .body { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; word-break: break-word; padding-right: 48px; }
.tile .lbl { font-size: 14px; font-weight: 600; color: var(--c); }
.tile.idle .lbl { color: var(--muted); }
.tile .meta { margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.tile .meta a { color: var(--navy); font-weight: 600; text-decoration: none; }
.tile .meta .live { color: var(--ok); font-weight: 700; }
.tile .meta .stale { color: #b45309; font-weight: 600; }

.tile .flag { display: none; position: absolute; top: 12px; right: 12px; }
.tile .flag span {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--c);
  padding: 3px 9px;
  border-radius: 99px;
}
.tile.unacked .flag { display: block; }
.tile.unacked { animation: ring 1.1s ease-in-out infinite; }
@keyframes ring {
  0%, 100% { box-shadow: 0 0 0 3px var(--c), 0 0 0 0 color-mix(in srgb, var(--c) 45%, transparent); }
  50% { box-shadow: 0 0 0 3px var(--c), 0 0 0 12px color-mix(in srgb, var(--c) 0%, transparent); }
}
.tile.unacked .num { animation: glow 1.1s ease-in-out infinite; }
@keyframes glow { 50% { filter: brightness(1.25); } }
@media (prefers-reduced-motion: reduce) {
  .tile.unacked, .tile.unacked .num { animation: none; box-shadow: 0 0 0 3px var(--c); }
}

/* rechte Spalte */
.side { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
#map { height: 380px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 1; background: #e5e7eb; }
.leaflet-container { font-family: var(--font); }

.log {
  list-style: none;
  margin: 0;
  padding: 4px 16px;
  max-height: 360px;
  overflow: auto;
  font-size: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.log li {
  display: grid;
  grid-template-columns: auto 28px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f1f2f4;
  align-items: center;
}
.log li:last-child { border-bottom: 0; }
.log time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log .pill {
  font-weight: 700;
  font-size: 12px;
  text-align: center;
  color: #fff;
  padding: 3px 0;
  border-radius: 7px;
}
.log b { font-weight: 600; }
.log .loc { font-size: 11px; color: var(--faint); margin-left: 6px; }

/* Popups */
.toasts {
  position: fixed;
  top: 76px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  width: min(380px, calc(100vw - 48px));
}
.toast {
  display: grid;
  grid-template-columns: 60px 1fr;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  animation: slidein 0.22s ease-out;
}
.toast .big { background: var(--c); color: #fff; display: grid; place-items: center; font-size: 30px; font-weight: 800; }
.toast div { padding: 12px 14px; }
.toast b { display: block; font-size: 16px; font-weight: 700; }
.toast small { color: var(--muted); font-size: 13px; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }

/* Login */
.center-card {
  max-width: 380px;
  margin: 14vh auto;
  padding: 28px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.center-card h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.error { color: var(--red); font-size: 13px; margin: 0; }

/* Dialog */
dialog {
  border: 0;
  border-radius: 22px;
  padding: 24px;
  width: min(540px, calc(100vw - 32px));
  background: var(--card);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 27, 51, 0.35); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 16px; font-size: 20px; font-weight: 700; }
.manage-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.manage-row .btn { padding: 9px 12px; }
.manage-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-foot { display: flex; justify-content: flex-end; margin-top: 18px; }

/* Kartenmarker */
.gmarker {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transform: translate(-15px, -15px);
  width: max-content;
}
.gmarker .dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #fff;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(15, 27, 51, 0.35);
}
.gmarker .tag {
  background: #fff;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15, 27, 51, 0.2);
}
.gmarker.stale { opacity: 0.5; }

/* Betreuer + Infos auf den Kacheln */
.tile .crew { font-size: 13px; color: #374151; margin-top: 4px; }
.tile .crew a { color: var(--navy); font-weight: 600; text-decoration: none; }
.tile .info {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}
.hero .crew { color: #cbd5e1; font-size: 14px; margin: -6px 0 8px; }

/* Gruppen verwalten */
#manage-list { max-height: 60vh; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.manage-card { padding: 12px 0; border-bottom: 1px solid var(--line); }
.manage-card:first-child { padding-top: 0; }
.manage-card .manage-row { margin-bottom: 6px; }
.manage-card .manage-row input { font-weight: 600; }
.manage-grid { display: grid; grid-template-columns: 1fr 160px; gap: 6px; margin-bottom: 6px; }
textarea {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15, 27, 51, 0.12); }
input[type='tel'] { font: inherit; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; width: 100%; }
input[type='tel']:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15, 27, 51, 0.12); }

/* Karte */
.head-right { display: flex; align-items: center; gap: 10px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.map-fit {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  border: 0;
  border-radius: 10px;
  padding: 7px 12px;
  box-shadow: 0 2px 8px rgba(15, 27, 51, 0.2);
  cursor: pointer;
}
.leaflet-popup-content-wrapper { border-radius: 14px; }
.leaflet-popup-content { font-size: 13px; line-height: 1.5; }

/* Ausgelagertes Kartenfenster */
.karte-page { height: 100vh; display: grid; grid-template-columns: 300px 1fr; }
.karte-side { background: var(--bg); padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; border-right: 1px solid var(--line); }
.karte-side h1 { font-size: 17px; margin: 0; font-weight: 700; }
.karte-side .sub { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
#karte-map { height: 100vh; }
.mini {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 0;
  text-align: left;
}
.mini .d { width: 40px; height: 40px; border-radius: 10px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.mini.idle .d { background: #f3f4f6; color: var(--faint); }
.mini.nogps { opacity: 0.55; }
.mini b { display: block; font-size: 14px; }
.mini small { display: block; font-size: 12px; color: var(--muted); }
@media (max-width: 700px) { .karte-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } #karte-map { height: 70vh; } }
