/* OrgaPilot.ORDER – Design System (basiert auf OrgaPilot WIS) */

:root {
  --bg-0: #0a0d14;
  --bg-1: #111520;
  --bg-2: #171c2d;
  --bg-3: #1e2436;
  --border: #252c40;
  --accent: #f79727;
  --accent-dark: #005480;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f79727;
  --blue: #005480;
  --text-primary: #e8ecf4;
  --text-secondary: #bcc6dd;
  --text-muted: #97a3bd;
  --prio-sofort: #ef4444;
  --prio-dringend: #f79727;
  --prio-normal: #22c55e;

  --status-neu: #6b7280;
  --status-übermittelt: #005480;
  --status-disponiert: #8b5cf6;
  --status-anfahrt: #f79727;
  --status-angekommen: #eab308;
  --status-transport: #005480;
  --status-abgeschlossen: #22c55e;
  --status-storniert: #ef4444;

  --sidebar-w: 220px;
  --topbar-h: 52px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

/* Light Mode Theme */
html[data-theme="light"] {
  --bg-0: #fafafa;
  --bg-1: #ffffff;
  --bg-2: #f3f4f6;
  --bg-3: #e5e7eb;
  --border: #d1d5db;
  --accent: #f79727;
  --accent-dark: #005480;
  --text-primary: #1f2937;
  --text-secondary: #374151;
  --text-muted: #6b7280;
}

html[data-theme="light"] .login-card {
  box-shadow: 0 24px 64px rgba(0,0,0,.12);
}

html[data-theme="light"] .modal {
  box-shadow: 0 24px 60px rgba(0,0,0,.15);
}

html[data-theme="light"] .cc-autofill-list {
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

html[data-theme="light"] .addr-suggestions {
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}

html[data-theme="light"] .tp-dropdown {
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}

html[data-theme="light"] .broadcast-popup-box {
  box-shadow: 0 8px 40px rgba(0,0,0,.15);
}

html[data-theme="light"] .toast {
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

html[data-theme="light"] .mission-tile:hover {
  box-shadow: 0 4px 20px rgba(247,151,39,.15);
}

html[data-theme="light"] .tile-time {
  color: #005480;
}

html[data-theme="light"] .modal-backdrop {
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── LOGIN ─────────────────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0;
  background: var(--bg-0);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

.login-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 44px;
  width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-brand-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 125px;
}
.login-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform: translateY(-50px);
}
.login-logo-img {
  display: block;
  width: 59px;
  max-width: 100%;
  height: auto;
  margin: 0;
  object-fit: contain;
}
.login-zkn-logo {
  display: block;
  width: 440px;
  max-width: 100%;
  height: auto;
  margin: 0;
  object-fit: contain;
}
.login-divider {
  width: 220px;
  max-width: 100%;
  height: 3px;
  min-height: 3px;
  background: #005480;
  border-radius: 999px;
  flex-shrink: 0;
}
.login-logo .badge {
  background: var(--accent); color: #fff;
  font-size: .65rem; padding: 2px 10px;
  border-radius: 4px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
}
.login-logo .wordmark {
  font-size: 1.6rem; font-weight: 800;
  letter-spacing: .04em;
  display: block;
}
.login-logo .wordmark span { color: var(--accent); }
.login-logo .sub {
  font-size: .72rem; color: #ffffff;
  letter-spacing: .15em; text-transform: uppercase; margin-top: 4px;
}
.login-footer { text-align: center; margin-top: 20px; font-size: .72rem; color: var(--text-muted); }

.btn-login {
  width: 100%; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); padding: 13px;
  font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: background .2s;
}
.btn-login:hover { background: var(--accent-dark); }

.form-error {
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5; border-radius: var(--radius); padding: 10px 14px;
  font-size: .82rem; margin-bottom: 16px;
}

/* ── APP LAYOUT ─────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

#topbar {
  height: var(--topbar-h); background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  flex-shrink: 0; z-index: 100;
}

.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-brand-logo {
  height: 24px;
  width: auto;
  display: block;
  object-fit: contain;
}
.topbar-brand .badge {
  background: var(--accent); color: #fff;
  font-size: .6rem; padding: 2px 8px; border-radius: 4px;
  font-weight: 700; letter-spacing: .08em;
}
.topbar-brand .wordmark { font-size: .95rem; font-weight: 700; letter-spacing: .04em; }
.topbar-brand .wordmark span { color: var(--accent); }
.topbar-spacer { flex: 1; }
.topbar-inst { font-size: .8rem; color: var(--text-secondary); }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.role-badge {
  font-size: .65rem; padding: 2px 8px; border-radius: 4px;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-secondary); font-weight: 600; text-transform: uppercase;
}

#main-layout {
  display: flex; flex: 1; overflow: hidden;
}

.partner-footer {
  display: none;
  height: 54px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  overflow: hidden;
}

.partner-marquee {
  height: 100%;
  display: flex;
  width: max-content;
  animation: partner-scroll 80s linear infinite;
}

.partner-track {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 22px;
}

.partner-track img {
  max-height: 28px;
  width: auto;
  object-fit: contain;
  opacity: .88;
}

@keyframes partner-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (max-width: 900px) {
  .partner-footer { height: 48px; }
  .partner-track { gap: 20px; padding: 0 16px; }
  .partner-track img { max-height: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .partner-marquee { animation: none; }
}

/* ── SIDEBAR NAV ─────────────────────────────────────────────────── */
#sidebar-nav {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-logo-wrap {
  padding: 2px 16px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.sidebar-logo {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

/* Blinken-Toggle am Nav-Ende */
.nav-blink-toggle {
  margin-top: auto; padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: .78rem; color: var(--text-secondary);
  user-select: none;
  transition: background .15s;
}
.nav-blink-toggle:hover { background: var(--bg-2); }
.nav-blink-dot { font-size: 1rem; }
.nav-blink-switch {
  margin-left: auto;
  width: 32px; height: 17px;
  border-radius: 9px;
  background: var(--accent);
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.nav-blink-switch::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: left .2s;
}
.nav-blink-toggle.off .nav-blink-switch { background: var(--text-muted); }
.nav-blink-toggle.off .nav-blink-switch::after { left: 17px; }

/* Blinken global deaktiviert */
body.blink-off .mission-tile.sonderrechte {
  animation: none;
  border-color: rgba(59,130,246,.5);
}

.nav-section {
  font-size: .65rem; font-weight: 700; color: var(--text-muted);
  letter-spacing: .12em; text-transform: uppercase;
  padding: 14px 16px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; color: var(--text-secondary);
  text-decoration: none; font-size: .82rem; font-weight: 500;
  cursor: pointer; border-left: 2px solid transparent;
  transition: all .15s;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-2); }
.nav-link.active {
  color: var(--accent); background: rgba(59,126,250,.08);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

/* ── CONTENT ─────────────────────────────────────────────────────── */
#content-area {
  flex: 1; overflow-y: auto;
  padding: 24px;
  background: var(--bg-0);
}

.view { display: none; animation: fadeIn .2s ease; }
.view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; }
.page-header h2 { font-size: 1rem; font-weight: 600; }

