/* ==========================================================================
   Interne Hotline – Stylesheet
   Farbwelt und Typografie sind aus dem CSS von https://www.w-medien.de
   (.wtv Württemberger Medien) übernommen:
     --mainColor #0054A8 · --secondColor #8BADDC · --fontColor #434656
     --specialColor #F9F871 · --greyLight #F6F6F6 · Roboto, Radius 10px
   ========================================================================== */

/* --------------------------------------------------------------------------
   Roboto – liegt lokal unter public/fonts und wird NICHT von Google geladen.
   Es ist die Variable-Font-Variante: eine Datei deckt 400 bis 700 ab.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/roboto-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/roboto-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Marke */
  --primary: #0054a8;
  --primary-dark: #003f7d;
  --primary-light: #0057ad;
  --primary-soft: #e6eff8;
  --second: #8baddc;
  --second-soft: #b6c6db;
  --accent: #f9f871;

  /* Flächen und Text */
  --bg: #f6f6f6;
  --surface: #ffffff;
  --surface-muted: #fafbfc;
  --text: #434656;
  --text-strong: #262b3a;
  --text-muted: #6f7486;
  --border: #e4e7ee;

  /* Status */
  --status-free: #1a9c5b;
  --status-free-soft: #e6f5ee;
  --status-busy: #e07b1f;
  --status-busy-soft: #fdf1e3;
  --status-offline: #808080;
  --status-offline-soft: #eeeeee;
  --danger: #b10000;
  --danger-soft: #fdeaea;

  /* Form */
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 10px 10px 64px 0 rgba(0, 0, 0, 0.07);
  --shadow-soft: 0 2px 10px 0 rgba(38, 43, 58, 0.06);
  --shadow-lift: 0 12px 32px 0 rgba(0, 84, 168, 0.16);
  --gradient: linear-gradient(180deg, #0057ad 0%, #0054a8 100%);
  --transition: all 0.25s ease;

  --font: 'Roboto', Verdana, Arial, sans-serif;
  --page-width: 1250px;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  color: var(--text-strong);
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 700;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { color: var(--primary-dark); text-decoration: underline; }

p { margin: 0 0 1em; }

/* ---------------------------------------------------------------- Header */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-header__inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.wordmark:hover { text-decoration: none; color: var(--primary); }

.wordmark__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gradient);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.nav {
  display: flex;
  gap: 0.35rem;
  margin-right: auto;
  flex-wrap: wrap;
}