.dash-cap-wrap {
  flex: 1; display: flex; flex-direction: column;
  margin: 0 16px; min-width: 0;
}
.dash-cap-bars  { height: 32px !important; border-radius: var(--radius) var(--radius) 0 0 !important; }
.dash-cap-labels { font-size: .55rem !important; }

.refresh-bar-wrap {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.refresh-bar-track {
  flex: 1; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.refresh-bar-fill {
  height: 100%; width: 100%;
  background: var(--accent);
  border-radius: 2px;
  transform-origin: left;
  transition: none;
}
.refresh-bar-fill.animating {
  transition: width linear;
}
.refresh-bar-label {
  font-size: .75rem; color: var(--text-muted);
  white-space: nowrap; min-width: 200px; text-align: right;
}

.tile-eta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--text-secondary);
  background: rgba(255,255,255,.04); border-radius: 6px;
  padding: 5px 8px; margin-top: 6px;
}
.tile-eta-vehicle { color: var(--accent); font-weight: 600; }
.tile-eta-item    { color: var(--text-muted); }

.section-title {
  font-size: .85rem; font-weight: 600; color: var(--text-secondary);
  letter-spacing: .06em; text-transform: uppercase;
  margin: 24px 0 12px;
}

/* ── FORM ELEMENTS ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-group label { font-size: .75rem; color: var(--text-secondary); font-weight: 500; letter-spacing: .04em; }
.form-group input:not([type="checkbox"]),
.form-group select,
.form-group textarea {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius);
  padding: 10px 12px; font-family: inherit; font-size: .85rem;
  transition: border-color .15s; width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,126,250,.12);
}
.form-group textarea { resize: vertical; min-height: 60px; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-row .form-group.flex-2 { flex: 2; }

.form-section {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
}
.form-section-title {
  font-size: .7rem; font-weight: 700; color: var(--text-muted);
  letter-spacing: .12em; text-transform: uppercase;
  margin-bottom: 12px;
}
.req { color: var(--red); }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; color: var(--text-secondary);
  cursor: pointer; margin-top: 4px;
}
.radio-group { display: flex; gap: 10px; align-items: center; padding: 6px 0; flex-wrap: nowrap; }
.radio-group label { display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: .85rem; white-space: nowrap; }
.radio-sep { color: var(--border); font-size: .9rem; user-select: none; }

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 9px 18px;
  font-weight: 600; font-size: .82rem; cursor: pointer;
  transition: background .15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: var(--radius);
  padding: 9px 18px; font-weight: 500; font-size: .82rem; cursor: pointer;
  transition: all .15s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text-primary); }

.btn-danger {
  background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.4);
  color: #fca5a5; border-radius: var(--radius);
  padding: 9px 18px; font-size: .82rem; cursor: pointer; font-weight: 500;
}
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn-icon {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: var(--radius);
  padding: 5px 12px; font-size: .78rem; cursor: pointer;
  transition: all .15s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--text-primary); }

.btn-sm { padding: 5px 10px; font-size: .75rem; }

.btn-link-order {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link-order:hover {
  color: #7fb0ff;
}

/* ── ALL ORDERS FILTER HIGHLIGHTS ─────────────────────────────── */
#view-all-orders .all-orders-quick-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent-dark) !important;
}

#view-all-orders .all-orders-quick-active:hover {
  background: var(--accent-dark) !important;
}

#all-orders-date-from.date-active,
#all-orders-date-to.date-active {
  border-color: var(--accent) !important;
  background: rgba(59,126,250,.16) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 0 0 2px rgba(59,126,250,.18);
}

/* ── TABLES ──────────────────────────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: .82rem;
}
.data-table th {
  background: var(--bg-2); color: var(--text-muted);
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 10px 12px;
  border-bottom: 1px solid var(--border); text-align: left;
}
.data-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

/* ── KOSTENTRÄGER ──────────────────────────────────────────────── */
/* Autofill-Dropdown */
.cc-autofill-wrap { position: relative; }
.cc-autofill-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 500;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius);
  list-style: none; margin: 0; padding: 4px 0; max-height: 240px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.cc-autofill-list li {
  padding: 8px 12px; cursor: pointer; font-size: .85rem;
  display: flex; flex-direction: column; gap: 1px;
}
.cc-autofill-list li:hover, .cc-autofill-list li.active {
  background: var(--bg-hover, rgba(255,255,255,.06));
}
.cc-autofill-list li .cc-af-name { color: var(--text-primary); font-weight: 500; }
.cc-autofill-list li .cc-af-meta { color: var(--text-muted); font-size: .75rem; }

.cc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.cc-hint {
  color: var(--text-secondary);
  font-size: .8rem;
  margin: 4px 0 8px;
}

.cc-mapping-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.cc-mapping-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cc-mapping-row label {
  font-size: .74rem;
  color: var(--text-secondary);
}

.cc-mapping-row select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: .8rem;
}

@media (max-width: 1100px) {
  .cc-grid {
    grid-template-columns: 1fr;
  }
  .cc-mapping-list {
    grid-template-columns: 1fr;
  }
}
.data-table tr:hover td { background: var(--bg-2); }
.data-table tr:last-child td { border-bottom: none; }

/* ── STATUS BADGES ───────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
}
.status-NEU { background: rgba(107,114,128,.2); color: #d1d5db; border: 1px solid rgba(107,114,128,.3); }
.status-ÜBERMITTELT { background: rgba(59,130,246,.15); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }
.status-DISPONIERT { background: rgba(139,92,246,.15); color: #c4b5fd; border: 1px solid rgba(139,92,246,.3); }
.status-AUF_ANFAHRT { background: rgba(249,115,22,.15); color: #fdba74; border: 1px solid rgba(249,115,22,.3); }
.status-ANGEKOMMEN { background: rgba(234,179,8,.15); color: #fde68a; border: 1px solid rgba(234,179,8,.3); }
.status-TRANSPORT { background: rgba(6,182,212,.15); color: #67e8f9; border: 1px solid rgba(6,182,212,.3); }
.status-ABGESCHLOSSEN { background: rgba(34,197,94,.15); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.status-STORNIERT { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

html[data-theme="light"] .status-badge,
html[data-theme="light"] .tile-badge,
html[data-theme="light"] .cap-pill {
  font-weight: 700;
}

html[data-theme="light"] .status-NEU,
html[data-theme="light"] .status-ÜBERMITTELT,
html[data-theme="light"] .status-DISPONIERT,
html[data-theme="light"] .status-AUF_ANFAHRT,
html[data-theme="light"] .status-ANGEKOMMEN,
html[data-theme="light"] .status-TRANSPORT,
html[data-theme="light"] .status-ABGESCHLOSSEN,
html[data-theme="light"] .status-STORNIERT {
  background: #ffffff;
  color: var(--text-primary);
  border-width: 1px;
}

html[data-theme="light"] .status-NEU { border-color: #9ca3af; color: #4b5563; }
html[data-theme="light"] .status-ÜBERMITTELT { border-color: #2563eb; color: #005480; }
html[data-theme="light"] .status-DISPONIERT { border-color: #7c3aed; color: #6d28d9; }
html[data-theme="light"] .status-AUF_ANFAHRT { border-color: #f97316; color: #c2410c; }
html[data-theme="light"] .status-ANGEKOMMEN { border-color: #eab308; color: #a16207; }
html[data-theme="light"] .status-TRANSPORT { border-color: #0891b2; color: #0e7490; }
html[data-theme="light"] .status-ABGESCHLOSSEN { border-color: #22c55e; color: #15803d; }
html[data-theme="light"] .status-STORNIERT { border-color: #ef4444; color: #b91c1c; }

/* ── CARDS GRID ──────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.institution-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  transition: border-color .15s;
}
.institution-card:hover { border-color: var(--accent); }
.institution-card h3 { font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.institution-card .type-badge {
  font-size: .68rem; background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-muted); padding: 2px 8px; border-radius: 4px;
  font-weight: 600;
}
.institution-card .meta { font-size: .78rem; color: var(--text-muted); margin-top: 8px; line-height: 1.6; }
.institution-card .actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── MISSION TILES ───────────────────────────────────────────────── */
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1800px) {
  .tiles-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1450px) {
  .tiles-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .tiles-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .tiles-grid { grid-template-columns: 1fr; }
}

.mission-tile {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  position: relative;
}
.mission-tile:hover { border-color: var(--accent); box-shadow: 0 4px 20px rgba(59,126,250,.1); }