.nav__link {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav__link:hover {
  background: var(--surface-muted);
  color: var(--primary);
  text-decoration: none;
}
.nav__link--mobile-only { display: none; }
.nav__link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

/* Erreichbarkeit: eigene Leiste ganz oben, ueber der Kopfzeile. Zwei grosse
   Felder - Klingelton und Anruf-Hinweise. Rot und pulsierend, solange etwas
   fehlt, damit es niemandem entgeht; gruen und ruhig, wenn alles an ist. */
/* Die Leiste selbst ist hell wie die Kopfzeile; Farbe tragen nur die beiden
   Felder - in den Statusfarben, die die Anwendung ohnehin benutzt (gruen
   "frei", rot "Gefahr", orange "beschaeftigt"). */
.erreichbar {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}
.erreichbar[hidden] { display: none; }
.erreichbar__inner {
  max-width: var(--page-width);
  margin: 0 auto;
  display: flex;
  gap: 0.6rem;
  padding: 0.55rem max(1.5rem, env(safe-area-inset-right)) 0.55rem max(1.5rem, env(safe-area-inset-left));
}
.erreichbar__chip {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 46px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: background-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
}
.erreichbar__chip:hover { filter: brightness(0.97); }
.erreichbar__chip:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.erreichbar__symbol { font-size: 1.35rem; line-height: 1; }
.erreichbar__text { flex: 1; }

/* Alles gut: gruen, ruhig. */
.erreichbar__chip[data-state='an'] {
  background: var(--status-free);
  border-color: var(--status-free);
  color: #fff;
  animation: none;
}
/* Fehlt noch: rot und pulsierend - auch "blockiert". */
.erreichbar__chip[data-state='aus'],
.erreichbar__chip[data-state='blockiert'] {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: erreichbar-puls 1.4s ease-in-out infinite;
}
/* Der Browser fragt gerade: orange, pulsierend. */
.erreichbar__chip[data-state='wartet'] {
  background: var(--status-busy);
  border-color: var(--status-busy);
  color: #fff;
  animation: erreichbar-puls 1.4s ease-in-out infinite;
}
@keyframes erreichbar-puls {
  0%, 100% { box-shadow: 0 0 0 0 rgba(177, 0, 0, 0.45); }
  55% { box-shadow: 0 0 0 9px rgba(177, 0, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .erreichbar__chip { animation: none !important; }
}
.user-box__name { color: var(--text-strong); font-weight: 500; }
.user-box__link { color: var(--text-muted); font-size: 0.85rem; }
.user-box__form { margin: 0; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}
.badge--admin { background: var(--accent); color: #5c5a00; }

/* ------------------------------------------------------------------ Page */

.page {
  flex: 1;
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-head p { color: var(--text-muted); margin: 0; }

.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------- Cards */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card--flat { box-shadow: none; border: 1px solid var(--border); }
.card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.card__title h2, .card__title h3 { margin: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* --------------------------------------------------------- Status-Karte */

.status-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  border-left: 6px solid var(--status-offline);
  transition: border-color 0.35s ease, background 0.35s ease;
}
.status-card[data-state='frei'] { border-left-color: var(--status-free); }
.status-card[data-state='im-gespraech'] { border-left-color: var(--status-busy); }
.status-card[data-state='nicht-online'] { border-left-color: var(--status-offline); }
.status-card[data-state='niemand-eingeteilt'] { border-left-color: var(--danger); }

.status-card__main { flex: 1 1 320px; min-width: 0; }
.status-card__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
}
.status-card__person {
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem);
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.15;
  margin: 0 0 0.5rem;
  word-break: break-word;
}
.status-card__meta { color: var(--text-muted); font-size: 0.92rem; margin: 0; }
.status-card__actions { display: flex; flex-direction: column; gap: 0.75rem; align-items: stretch; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.92rem;
  background: var(--status-offline-soft);
  color: var(--status-offline);
  transition: var(--transition);
}
.status-pill__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.status-pill[data-state='frei'] { background: var(--status-free-soft); color: var(--status-free); }
.status-pill[data-state='frei'] .status-pill__dot { animation: pulse 2s ease-in-out infinite; }
.status-pill[data-state='im-gespraech'] { background: var(--status-busy-soft); color: var(--status-busy); }
.status-pill[data-state='nicht-online'] { background: var(--status-offline-soft); color: var(--status-offline); }
.status-pill[data-state='niemand-eingeteilt'] { background: var(--danger-soft); color: var(--danger); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26, 156, 91, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(26, 156, 91, 0); }
}

/* --------------------------------------------------------------- Buttons */

/* Das hidden-Attribut muss immer gewinnen - auch gegen display: inline-flex
   der Knoepfe. Sonst stehen "Bildschirm teilen" auf dem Handy oder "Hinweise
   erlauben" im blockierten Zustand sichtbar herum. */
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.7rem 1.3rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface-muted);
  color: var(--text-strong);
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--primary { background: var(--gradient); color: #fff; box-shadow: var(--shadow-lift); }
.btn--primary:hover { color: #fff; background: var(--primary-dark); }
.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text-strong); }
.btn--secondary:hover { border-color: var(--second); color: var(--primary); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn--ghost:hover { color: var(--primary); border-color: var(--second); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #8f0000; color: #fff; }
.btn--success { background: var(--status-free); color: #fff; }
.btn--success:hover { background: #157c48; color: #fff; }
.btn--big { padding: 1rem 2rem; font-size: 1.1rem; font-weight: 700; border-radius: var(--radius-lg); }
.btn--small { padding: 0.35rem 0.75rem; font-size: 0.83rem; }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- Formen */

.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.85rem; font-weight: 500; color: var(--text-strong); }
.field small { color: var(--text-muted); font-size: 0.78rem; }

input[type='text'],
input[type='password'],
input[type='date'],
input[type='datetime-local'],
select,
textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--second-soft);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  width: 100%;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 90px; }

/* --------------------------------------------------------------- Tabelle */

.table-wrap { overflow-x: auto; margin: 0 -0.5rem; padding: 0 0.5rem; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 640px;
}
table.data th {
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data tbody tr { transition: background 0.15s ease; }
table.data tbody tr:hover { background: var(--surface-muted); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------- Chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}
.chip--muted { background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border); }

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  background: var(--status-offline-soft);
  color: var(--text-muted);
}
.status-tag[data-status='angenommen'] { background: var(--status-free-soft); color: var(--status-free); }
.status-tag[data-status='verpasst'] { background: var(--danger-soft); color: var(--danger); }
.status-tag[data-status='abgelehnt'] { background: var(--status-busy-soft); color: var(--status-busy); }
.status-tag[data-status='rückruf offen'] { background: #fff6dd; color: #8a6100; }
.status-tag[data-status='erledigt'] { background: var(--primary-soft); color: var(--primary); }

/* ----------------------------------------------------------- Stat-Kacheln */

.stat {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.25rem;
}
.stat__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 500;
}
.stat__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.1;
  margin-top: 0.25rem;
}
.stat__hint { font-size: 0.82rem; color: var(--text-muted); }

/* --------------------------------------------------------------- Hinweise */