.tile-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.tile-order-nr { font-size: .75rem; font-weight: 700; color: var(--accent); }
.tile-time { font-size: .8rem; color: #fef08a; font-weight: 700; }
.tile-time-clock { color: #22c55e; }

.tile-status-bar {
  height: 4px;
  background: var(--border);
  position: relative;
}
.tile-status-bar .bar-fill {
  height: 100%; transition: width .5s ease;
  background: var(--accent);
}

.tile-body { padding: 14px; }
.tile-patient { font-size: .95rem; font-weight: 700; margin-bottom: 4px; }
.tile-route {
  font-size: .78rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
  min-width: 0;
}
.tile-route .arrow { color: var(--accent); }
.tile-route .tile-route-pickup,
.tile-route .tile-route-dest {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-route .tile-route-pickup { color: #005480; flex: 1 1 50%; }
.tile-route .tile-route-dest { color: #005480; flex: 1 1 50%; }

.tile-info-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.tile-badge {
  font-size: .7rem; padding: 2px 8px; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-secondary);
}
.tile-badge.type-liegend { background: rgba(59,130,246,.1); color: #93c5fd; border-color: rgba(59,130,246,.25); }
.tile-badge.type-sitzend { background: rgba(34,197,94,.1); color: #86efac; border-color: rgba(34,197,94,.25); }
.tile-badge.type-maxicosi { background: rgba(234,179,8,.1); color: #fde68a; border-color: rgba(234,179,8,.25); }
.tile-badge.type-material { background: rgba(168,85,247,.1); color: #d8b4fe; border-color: rgba(168,85,247,.25); }

html[data-theme="light"] .tile-badge {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border);
}

html[data-theme="light"] .tile-badge.type-liegend { border-color: #2563eb; color: #005480; }
html[data-theme="light"] .tile-badge.type-sitzend { border-color: #22c55e; color: #15803d; }
html[data-theme="light"] .tile-badge.type-maxicosi { border-color: #eab308; color: #a16207; }
html[data-theme="light"] .tile-badge.type-material { border-color: #7c3aed; color: #6d28d9; }

.tile-feedback-msg {
  background: rgba(250,204,21,.12);
  border: 1px solid rgba(250,204,21,.55);
  border-left: 3px solid #facc15;
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: 8px;
  display: flex; gap: 8px; align-items: flex-start;
}
.tile-eta {
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: .78rem;
  color: #86efac;
  margin-top: 8px;
}

.tile-actions { padding: 0 14px 12px; display: flex; gap: 8px; }

/* Animierter "auf Anfahrt" Tile */
.mission-tile.on-the-way {
  border-color: rgba(249,115,22,.4);
  animation: tile-pulse 2s ease-in-out infinite;
}
@keyframes tile-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,.15); }
  50% { box-shadow: 0 0 0 6px rgba(249,115,22,.05); }
}

/* Sonderrechte / Blaulicht Tile – Doppelblitz */
.mission-tile.sonderrechte {
  border-color: transparent;
  animation: tile-doppelblitz 0.7s linear infinite;
  position: relative;
}
.mission-tile.sonderrechte:hover { border-color: transparent; }
@keyframes tile-doppelblitz {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,.0);
         border-color: rgba(59,130,246,.15); }
  15%  { box-shadow: -4px 0 14px 4px rgba(59,130,246,.8),  4px 0 14px 4px rgba(59,130,246,.0);
         border-left-color: rgba(59,130,246,1); border-right-color: rgba(59,130,246,.1); }
  30%  { box-shadow: -4px 0 14px 4px rgba(59,130,246,.0),  4px 0 14px 4px rgba(59,130,246,.0);
         border-color: rgba(59,130,246,.1); }
  45%  { box-shadow: -4px 0 14px 4px rgba(59,130,246,.0),  4px 0 14px 4px rgba(59,130,246,.8);
         border-right-color: rgba(59,130,246,1); border-left-color: rgba(59,130,246,.1); }
  60%  { box-shadow: 0 0 0 0 rgba(59,130,246,.0);
         border-color: rgba(59,130,246,.1); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,.0);
         border-color: rgba(59,130,246,.15); }
}
.tile-badge.blaulicht {
  background: rgba(59,130,246,.15); color: #93c5fd;
  border-color: rgba(59,130,246,.5); font-weight: 700;
}

/* ── STATS ───────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  text-align: center;
}
.stat-box .stat-val {
  font-size: 2rem; font-weight: 800; color: var(--accent);
  line-height: 1;
}
.stat-box .stat-lbl { font-size: .72rem; color: var(--text-muted); margin-top: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  overflow: visible;
}
.stat-card h3 { font-size: .82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; }

.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: .75rem; }
.bar-row .bar-label { width: 120px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.bar-row .bar-val { width: 30px; text-align: right; color: var(--text-primary); font-weight: 600; }

/* Tages-Chart */
.day-chart { display: flex; align-items: flex-end; gap: 2px; height: 100px; overflow: visible; }
.day-bar { flex: 1; min-width: 4px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .7; transition: opacity .2s; cursor: pointer; position: relative; }
.day-bar:hover { opacity: 1; }
.day-bar:hover::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; font-size: .8rem; font-weight: 600;
  white-space: nowrap; color: var(--text-primary); z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  pointer-events: none;
}

/* Feedback Donut (CSS only) */
.feedback-bars { display: flex; flex-direction: column; gap: 8px; }
.feedback-row { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.feedback-row .fi { font-size: 1.1rem; }

/* ── MODAL ───────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 500px;
  max-height: 96vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.7);
  animation: modalIn .2s ease;
}
.modal-xl { max-width: 1100px; }

/* ── ORDER FORM COMPACT (kein Scrollen nötig) ──────────────────── */
/* Auftraggeber: transparente Titelleiste über voller Breite */
.order-form-grid [data-section="auftraggeber"] {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 2px 0 10px 0;
}
/* Kompaktere Sections */
.order-form-grid .form-section { padding: 10px 12px; border-radius: var(--radius); }
.order-form-grid .form-section-title { margin-bottom: 7px; }
/* Kompaktere Felder */
.order-form-grid .form-group { margin-bottom: 7px; }
.order-form-grid .form-group:last-child { margin-bottom: 0; }
.order-form-grid .form-group input,
.order-form-grid .form-group select { padding: 6px 10px; font-size: .82rem; }
.order-form-grid .form-group textarea { padding: 6px 10px; font-size: .82rem; min-height: 44px; }
.order-form-grid .form-row { gap: 7px; }
.order-form-grid .radio-group { gap: 12px; padding: 4px 0; }
/* Kompakter Kapazitätsbalken */
.order-form-grid .cap-bar-wrap { height: 30px; }
.order-form-grid .cap-hour-labels .cap-hl { font-size: .55rem; }
.order-form-grid #capacity-widget { margin-top: 4px; margin-bottom: 0; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg-1); z-index: 5;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.1rem; cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-3); }
.modal-body { padding: 14px 16px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--bg-1);
}

/* Order Form Grid in Modal */
.order-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}
@media (max-width: 680px) { .order-form-grid { grid-template-columns: 1fr; } }

/* ── FEEDBACK ────────────────────────────────────────────────────── */
.feedback-buttons {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.feedback-btn {
  background: var(--bg-2); border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; transition: all .2s; font-size: .78rem; color: var(--text-secondary);
  min-width: 76px;
}
.feedback-btn:hover, .feedback-btn.selected { border-color: var(--accent); background: var(--bg-3); }
.feedback-btn.selected-1 { border-color: var(--red); }
.feedback-btn.selected-2 { border-color: #fb923c; }
.feedback-btn.selected-3 { border-color: var(--yellow); }
.feedback-btn.selected-4 { border-color: #4ade80; }
.feedback-btn.selected-5 { border-color: var(--green); }
.feedback-icon { font-size: 2.5rem; }
.feedback-icon.bad { filter: grayscale(0); }

/* ── TOAST ───────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px;
  min-width: 260px; max-width: 360px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: slideIn .3s ease;
  font-size: .82rem;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }
.toast.warning { border-left: 3px solid var(--yellow); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── ADMIN ───────────────────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.admin-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.admin-card h3 { font-size: .9rem; font-weight: 700; margin-bottom: 8px; }
.admin-card p { font-size: .8rem; color: var(--text-muted); margin-bottom: 12px; }

/* ── SETTINGS ────────────────────────────────────────────────────── */
.settings-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.settings-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: .82rem; padding: 10px 16px;
  cursor: pointer; margin-bottom: -1px; font-family: inherit; font-weight: 500;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-section { max-width: 600px; }
.settings-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
#settings-transport-doc { max-width: 780px; }
#settings-form-layout { max-width: none; width: 100%; }

/* ── TRANSPORTSCHEIN SETTINGS ───────────────────────────────────── */
.td-settings-group {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.td-settings-group-title {
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px;
}
.td-settings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px;
}
.td-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-3); border-radius: 6px; padding: 6px 10px;
  font-size: .82rem; cursor: pointer; user-select: none; gap: 8px;
}
.td-toggle-row:hover { background: var(--bg-1); }
.td-toggle-row input[type="checkbox"] { display: none; }
.td-toggle-label {
  width: 36px; height: 20px; background: var(--bg-1); border-radius: 10px;
  position: relative; flex-shrink: 0; border: 1px solid var(--border); transition: background .2s;
}
.td-toggle-label::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-muted); transition: left .2s, background .2s;
}
.td-toggle-row input[type="checkbox"]:checked ~ .td-toggle-label { background: #ef4444; border-color: #ef4444; }
.td-toggle-row input[type="checkbox"]:checked ~ .td-toggle-label::after { left: 18px; background: #fff; }
.td-toggle-row span:first-child { flex: 1; color: var(--text-primary); }

/* ── TRANSPORTSCHEIN FORMULAR MODAL ─────────────────────────────── */
.td-checkbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px 16px; margin-bottom: 4px;
}
.td-chk-label {
  display: flex; align-items: center; gap: 6px; font-size: .83rem;
  padding: 4px 6px; border-radius: 4px; cursor: pointer;
  color: var(--text-primary); user-select: none;
}
.td-chk-label:hover { background: var(--bg-2); }
.td-chk-label input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--accent);
  flex-shrink: 0; cursor: pointer;
}
.td-chk-label.td-chk-locked { opacity: .5; cursor: not-allowed; }
.td-chk-label.td-chk-locked input { cursor: not-allowed; }

/* ── FILTERS ─────────────────────────────────────────────────────── */
.filters-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.filters-bar input, .filters-bar select {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius);
  padding: 8px 12px; font-size: .82rem; font-family: inherit;
}
.filters-bar input { min-width: 200px; }

/* ── TRANSPORT DOC (Druck-Layout) ───────────────────────────────── */
@media print {
  body > *:not(#transport-doc-container) { display: none !important; }
  #transport-doc-container { display: block !important; }
}

.transport-doc {
  font-family: 'Arial', sans-serif; color: #000;
  max-width: 21cm; margin: 0 auto;
  font-size: 12px; line-height: 1.4;
}
.doc-title { font-size: 18px; font-weight: bold; margin-bottom: 16px; border-bottom: 2px solid #000; padding-bottom: 8px; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 16px; }
.doc-section h4 { font-size: 13px; font-weight: bold; margin-bottom: 8px; }
.doc-row { display: flex; margin-bottom: 4px; }
.doc-row .doc-label { width: 130px; font-weight: bold; flex-shrink: 0; font-size: 11px; }
.doc-row .doc-val { flex: 1; font-size: 11px; }
.doc-checkboxes { margin: 8px 0; }
.doc-checkbox-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 4px; font-size: 11px; }
.doc-checkbox-item { display: flex; align-items: center; gap: 4px; }
.doc-checkbox { width: 12px; height: 12px; border: 1.5px solid #000; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; }
.doc-box { border: 1.5px solid #000; height: 80px; margin-top: 8px; }
.doc-divider { border: none; border-top: 1px solid #000; margin: 16px 0; }
.doc-footer { margin-top: 16px; font-size: 10px; color: #666; }
.doc-bold { font-weight: bold; }

/* ── SCROLLBAR ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── MISC ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.msg-bubble {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  font-size: .8rem; margin-bottom: 8px;
}
.msg-bubble.from-disponent { border-left: 3px solid var(--accent); }
.msg-bubble.from-institution,
.msg-bubble.to-institution {
  background: rgba(250,204,21,.12);
  border: 1px solid rgba(250,204,21,.55);
  border-left: 3px solid #facc15;
}
.msg-bubble.from-system { border-left: 3px solid var(--text-muted); color: var(--text-muted); }
.msg-time { font-size: .68rem; color: var(--text-muted); margin-top: 2px; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px;
}
.detail-section { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; }
.detail-section h4 { font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.detail-row { display: flex; gap: 8px; margin-bottom: 6px; font-size: .82rem; }
.detail-label { color: var(--text-muted); min-width: 100px; }
.detail-val { color: var(--text-primary); font-weight: 500; }

/* Station rows in institution modal */
.station-row {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.station-row .station-name { flex: 1; font-size: .85rem; font-weight: 600; }
.station-row .station-meta { font-size: .75rem; color: var(--text-muted); }

/* ── LOGBUCH ─────────────────────────────────────────────────────── */
.logbuch-filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 16px;
}
.logbuch-filter-bar .filter-group {
  display: flex; flex-direction: column; gap: 4px;
}
.logbuch-filter-bar .filter-group label {
  font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
}
.logbuch-filter-bar input, .logbuch-filter-bar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-3); color: var(--text-primary); font-size: .85rem; min-width: 140px;
}
.logbuch-count {
  font-size: .8rem; color: var(--text-muted); align-self: center; margin-left: auto;
}

/* Badges */
.lb-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.lb-badge-ok      { background: rgba(74,222,128,.15); color: #4ade80; border: 1px solid rgba(74,222,128,.3); }
.lb-badge-warn    { background: rgba(251,191,36,.15);  color: #fbbf24; border: 1px solid rgba(251,191,36,.3); }
.lb-badge-danger  { background: rgba(248,113,113,.15); color: #f87171; border: 1px solid rgba(248,113,113,.3); }
.lb-badge-info    { background: rgba(96,165,250,.15);  color: #60a5fa; border: 1px solid rgba(96,165,250,.3); }
.lb-badge-default { background: var(--bg-3); color: var(--text-muted); border: 1px solid var(--border); }

.lb-ts      { white-space: nowrap; font-family: monospace; font-size: .8rem; color: var(--text-muted); }
.lb-details { font-size: .8rem; max-width: 280px; }
.lb-ip      { font-family: monospace; font-size: .75rem; color: var(--text-muted); }

.logbuch-pagination {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 16px 0;
}
.lb-page-info { font-size: .85rem; color: var(--text-muted); }

/* ── FORM-LAYOUT EDITOR ──────────────────────────────────────────── */
.fl-grid-editor {
  display: grid;
  grid-template-columns: 22px 1fr 1fr;
  gap: 4px;
  align-items: stretch;
}
.fl-grid-corner { /* leer, oben links */ }
.fl-grid-col-hdr {
  font-size: .68rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .1em;
  text-align: center; padding: 4px 0;
}
.fl-grid-row-lbl {
  font-size: .65rem; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.fl-grid-pinned {
  grid-column: 2 / 4;
  background: rgba(59,126,250,.08); border: 1px solid rgba(59,126,250,.25);
  border-radius: var(--radius); padding: 7px 12px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .82rem; font-weight: 600; color: var(--text-secondary);
}
.fl-pin-badge {
  font-size: .67rem; font-weight: 500; color: var(--accent);
  background: rgba(59,126,250,.12); border: 1px solid rgba(59,126,250,.2);
  border-radius: 20px; padding: 2px 8px;
}
.fl-grid-cell {
  min-height: 52px;
  background: var(--bg-3); border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
  position: relative;
}
.fl-grid-cell.drag-over {
  border-color: var(--accent); background: rgba(59,126,250,.1);
}
.fl-grid-cell.dragging { opacity: .4; }
.fl-grid-empty {
  font-size: .68rem; color: var(--text-muted); pointer-events: none;
  letter-spacing: .04em;
}
.fl-card {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  display: flex; align-items: center; gap: 8px; width: 100%;
  cursor: grab; user-select: none; font-size: .82rem; font-weight: 600;
  transition: border-color .15s, box-shadow .15s;
}
.fl-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.fl-card:active { cursor: grabbing; }
.fl-card .fl-drag-handle { color: var(--text-muted); font-size: 1rem; }
.fl-card-remove {
  background: none; border: none; color: var(--text-muted);
  font-size: .75rem; cursor: pointer; padding: 2px 4px;
  border-radius: var(--radius); line-height: 1;
  transition: color .15s, background .15s;
}
.fl-card-remove:hover { color: var(--red); background: rgba(239,68,68,.12); }
.fl-pool-wrap { margin-top: 10px; }
.fl-pool-label {
  font-size: .68rem; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px;
}
.fl-pool {
  min-height: 44px;
  background: var(--bg-3); border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 6px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  transition: border-color .15s, background .15s;
}
.fl-pool.drag-over { border-color: var(--red); background: rgba(239,68,68,.07); }
.fl-pool:empty::after {
  content: 'Karte hierher ziehen zum Entfernen aus dem Raster';
  font-size: .72rem; color: var(--text-muted); pointer-events: none; padding: 4px 6px;
}

/* Form-Layout: Haupt-Wrapper Editor + Vorschau */
.fl-main-wrap {
  display: grid; grid-template-columns: minmax(260px, 380px) minmax(360px, 1fr);
  gap: 28px; align-items: start;
  overflow-x: auto;
}
.fl-panel-title {
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px;
}

/* Live-Vorschau */
.fl-preview-panel { min-width: 0; }
.fl-preview-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  width: 100%; box-sizing: border-box;
}
.fl-preview-col { display: flex; flex-direction: column; gap: 8px; }
.fl-preview-col-hdr {
  font-size: .65rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 2px; opacity: .8;
}
.fl-preview-section {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px;
}
.fl-preview-sec-title {
  font-size: .68rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .06em;
  padding-bottom: 5px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 5px;
}
.fl-preview-frow { display: flex; gap: 4px; margin-bottom: 3px; }
.fl-preview-frow:last-child { margin-bottom: 0; }
.fl-preview-fbox { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fl-preview-flabel {
  font-size: .58rem; color: var(--text-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; opacity: .9;
}
.fl-preview-fbar {
  height: 14px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 3px;
}

/* ───────────────────────────────────────────────────────────────
   KAPAZITÄTS-WIDGET (Formular)
─────────────────────────────────────────────────────────────── */
#capacity-widget {
  margin-top: 8px; margin-bottom: 2px;
}
.cap-chart-wrap {
  display: flex; flex-direction: column; gap: 0;
}
.cap-bar-wrap {
  display: flex; align-items: flex-end; gap: 2px; height: 40px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; padding: 4px 6px 0;
}
.cap-hour-labels {
  display: flex; align-items: flex-start; gap: 2px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  padding: 2px 6px 3px;
}
.cap-hour-labels .cap-hl {
  flex: 1; min-width: 0; text-align: center;
  font-size: .6rem; color: var(--text-muted); line-height: 1;
  white-space: nowrap; overflow: hidden;
}
.cap-hour-labels .cap-hl.cap-hl-active { color: #fff; font-weight: 700; }
.cap-bar-wrap .cap-h {
  flex: 1; min-width: 0; border-radius: 2px 2px 0 0;
  transition: background .2s, height .2s;
  cursor: default; position: relative;
}
.cap-bar-wrap .cap-h.cap-green  { background: rgba(34,197,94,.55); }
.cap-bar-wrap .cap-h.cap-orange { background: rgba(251,146,60,.7); }
.cap-bar-wrap .cap-h.cap-red    { background: rgba(239,68,68,.75); }
.cap-bar-wrap .cap-h.cap-empty  { background: var(--bg-2); border: 1px solid var(--border); }
.cap-bar-wrap .cap-h.cap-past   { background: rgba(100,116,139,.4); border: 1px solid rgba(100,116,139,.5); opacity: .6; }
.cap-bar-wrap .cap-h.cap-active {
  outline: 2px solid #fff; outline-offset: 1px; z-index: 1;
}
.cap-status-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 5px; font-size: .78rem; gap: 8px; flex-wrap: wrap;
}
.cap-pill {
  padding: 2px 10px; border-radius: 20px; font-weight: 700; font-size: .78rem;
  display: inline-flex; align-items: center; gap: 5px;
}
.cap-pill.cap-green  { background: rgba(34,197,94,.18);  color: #4ade80; border: 1px solid rgba(34,197,94,.35); }
.cap-pill.cap-orange { background: rgba(251,146,60,.18); color: #fb923c; border: 1px solid rgba(251,146,60,.35); }
.cap-pill.cap-red    { background: rgba(239,68,68,.18);  color: #f87171; border: 1px solid rgba(239,68,68,.35); }
.cap-pill.cap-empty  { background: var(--bg-2); color: var(--text-muted); border: 1px solid var(--border); }
.cap-pill.cap-past   { background: rgba(100,116,139,.15); color: rgba(148,163,184,.7); border: 1px solid rgba(100,116,139,.3); }

html[data-theme="light"] .cap-pill.cap-green,
html[data-theme="light"] .cap-pill.cap-orange,
html[data-theme="light"] .cap-pill.cap-red,
html[data-theme="light"] .cap-pill.cap-empty,
html[data-theme="light"] .cap-pill.cap-past {
  background: #ffffff;
  color: var(--text-primary);
}

html[data-theme="light"] .cap-pill.cap-green { border-color: #22c55e; color: #15803d; }
html[data-theme="light"] .cap-pill.cap-orange { border-color: #f97316; color: #c2410c; }
html[data-theme="light"] .cap-pill.cap-red { border-color: #ef4444; color: #b91c1c; }
html[data-theme="light"] .cap-pill.cap-empty { border-color: var(--border); color: var(--text-muted); }
html[data-theme="light"] .cap-pill.cap-past { border-color: #94a3b8; color: #64748b; }
.cap-info { font-size: .75rem; color: var(--text-muted); flex: 1; text-align: right; }
.cap-legend { display:flex; gap:10px; font-size:.72rem; color:var(--text-muted); margin-top:3px; }
.cap-legend span { display:inline-flex;align-items:center;gap:3px; }
.cap-legend .dot { width:8px;height:8px;border-radius:50%;display:inline-block; }

/* ───────────────────────────────────────────────────────────────
   KAPAZITÄTS-EINSTELLUNGEN (Settings)
─────────────────────────────────────────────────────────────── */
.cap-settings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px;
}
.cap-settings-box {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
}
.cap-settings-box-title {
  font-weight: 700; font-size: .85rem; margin-bottom: 12px;
}
.cap-hint { font-size: .73rem; color: var(--text-muted); margin-top: 4px; }
.cap-special-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; margin-bottom: 6px;
}
.cap-special-row input[type=text],
.cap-special-row input[type=date],
.cap-special-row input[type=number] {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 4px 7px;
  font-size: .82rem;
}
.cap-special-row label { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

/* ───────────────────────────────────────────────────────────────
   TIME PICKER
─────────────────────────────────────────────────────────────── */
.tp-wrap { position: relative; }
.tp-display {
  width: 100%; box-sizing: border-box; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 8px 12px;
  font-size: .9rem; font-family: inherit;
}
.tp-display:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.25); }
.tp-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 9999;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0,0,0,.45);
  padding: 6px; max-height: 260px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
}
.tp-slot {
  border: none; border-radius: var(--radius); padding: 6px 4px;
  font-size: .8rem; font-weight: 600; cursor: pointer; text-align: center;
  transition: filter .15s, transform .1s; color: #fff; position: relative;
  font-family: inherit;
}
.tp-slot:hover { filter: brightness(1.25); transform: scale(1.06); z-index: 1; }
.tp-slot.tp-selected { outline: 2px solid #fff; outline-offset: 1px; }
.tp-slot.tp-green  { background: rgba(34,197,94,.35);  color: #86efac; }
.tp-slot.tp-orange { background: rgba(251,146,60,.45); color: #fcd34d; }
.tp-slot.tp-red    { background: rgba(239,68,68,.45);  color: #fca5a5; }
.tp-slot.tp-empty  { background: var(--bg-3); color: var(--text-muted); }
.tp-slot.tp-past   { background: transparent; color: var(--text-muted); opacity: .3; cursor: not-allowed; text-decoration: line-through; }
.tp-slot .tp-cnt {
  display: block; font-size: .62rem; font-weight: 400; opacity: .8; margin-top: 1px;
}

html[data-theme="light"] .tp-slot.tp-green,
html[data-theme="light"] .tp-slot.tp-orange,
html[data-theme="light"] .tp-slot.tp-red,
html[data-theme="light"] .tp-slot.tp-empty {
  color: #005480;
}

html[data-theme="light"] .tp-slot.tp-past {
  color: #64748b;
}

html[data-theme="light"] .tp-slot.tp-selected {
  outline-color: #005480;
}

/* ── ADRESSSUCHE (OSM Nominatim) ─────────────────────────────────── */
.addr-search-wrap { position: relative; }
.addr-search-wrap .form-group { position: relative; }
.addr-search-input {
  background: var(--bg-2); border: 1px solid var(--accent);
  color: var(--text-primary); border-radius: var(--radius);
  padding: 6px 10px 6px 30px; font-family: inherit; font-size: .82rem;
  width: 100%; transition: border-color .15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%233b7efa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 8px center;
}
.addr-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,126,250,.12); }
.addr-suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px);
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 200; max-height: 210px; overflow-y: auto; display: none;
}
.addr-suggestions.open { display: block; }
.addr-suggestion-item {
  padding: 8px 12px; font-size: .8rem; cursor: pointer;
  border-bottom: 1px solid var(--border); line-height: 1.4;
  color: var(--text-primary); display: flex; align-items: flex-start; gap: 8px;
}
.addr-suggestion-item:last-child { border-bottom: none; }
.addr-suggestion-item:hover, .addr-suggestion-item.active { background: var(--bg-2); }
.addr-suggestion-icon { color: var(--accent); font-size: .85rem; flex-shrink: 0; margin-top: 1px; }
.addr-suggestion-main { font-weight: 600; }
.addr-suggestion-sub  { font-size: .73rem; color: var(--text-muted); }
.addr-loading { padding: 10px 12px; font-size: .8rem; color: var(--text-muted); text-align: center; }

/* Außerhalb des Radius → rot */
.addr-suggestion-item.addr-far .addr-suggestion-main { color: #ef4444; }
.addr-suggestion-item.addr-far .addr-suggestion-sub  { color: #fca5a5; }
.addr-suggestion-item.addr-far .addr-suggestion-icon { filter: sepia(1) saturate(2) hue-rotate(310deg); }

/* Distanz-Badge */
.addr-dist-badge {
  margin-left: auto; flex-shrink: 0;
  font-size: .68rem; font-weight: 600;
  background: var(--bg-2); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 1px 7px; white-space: nowrap; align-self: center;
}
.addr-dist-badge.far { background: rgba(239,68,68,.15); color: #ef4444; border-color: #ef4444; }

/* ── Schnellauftrag-Vorlagen ─────────────────────────────────────── */
.qo-preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.qo-preset-card {
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex; flex-direction: column; gap: 4px;
}
.qo-preset-card:hover { border-color: var(--primary); background: rgba(var(--primary-rgb), .06); }
.qo-preset-card.selected { border-color: var(--primary); background: rgba(var(--primary-rgb), .12); }
.qo-preset-card-name { font-weight: 700; font-size: .97rem; }
.qo-preset-card-sub  { font-size: .8rem; color: var(--text-secondary); }
.qo-preset-card-addr { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.qo-preset-card-actions { display: flex; gap: 4px; margin-top: 8px; justify-content: flex-end; }
.qo-card-action-btn {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 5px;
  padding: 2px 7px; font-size: .8rem; cursor: pointer; color: var(--text-secondary);
  transition: background .12s, color .12s;
}
.qo-card-action-btn:hover { background: var(--bg-2); color: var(--primary); }
.qo-card-action-btn.danger:hover { color: var(--danger); }
.qo-group-label {
  grid-column: 1 / -1;
  font-size: .75rem; font-weight: 700; letter-spacing: .05em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 6px 0 2px; border-bottom: 1px solid var(--border);
  margin-top: 4px;
}
.qo-preview-badge {
  background: rgba(var(--primary-rgb), .1);
  border: 1px solid rgba(var(--primary-rgb), .3);
  border-radius: 8px; padding: 8px 14px;
  font-size: .9rem;
}
.qo-preview-badge strong { font-size: 1rem; }
.qo-empty { grid-column: 1/-1; text-align:center; color:var(--text-muted); padding: 24px; }
.qo-sofort-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  border-radius: var(--radius); padding: 9px 14px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  width: 100%; box-sizing: border-box;
  transition: background .15s;
}
.qo-sofort-badge:hover { background: var(--accent-dark); }

/* Admin-Card full-width */
.admin-card-full { grid-column: 1 / -1; }

/* Admin-Preset-Tabelle */
.preset-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 8px; }
.preset-table th { text-align: left; padding: 6px 10px; border-bottom: 2px solid var(--border); font-weight: 700; color: var(--text-secondary); }
.preset-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.preset-table tr:hover td { background: var(--bg-2); }
.preset-active-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.preset-active-dot.on  { background: #22c55e; }
.preset-active-dot.off { background: #9ca3af; }

/* ── Rollen & Rechte ─────────────────────────────────────────────── */
.rp-table th { text-align: center; }
.rp-table th:first-child { text-align: left; }
.rp-section-row td {
  background: var(--bg-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.rp-view-label { padding-left: 16px !important; }
.rp-check-cell { text-align: center; }
.rp-check-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ── Nachichten-Textvorlagen ─────────────────────────────────────── */
.mt-inactive td { opacity: .45; }

/* ── Passwort vergessen / Reset ──────────────────────────────────── */
#forgot-screen,
#reset-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-1, #0d1117);
  z-index: 9999;
}

/* ── Broadcast-Nachrichten ──────────────────────────────────────── */

/* Dashboard-Zeile: Stats links, Infoboxen rechts */
.dash-broadcast-row {
  display: flex;
  align-items: stretch;
  gap: 16px;
  flex-wrap: nowrap;
  margin-bottom: 8px;
}
.dash-broadcast-row .stats-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(145px, 1fr));
  gap: 12px;
  min-width: 620px;
  margin-bottom: 0;
}
.dash-broadcast-row .stat-box {
  min-height: 102px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#broadcast-infobox-container {
  flex: 1 1 320px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  gap: 10px;
}

/* Infobox mit gelb blinkendem Rahmen */
.broadcast-infobox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(250,204,21,.10);
  border: 2px solid #facc15;
  border-radius: 10px;
  padding: 12px 16px;
  min-height: 102px;
  animation: bc-border-blink 1.4s ease-in-out infinite;
}
@keyframes bc-border-blink {
  0%,100% { border-color: #facc15; box-shadow: 0 0 0 0 rgba(250,204,21,0); }
  50%      { border-color: #fde047; box-shadow: 0 0 8px 4px rgba(250,204,21,.35); }
}
.broadcast-infobox-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; }
.broadcast-infobox-content strong { display:block; color: var(--text-primary); margin-bottom: 4px; }
.broadcast-infobox-content p      { margin: 0 0 4px; color: var(--text-secondary); white-space: pre-wrap; font-size: .88rem; }

/* Popup-Box */
.broadcast-popup-box {
  background: var(--bg-2, #161b22);
  border: 2px solid #facc15;
  border-radius: 14px;
  width: 460px;
  max-width: 94vw;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  animation: bc-border-blink 1.4s ease-in-out infinite;
}
.broadcast-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--border, #30363d);
}
.broadcast-popup-icon { font-size: 1.6rem; flex-shrink: 0; }
.broadcast-popup-header h3 { flex: 1; margin: 0; color: var(--text-primary); font-size: 1.1rem; }
.broadcast-popup-body {
  padding: 16px 20px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-size: .95rem;
  line-height: 1.55;
}
.broadcast-popup-footer {
  padding: 12px 20px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (max-width: 1200px) {
  .dash-broadcast-row {
    flex-wrap: wrap;
  }
  .dash-broadcast-row .stats-row {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }
  #broadcast-infobox-container {
    width: 100%;
  }
}