.flash {
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.25rem;
  font-size: 0.93rem;
  border: 1px solid transparent;
  animation: slide-in 0.3s ease;
}
.flash--erfolg { background: var(--status-free-soft); color: #0f6b3d; border-color: #bfe4d1; }
.flash--fehler { background: var(--danger-soft); color: var(--danger); border-color: #f1c6c6; }
.flash--info { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--second-soft); }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.notice {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.notice--warn { background: #fff8e6; border-color: #f0dfae; color: #7a5b00; }
.notice--info { background: var(--primary-soft); border-color: var(--second-soft); color: var(--primary-dark); }
.notice--rec { background: var(--danger-soft); border-color: #f1c6c6; color: var(--danger); }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty__icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; opacity: 0.5; }

/* ------------------------------------------------------------ Login-Seite */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: linear-gradient(160deg, #f6f6f6 0%, #e6eff8 100%);
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 430px;
}
.auth-card .wordmark { font-size: 1.35rem; margin-bottom: 1.5rem; }
.auth-card .field + .field { margin-top: 1rem; }
.auth-card .btn { margin-top: 1.5rem; }

/* -------------------------------------------------------------- Anruf-UI */

.ring-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 43, 58, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
  animation: fade-in 0.2s ease;
}
.ring-overlay[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.ring-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: pop-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.ring-box__avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  animation: ring-shake 1.2s ease-in-out infinite;
}
@keyframes ring-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-7deg); }
  40% { transform: rotate(7deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(4deg); }
}

.ring-box__label { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.07em; }
.ring-box__name { font-size: 1.6rem; font-weight: 700; color: var(--text-strong); margin: 0.25rem 0 0.5rem; }
.ring-box__timer { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.ring-box__actions { display: flex; gap: 0.75rem; }
.ring-box__actions .btn { flex: 1; }

.call-panel {
  background: var(--gradient);
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  animation: slide-in 0.3s ease;
}
.call-panel[hidden] { display: none; }
.call-panel h2 { color: #fff; margin: 0 0 0.25rem; }
.call-panel__peer { font-size: 1.6rem; font-weight: 700; }
.call-panel__timer {
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.call-panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.call-panel__actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.call-panel .btn--secondary { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.call-panel .btn--secondary:hover { background: rgba(255, 255, 255, 0.28); color: #fff; }
/* "Chat öffnen" war als Geister-Knopf grau auf blau kaum zu erkennen - auf
   dem Handy fanden die Leute den Chat deshalb nicht. Im blauen Panel sehen
   Geister-Knoepfe wie die weissen Zweitknoepfe aus. */
.call-panel .btn--ghost { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.55); color: #fff; }
.call-panel .btn--ghost:hover { background: rgba(255, 255, 255, 0.28); color: #fff; }
.call-panel .notice {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #eef4fb;
  margin-top: 1rem;
}
.call-panel__state { font-size: 0.85rem; opacity: 0.85; }

.rec-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5a5a;
  margin-right: 0.4rem;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --------------------------------------------------------------- Details */

details.transcript {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--surface-muted);
}
details.transcript summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--primary);
}
details.transcript p {
  margin-top: 0.85rem;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 0.93rem;
}

.bullets { margin: 0; padding-left: 1.2rem; }
.bullets li { margin-bottom: 0.4rem; }

audio { width: 100%; margin-top: 0.5rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.5rem 1.25rem; font-size: 0.93rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-strong); }

.chart-box { position: relative; height: 300px; }

.bar-list { display: flex; flex-direction: column; gap: 0.6rem; }
.bar-list__row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 0.75rem; align-items: center; font-size: 0.9rem; }
.bar-list__track { background: var(--surface-muted); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-list__fill { background: var(--gradient); height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.bar-list__value { font-variant-numeric: tabular-nums; color: var(--text-muted); }

/* Stapel unten rechts: Hinweis-Kasten ueber Ton-Kasten. */
.hinweis-stapel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  pointer-events: none;
}
.hinweis-stapel > * { pointer-events: auto; }

.audio-hint {
  background: var(--surface);
  border: 1px solid var(--second-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
  max-width: 330px;
  font-size: 0.88rem;
  animation: slide-in 0.3s ease;
}
.audio-hint[hidden] { display: none; }
.audio-hint .btn { margin-top: 0.6rem; }
/* Schmale Variante nach einem Neuladen: kein Knopf, nur die Zeile. */
.audio-hint--klein { padding: 0.6rem 0.85rem; max-width: 300px; border-color: var(--border); }
.audio-hint--klein strong { font-size: 0.85rem; }
.audio-hint--klein p { font-size: 0.8rem; color: var(--text-muted); }
.audio-hint--klein .btn { display: none; }
.audio-hint .btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.notify-schritte { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.notify-schritte li { margin-bottom: 0.25rem; }
.notify-alternativ { margin-top: 0.5rem; color: var(--text-muted); }
.notify-alternativ code { font-size: 0.78rem; user-select: all; }
.audio-hint .btn-row .btn { margin-top: 0.6rem; }

/* --- Dienstplan: Wochenansicht ---------------------------------------- */
.woche__kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.woche__kopf .card__title { margin-bottom: 0; }
.woche__nav .btn.is-aktiv { background: var(--primary-soft); color: var(--primary-dark); }

.woche__raster {
  --zeilen-hoehe: 44px;
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.woche__tag { min-width: 0; border-left: 1px solid var(--border); }
.woche__tag-kopf {
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}
.woche__wochentag { font-weight: 600; font-size: 0.85rem; color: var(--text-strong); }
.woche__datum { font-size: 0.72rem; color: var(--text-muted); }
.woche__tag.is-heute .woche__tag-kopf { background: var(--primary-soft); }
.woche__tag.is-heute .woche__wochentag { color: var(--primary-dark); }

.woche__spalte,
.woche__zeiten-spalte {
  position: relative;
  height: calc(var(--stunden) * var(--zeilen-hoehe));
}
.woche__spalte {
  background: repeating-linear-gradient(
    to bottom,
    var(--border) 0,
    var(--border) 1px,
    transparent 1px,
    transparent var(--zeilen-hoehe)
  );
}
.woche__tag.is-heute .woche__spalte { background-color: rgba(0, 84, 168, 0.03); }
.woche__stunde {
  position: absolute;
  right: 0.35rem;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.woche__leer { display: none; }

.woche__block {
  position: absolute;
  left: 3px;
  right: 3px;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  background: var(--farbe, var(--primary));
  color: #fff;
  font-size: 0.74rem;
  line-height: 1.2;
  overflow: hidden;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  min-height: 18px;
}
a.woche__block:hover { filter: brightness(1.1); color: #fff; }
.woche__block-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.woche__block-zeit { opacity: 0.9; white-space: nowrap; font-variant-numeric: tabular-nums; }
.woche__block.is-aktiv { outline: 2px solid #fff; outline-offset: -3px; }
.woche__block.is-beendet { opacity: 0.6; background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, 0.18) 6px 12px); }
.woche__block.is-fortsetzung { border-top-left-radius: 0; border-top-right-radius: 0; }
.woche__block.is-laeuft-weiter { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.woche__jetzt {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--danger);
  pointer-events: none;
}
.woche__jetzt::before {
  content: '';
  position: absolute;
  left: -1px;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.woche__legende {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.85rem;
}
.person-farbe {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--farbe, var(--status-offline));
  margin-right: 0.4rem;
  vertical-align: 0;
  flex-shrink: 0;
}

/* Handy: Tage untereinander als Liste, keine Stundenachse. */
@media (max-width: 720px) {
  .woche__raster { display: block; border: 0; background: transparent; }
  .woche__zeiten { display: none; }
  .woche__tag { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; overflow: hidden; }
  .woche__tag-kopf { height: auto; flex-direction: row; justify-content: flex-start; gap: 0.5rem; padding: 0.45rem 0.75rem; }
  .woche__spalte { height: auto; background: none; padding: 0.4rem 0.6rem; display: flex; flex-direction: column; gap: 0.35rem; }
  .woche__leer { display: block; color: var(--text-muted); font-size: 0.85rem; padding: 0.1rem 0.15rem; }
  .woche__block { position: static; flex-direction: row; justify-content: space-between; align-items: center; gap: 0.75rem; font-size: 0.85rem; padding: 0.45rem 0.65rem; min-height: 40px; }
  .woche__block.is-fortsetzung, .woche__block.is-laeuft-weiter { border-radius: 6px; }
  .woche__jetzt { display: none; }
}

/* iPhone-Hinweis unter der Status-Karte (nur auf iOS eingeblendet) */
.ios-hinweis { margin: -0.5rem 0 1.25rem; line-height: 1.5; }

/* Meldungen zum Anruf auf Seiten ohne Status-Karte (Dienstplan, Protokoll …) */
.anruf-hinweis {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.anruf-hinweis[hidden] { display: none; }

/* Traeger fuer den Ton der Gegenstelle. Absichtlich nicht "display: none" und
   auch nicht per width/height 0 entfernt: Safari auf dem iPhone stoppt die
   Wiedergabe in Elementen, die gar nicht dargestellt werden. Deshalb bleibt es
   ein reales, aber unsichtbares 1x1-Pixel-Element. */
.remote-media {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }


/* ==========================================================================
   Responsive – Tablet und Smartphone
   Reihenfolge: Tablet (<=1024px) → Phone (<=720px) → Karten-Tabellen (<=680px)
   ========================================================================== */

/* Immer: Touch-freundliche Grundlagen ------------------------------------- */

html {
  /* Verhindert, dass iOS beim Drehen die Schrift eigenmächtig vergrößert. */
  -webkit-text-size-adjust: 100%;
}

button,
.btn,
a,
select,
summary,
input[type='checkbox'] {
  /* Kein grauer Blitz beim Antippen, keine 300 ms Verzögerung. */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Sperrt das Scrollen der Seite, solange ein Anruf-Overlay offen ist. */
body.is-locked {
  overflow: hidden;
  /* Verhindert das "Durchscrollen" hinter dem Overlay auf iOS. */
  touch-action: none;
}

/* Sicherheitsabstand für Geräte mit Notch / Home-Indicator. */
.app-header__inner,
.page,
.app-footer {
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
}

/* ------------------------------------------------------------- Tablet */

@media (max-width: 1024px) {
  .page { padding-top: 1.5rem; }
  .status-card { padding: 1.75rem; gap: 1.5rem; }
  .chart-box { height: 260px; }
}

/* -------------------------------------------------------------- Phone */

@media (max-width: 720px) {
  :root {
    --page-width: 100%;
  }

  /* Kopfzeile: Zeile 1 Wortmarke + Person, Zeile 2 scrollbare Navigation */
  .app-header__inner {
    padding-top: 0.6rem;
    padding-bottom: 0;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    gap: 0.5rem;
    row-gap: 0;
  }
  .wordmark { font-size: 1.05rem; margin-right: auto; }

  .user-box {
    gap: 0.5rem;
    font-size: 0.8rem;
    max-width: 55%;
  }
  .user-box__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* "Name ändern" ist auf dem Handy über das Menü erreichbar. */
  .user-box__link { display: none; }
  /* Erreichbarkeits-Leiste: untereinander, volle Breite. */
  .erreichbar__inner {
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 0.5rem max(0.75rem, env(safe-area-inset-left));
  }
  .erreichbar__chip { font-size: 0.9rem; min-height: 44px; }

  .nav {
    order: 3;
    width: calc(100% + 2rem);
    margin: 0.5rem -1rem 0;
    padding: 0 1rem 0.6rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav__link--mobile-only { display: block; }
  .nav__link {
    flex: none;
    scroll-snap-align: start;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
  }

  .page { padding: 1.25rem 1rem 2rem; }
  .page-head { margin-bottom: 1rem; gap: 0.75rem; }

  .card,
  .status-card,
  .stat {
    padding: 1.15rem;
    border-radius: 14px;
  }
  .card { margin-bottom: 1rem; }
  .grid { gap: 1rem; }
  .grid--2,
  .grid--3 { grid-template-columns: 1fr; }
  .grid--stats { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat__value { font-size: 1.6rem; }

  /* Statuskarte: Text oben, Aktionen darunter über die volle Breite */
  .status-card {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    border-left-width: 0;
    border-top: 5px solid var(--status-offline);
  }
  .status-card[data-state='frei'] { border-top-color: var(--status-free); }
  .status-card[data-state='im-gespraech'] { border-top-color: var(--status-busy); }
  .status-card[data-state='nicht-online'] { border-top-color: var(--status-offline); }
  .status-card[data-state='niemand-eingeteilt'] { border-top-color: var(--danger); }
  .status-card__main { flex: 1 1 auto; }
  .status-card__person { font-size: 1.75rem; }
  .status-card__actions { width: 100%; }
  .status-pill { align-self: flex-start; }

  /* Der wichtigste Knopf der App: groß und mit dem Daumen erreichbar. */
  #btn-call {
    width: 100%;
    min-height: 60px;
    font-size: 1.15rem;
  }
  #btn-callback-request { width: 100%; min-height: 48px; }

  /* Touch-Ziele nach den Plattform-Richtlinien (mind. 44 px) */
  .btn { min-height: 44px; padding: 0.7rem 1.1rem; }
  .btn--small { min-height: 38px; padding: 0.4rem 0.8rem; }
  .btn--big { min-height: 56px; }

  /* iOS zoomt beim Fokus, wenn die Schrift kleiner als 16 px ist. */
  input[type='text'],
  input[type='password'],
  input[type='date'],
  input[type='datetime-local'],
  select,
  textarea {
    font-size: 16px;
    padding: 0.75rem 0.85rem;
    min-height: 46px;
  }
  .form-grid { grid-template-columns: 1fr; gap: 0.85rem; }
  .field label { font-size: 0.88rem; }

  /* Laufendes Gespräch bleibt beim Scrollen sichtbar. Schmale Innenraender
     und leicht ueber den Seitenrand hinaus, damit der Chat fast die volle
     Bildschirmbreite bekommt. */
  .call-panel {
    position: sticky;
    top: 0;
    z-index: 45;
    padding: 1rem 0.55rem 0.7rem;
    margin-left: -0.45rem;
    margin-right: -0.45rem;
    border-radius: 12px;
  }
  .call-panel .notice { margin-left: 0.2rem; margin-right: 0.2rem; }
  .call-panel__row {
    flex-direction: column;
    /* Vom Desktop erbt die Zeile "flex-wrap: wrap". Eine umbrechende
       Spalten-Flexbox berechnet WebKit (iPhone) falsch: Die Knoepfe wurden
       hunderte Pixel hoch und lagen ueber Hinweis, Chat und der Karte
       darunter. Auf dem Handy wird nichts umgebrochen - es gibt nur eine Spalte. */
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.85rem;
    text-align: center;
  }
  .call-panel__peer { font-size: 1.3rem; }
  .call-panel__timer { font-size: 2.6rem; }
  .call-panel__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Zeilen so hoch wie ihr Inhalt - nie auf die Containerhoehe gedehnt. */
    grid-auto-rows: max-content;
    align-content: start;
    align-items: start;
    gap: 0.6rem;
  }
  .call-panel__actions .btn { min-height: 52px; height: auto; }
  /* Auf dem Handy gibt es kein "Bildschirm teilen" - damit "Auflegen" nicht
     allein in einer halben Zeile haengt, bekommt es die volle Breite. */
  .call-panel__actions .btn--danger { grid-column: 1 / -1; }

  /* Anruf-Overlays als bildschirmfüllendes Sheet */
  .ring-overlay { padding: 0; align-items: flex-end; }
  .ring-box {
    max-width: none;
    width: 100%;
    min-height: 78vh;
    min-height: 78dvh;
    border-radius: 20px 20px 0 0;
    padding: 2rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    animation: sheet-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05);
  }
  .ring-box__avatar { width: 92px; height: 92px; font-size: 2.1rem; }
  .ring-box__name { font-size: 1.9rem; }
  .ring-box__actions {
    flex-direction: column-reverse;
    margin-top: auto;
    padding-top: 1.5rem;
    gap: 0.75rem;
  }
  .ring-box__actions .btn { min-height: 58px; font-size: 1.05rem; }
  #note-overlay .ring-box { min-height: auto; justify-content: flex-start; }
  #note-overlay .ring-box__actions { flex-direction: column-reverse; }

  /* Hinweise zum Ton: volle Breite unten, statt kleiner Kacheln in der Ecke */
  .hinweis-stapel {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  .audio-hint { max-width: none; }
  .audio-hint .btn { width: 100%; }
  .audio-hint .btn-row .btn { width: auto; flex: 1; }

  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.6rem; }
  .kv dd { margin-bottom: 0.1rem; }

  .chart-box { height: 230px; }
  .bar-list__row { grid-template-columns: minmax(70px, 38%) 1fr auto; font-size: 0.85rem; }

  .app-footer { flex-direction: column; gap: 0.35rem; font-size: 0.78rem; padding: 0.85rem 1rem; }

  audio { height: 44px; }
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------- Tabellen werden zu Karten */

@media (max-width: 680px) {
  .table-wrap { overflow-x: visible; margin: 0; padding: 0; }

  table.data { display: block; min-width: 0 !important; font-size: 0.92rem; }
  table.data thead {
    /* Für Screenreader erhalten, optisch entfernt – die Beschriftung
       steht auf dem Handy vor jedem Wert. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  table.data tbody { display: block; }

  table.data tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.7rem;
    background: var(--surface);
  }
  table.data tbody tr:hover { background: var(--surface); }
  table.data tr:last-child { margin-bottom: 0; }

  table.data td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.28rem 0;
    border: none;
    text-align: right;
    min-width: 0;
  }
  table.data td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    padding-top: 0.1rem;
  }
  /* Zellen ohne Beschriftung (Aktionen, Links) nehmen die volle Breite. */
  table.data td[data-label='']::before,
  table.data td:not([data-label])::before { content: none; }
  table.data td[data-label=''],
  table.data td:not([data-label]) { justify-content: stretch; text-align: left; }
  table.data td[data-label=''] .btn-row { width: 100%; margin-top: 0.5rem; }
  table.data td[data-label=''] .btn-row .btn { flex: 1; }

  table.data td .bullets { text-align: left; padding-left: 1rem; }
  table.data td > div.small { text-align: right; }
}

@media (max-width: 400px) {
  .grid--stats { grid-template-columns: 1fr; }
  .status-card__person { font-size: 1.5rem; }
  .call-panel__timer { font-size: 2.2rem; }
  .wordmark__text { font-size: 0.95rem; }
}

/* Querformat auf dem Handy: Overlays dürfen nicht höher als der Schirm sein. */
@media (max-height: 480px) and (orientation: landscape) {
  .ring-box { min-height: 100vh; min-height: 100dvh; padding: 1rem; justify-content: flex-start; }
  .ring-box__avatar { width: 54px; height: 54px; font-size: 1.3rem; margin-bottom: 0.5rem; }
  .ring-box__name { font-size: 1.3rem; }
  .ring-box__actions { flex-direction: row; padding-top: 0.75rem; }
  .call-panel { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Filterleiste (Protokoll und Auswertung)
   ========================================================================== */

.filterbar { padding: 1.25rem 1.5rem; }

.filterbar__row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem 1rem;
  align-items: end;
}

/* Das Suchfeld bekommt mehr Platz als die Auswahlfelder. */
.filterbar__search { grid-column: span 2; }
.filterbar__dates { grid-column: span 2; }
.filterbar__dates-inputs { display: flex; gap: 0.5rem; }
.filterbar__dates-inputs input { min-width: 0; }

.filterbar__more {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.filterbar__more > summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--primary);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.filterbar__more > summary::-webkit-details-marker { display: none; }
.filterbar__more > summary::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-soft);
  font-weight: 700;
  line-height: 1;
}
.filterbar__more[open] > summary::before { content: '–'; }

.checkline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 400;
  cursor: pointer;
  min-height: 46px;
}
.checkline input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex: none;
  margin: 0;
}

.filterbar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.filterbar__count { font-size: 0.92rem; color: var(--text-strong); }
.filterbar__export { margin-left: auto; }

.filterbar__chips {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.chip--removable {
  background: var(--primary-soft);
  color: var(--primary);
  padding-right: 0.4rem;
  transition: var(--transition);
}
.chip--removable:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}
.chip__x {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.6;
  padding: 0 0.15rem;
}
.chip--removable:hover .chip__x { opacity: 1; }

input[type='number'] {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--second-soft);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  width: 100%;
  transition: var(--transition);
}
input[type='number']:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

@media (max-width: 720px) {
  .filterbar { padding: 1.15rem; }
  .filterbar__row { grid-template-columns: 1fr; gap: 0.75rem; }
  .filterbar__search,
  .filterbar__dates { grid-column: span 1; }
  .filterbar__actions { gap: 0.6rem; }
  .filterbar__actions .btn { flex: 1 1 auto; }
  .filterbar__count { order: -1; width: 100%; }
  .filterbar__export { margin-left: 0; width: 100%; }
  input[type='number'] { font-size: 16px; min-height: 46px; }
}

/* Rollenkennzeichnung im Kopfbereich */
.badge--vertrieb { background: var(--primary-soft); color: var(--primary); }

/* ==========================================================================
   Servicezeiten auf dem Dashboard
   ========================================================================== */

.servicezeit__kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.servicezeit__liste {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.servicezeit__liste li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-muted);
}
.servicezeit__tag { flex: 1 1 auto; color: var(--text-strong); font-weight: 500; }
.servicezeit__uhr {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .servicezeit__kopf { margin-bottom: 0.75rem; }
  .servicezeit__liste li { padding: 0.6rem 0.75rem; }
}

/* Kontingent-Anzeige im Admin-Bereich (TURN-Verbrauch) ------------------ */
.kontingent { margin-bottom: 1rem; }
.kontingent__zahlen { font-size: 1.05rem; margin-bottom: 0.5rem; }
.kontingent__zahlen strong { font-size: 1.5rem; }
.kontingent__balken {
  height: 14px;
  border-radius: 7px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.kontingent__fuellung {
  height: 100%;
  border-radius: 7px;
  background: var(--status-free);
  transition: width 0.4s ease;
}
/* Ab 80 % faellt es auf - vorher lohnt die Aufregung nicht. */
.kontingent__fuellung[style*="width:8"],
.kontingent__fuellung[style*="width:9"],
.kontingent__fuellung[style*="width:100"] { background: var(--danger); }

/* Laengere Texte in einer Kennzahl (z. B. "einsatzbereit"). */
.stat__value--klein { font-size: 1.3rem; }

/* Monatswahl im Seitenkopf */
.filter-inline { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.filter-inline input[type='month'] { font-size: 16px; }

/* Zeitstempel-Tabelle im Admin-Bereich (TURN-Zugang) -------------------- */
.data--kompakt th[scope='row'] {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  width: 1%;
}
.data--kompakt code {
  font-size: 0.92rem;
  background: var(--surface-muted);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
/* Erneuerung steht an - auffaellig, aber kein Alarm. */
.zeile--faellig th[scope='row'],
.zeile--faellig td { background: var(--status-busy-soft); }
.zeile--faellig th[scope='row'] { color: var(--status-busy); font-weight: 700; }

/* ==========================================================================
   Chat, Dateien und Bildschirmfreigabe im Gespräch
   ========================================================================== */

/* Für Screenreader sichtbar, optisch nicht. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Arbeitsfläche: am Rechner nebeneinander, sobald Platz ist ------------- */
.call-workspace {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  /* Ohne geteilten Bildschirm nimmt der Chat die volle Breite. */
  grid-template-columns: 1fr;
}
.call-workspace:has(.screen-box.is-aktiv) {
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
}

/* --- Geteilter Bildschirm --------------------------------------------- */
.screen-box {
  background: #10131a;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.screen-box[hidden] { display: none; }

.screen-box__kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  color: #e8eaf0;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.06);
}
.screen-box__titel {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.screen-box__aktionen { display: flex; gap: 0.35rem; flex-shrink: 0; }
.screen-box__aktionen .btn {
  color: #e8eaf0;
  border-color: rgba(255, 255, 255, 0.25);
}
.screen-box__aktionen .btn:hover { background: rgba(255, 255, 255, 0.12); }

.screen-box__video {
  width: 100%;
  /* Bildschirme sind meist 16:9 – der Kasten behält die Höhe, auch wenn
     noch kein Bild da ist, damit die Seite nicht springt. */
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  object-fit: contain;
  background: #000;
  /* Nur mit Bild der Gegenstelle - teilt man allein, bleibt das leere
     Video weg und die eigene rote Vorschau bekommt den Platz. */
  display: none;
}
.screen-box.is-fremd .screen-box__video { display: block; }

/* Eigene Freigabe: rot umrandete Live-Vorschau. Der Rahmen liegt bewusst
   um die Vorschau und nicht um den ganzen Kasten - er soll wie ein
   "Sucher" wirken: Das hier sieht die Gegenstelle. */
.screen-box__eigen {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.75rem;
  color: #e8eaf0;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.06);
}
.screen-box__eigen-kopf {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.9rem;
}
.screen-box__eigen-kopf strong { color: #ffb4b4; }
.screen-box__eigen-hinweis {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(232, 234, 240, 0.7);
}
.screen-box__vorschau {
  width: 100%;
  max-height: 46vh;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 6px;
  background: #000;
  border: 4px solid #e53935;
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.28);
  animation: freigabe-puls 1.6s ease-in-out infinite;
}
@keyframes freigabe-puls {
  0%, 100% { box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.28); }
  50% { box-shadow: 0 0 0 7px rgba(229, 57, 53, 0.08); }
}
@media (prefers-reduced-motion: reduce) {
  .screen-box__vorschau { animation: none; }
}
/* Sehen beide Seiten etwas, wird die eigene Vorschau zum kleinen Kasten. */
.screen-box.is-fremd .screen-box__eigen {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}
.screen-box.is-fremd .screen-box__vorschau {
  width: 168px;
  max-height: none;
  flex-shrink: 0;
  order: -1;
}
.screen-box.is-fremd .screen-box__eigen-hinweis { flex-basis: 100%; }

/* --- Chat -------------------------------------------------------------- */
.chat {
  display: flex;
  flex-direction: column;
  background: var(--surface-muted);
  /* Das Gesprächs-Panel ist blau mit weißer Schrift - der Chat sitzt als
     helle Karte darin und muss die Textfarbe zurücksetzen. */
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  /* Damit die Liste scrollt statt die Seite in die Länge zu ziehen. */
  max-height: 60vh;
}
.chat.is-drop { border-color: var(--primary); background: var(--primary-soft); }

.chat__kopf {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.chat__titel { margin: 0; font-size: 1rem; }
.chat__sub { font-size: 0.78rem; color: var(--text-muted); }
/* Hinweis "Antippen zum Öffnen" - nur auf dem Handy, wo der Chat zugeklappt beginnt. */
.chat__auf { display: none; margin-left: auto; font-size: 0.8rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.chat__kopf:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.chat__liste {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 140px;
  /* Auf dem Handy sonst ruckelig. */
  -webkit-overflow-scrolling: touch;
}
.chat__leer {
  margin: auto 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.chat__eintrag {
  max-width: 85%;
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 0.45rem 0.65rem;
}
.chat__eintrag--eigen {
  align-self: flex-end;
  background: var(--primary-soft);
  border-color: transparent;
  border-radius: 12px 12px 4px 12px;
}

/* Der Kopf im einzelnen Eintrag sieht anders aus als der Kopf des Chats. */
.chat__eintrag .chat__kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0;
  border: 0;
  margin-bottom: 0.15rem;
}
.chat__wer { font-size: 0.78rem; font-weight: 700; color: var(--text-strong); }
.chat__wann { font-size: 0.72rem; color: var(--text-muted); }
.chat__koerper {
  font-size: 0.93rem;
  line-height: 1.45;
  /* Eine lange Kundennummer ohne Leerzeichen soll den Kasten nicht sprengen. */
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Datei-Kachel im Verlauf */
.chat__datei {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.chat__datei:hover { border-color: var(--primary); text-decoration: none; }
.chat__datei-symbol { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.chat__datei-text { display: flex; flex-direction: column; min-width: 0; }
.chat__datei-name {
  font-weight: 500;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat__datei-meta { font-size: 0.75rem; color: var(--text-muted); }

.chat__hinweis {
  margin: 0;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.chat__hinweis.is-fehler { color: var(--danger); background: var(--danger-soft); }
.chat__hinweis[hidden] { display: none; }

.chat__form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat__anhang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 44px: die kleinste Fläche, die sich am Touchscreen zuverlässig trifft. */
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 1.2rem;
  background: var(--surface);
  transition: var(--transition);
}
.chat__anhang:hover { border-color: var(--primary); background: var(--primary-soft); }
.chat__anhang.is-disabled { opacity: 0.45; pointer-events: none; }
.chat__anhang.is-busy { opacity: 0.6; pointer-events: none; }
.chat__datei-feld { display: none; }

.chat__text {
  flex: 1;
  min-width: 0;
  resize: none;
  /* 16px verhindert, dass iOS beim Antippen hineinzoomt. */
  font-size: 16px;
  font-family: inherit;
  line-height: 1.4;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 120px;
  overflow-y: auto;
}
.chat__text:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.chat__text:disabled { background: var(--surface-muted); color: var(--text-muted); }

.chat__form .btn { height: 44px; flex-shrink: 0; }
.chat__fuss { padding: 0 0.85rem 0.6rem; margin: 0; font-size: 0.75rem; }

/* Zähler für ungelesene Nachrichten am Umschalt-Knopf */
.chat-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 0.35rem;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}
.chat-badge[hidden] { display: none; }

/* Ein aktiver Umschalt-Knopf (z. B. „Freigabe beenden") */
.btn--aktiv {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* --- Geteilte Dateien im Dashboard ------------------------------------ */
.dateiliste { list-style: none; margin: 0; padding: 0; }
.dateiliste__eintrag {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.dateiliste__eintrag:last-child { border-bottom: 0; }
.dateiliste__link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.dateiliste__link:hover .dateiliste__name { text-decoration: underline; }
.dateiliste__name { font-weight: 500; color: var(--primary); overflow-wrap: anywhere; }
.dateiliste__meta { font-size: 0.78rem; color: var(--text-muted); }
.dateiliste__gespraech { display: block; font-size: 0.75rem; }

/* --- Handy und kleine Tablets ----------------------------------------- */
@media (max-width: 900px) {
  /* Nebeneinander wird zu eng - untereinander bleibt beides lesbar. */
  .call-workspace,
  .call-workspace:has(.screen-box.is-aktiv) {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  /* Aufgeklappt bekommt der Chat richtig Platz: volle Breite des Panels,
     mindestens gut die Haelfte des Bildschirms, hoechstens vier Fuenftel -
     dann scrollt der Verlauf statt der Seite. */
  .chat { max-height: none; border-radius: 10px; }
  .chat:not(.is-zu) { min-height: 62vh; min-height: 62dvh; max-height: 80vh; max-height: 80dvh; }
  .chat__liste { min-height: 220px; padding: 0.6rem 0.6rem; }
  .chat__kopf { padding: 0.6rem 0.7rem; }
  .chat__form { padding: 0.5rem 0.6rem; }
  .chat__fuss { padding: 0 0.7rem 0.5rem; }
  .chat__eintrag { max-width: 94%; }
  .screen-box__video { max-height: 40vh; }
  /* Zugeklappt bleibt nur der Knopf im Gesprächskopf stehen. */
  .chat.is-zu .chat__liste,
  .chat.is-zu .chat__form,
  .chat.is-zu .chat__fuss,
  .chat.is-zu .chat__hinweis { display: none; }
  .chat.is-zu { max-height: none; }
  .call-panel__chat-toggle { display: inline-flex; align-items: center; }
  /* Kopfzeile des Chats ist auf dem Handy der Klapp-Griff. */
  .chat > .chat__kopf { cursor: pointer; min-height: 48px; align-items: center; flex-wrap: wrap; }
  .chat__auf { display: inline; }
  .chat.is-zu > .chat__kopf { border-bottom: 0; }

  /* Das Gesprächs-Panel klebt am oberen Rand, damit man es beim Scrollen
     nicht verliert. Mit offenem Chat wäre es aber so hoch, dass darunter
     nichts mehr zu sehen ist - dann klebt es nicht. */
  .call-panel:has(.chat:not(.is-zu)) { position: static; }
}

/* Am Rechner braucht es den Umschalter nicht - der Chat steht ohnehin da. */
@media (min-width: 721px) {
  .call-panel__chat-toggle { display: none; }
}

/* Chatverlauf in der Admin-Detailansicht -------------------------------- */
.chatlog { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.chatlog__eintrag { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.chatlog__eintrag:last-child { border-bottom: 0; }
.chatlog__kopf {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.chatlog__kopf strong { color: var(--text-strong); }
.chatlog__text { font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.chatlog__datei { font-size: 0.92rem; overflow-wrap: anywhere; }
