:root {
  --navy: #0b2740;
  --navy-2: #153e5c;
  --blue: #176b9b;
  --blue-light: #e8f3f8;
  --paper: #ffffff;
  --ground: #edf1f3;
  --ink: #14202a;
  --muted: #64717d;
  --line: #d7dfe3;
  --green: #18754a;
  --green-light: #e4f4eb;
  --amber: #a15b00;
  --amber-light: #fff1d5;
  --red: #b3262e;
  --red-light: #fde9ea;
  --purple: #6b48a6;
  --shadow: 0 16px 40px rgba(18, 42, 58, .08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ground); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--ground); font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0, #1b5276 0, var(--navy) 42%, #071b2d 100%); }
.login-card { width: min(100%, 410px); padding: 38px; border-radius: 24px; background: rgba(255,255,255,.98); box-shadow: 0 24px 70px rgba(0,0,0,.26); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--navy); font-weight: 800; font-size: 24px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
.brand-mark.small { width: 40px; height: 40px; border-radius: 11px; font-size: 19px; background: white; color: var(--navy); }
.login-card h1 { margin: 14px 0 2px; font-size: 34px; letter-spacing: -.03em; }
.eyebrow { margin: 18px 0 3px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.muted { color: var(--muted); }

.stack-form { display: grid; gap: 16px; margin-top: 24px; }
.stack-form label, .filter-label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; color: #33434e; }
input, select, textarea { width: 100%; border: 1px solid #c9d3d9; border-radius: 10px; background: white; color: var(--ink); padding: 12px 13px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,107,155,.13); }
textarea { resize: vertical; }
.form-error { min-height: 20px; margin: 0; color: var(--red); font-weight: 650; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.button { border: 0; border-radius: 10px; min-height: 44px; padding: 10px 16px; font-weight: 800; transition: transform .12s, filter .12s, opacity .12s; }
.button:hover { filter: brightness(.96); }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .46; }
.button.primary { color: white; background: var(--blue); }
.button.secondary { color: var(--navy); background: var(--blue-light); border: 1px solid #bed7e3; }
.button.ghost { color: white; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); }
.button.danger { color: var(--red); background: var(--red-light); }
.button.compact { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.button.full { width: 100%; }

.topbar { min-height: 68px; padding: 10px clamp(16px, 3vw, 42px); display: flex; justify-content: space-between; align-items: center; gap: 20px; color: white; background: var(--navy); box-shadow: 0 2px 12px rgba(0,0,0,.17); position: sticky; top: 0; z-index: 1000; }
.brand-row, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand-row strong { display: block; font-size: 17px; }
.brand-row span { display: block; color: #bcd0dc; font-size: 11px; }
.connection-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #dcebf3; }
.connection-pill i { width: 8px; height: 8px; border-radius: 50%; background: #4bd38a; box-shadow: 0 0 0 4px rgba(75,211,138,.12); }
.connection-pill.offline i { background: #ef6a70; }
.user-name { font-size: 13px; font-weight: 700; }

.page-shell { width: min(1600px, 100%); margin: 0 auto; padding: 30px clamp(16px, 3vw, 42px) 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1; letter-spacing: -.035em; }
.page-heading .eyebrow { margin-top: 0; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(135px, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { padding: 15px 17px; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 5px 18px rgba(20,40,55,.04); }
.summary-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.summary-card strong { display: block; margin-top: 4px; font-size: 28px; line-height: 1; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dispatch-grid { display: grid; grid-template-columns: minmax(340px, .82fr) minmax(500px, 1.5fr); gap: 18px; margin-bottom: 18px; }
.order-panel { padding: 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-heading .eyebrow { margin-top: 0; }
.panel-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 800; }
.tag.neutral { color: #596872; background: #edf1f3; }
.tag.success { color: var(--green); background: var(--green-light); }
.tag.danger { color: var(--red); background: var(--red-light); }
.divider-label { display: flex; align-items: center; gap: 10px; color: #8a969d; font-size: 11px; text-transform: uppercase; }
.divider-label::before, .divider-label::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.search-results { display: grid; gap: 5px; margin-top: 7px; }
.search-result { width: 100%; text-align: left; border: 1px solid var(--line); background: #f7f9fa; padding: 9px 11px; border-radius: 9px; font-size: 12px; color: #314652; }
.search-result:hover { border-color: var(--blue); background: var(--blue-light); }

.map-panel { overflow: hidden; padding: 22px 22px 0; min-height: 590px; display: flex; flex-direction: column; }
.map-heading { margin-bottom: 12px; }
.map-note { color: var(--muted); font-size: 10px; }
.map { flex: 1; min-height: 500px; margin: 0 -22px; border-top: 1px solid var(--line); background: #dce5e8; }
.leaflet-popup-content { margin: 12px 14px; }
.map-popup strong { display: block; font-size: 14px; }
.map-popup span { display: block; margin-top: 3px; color: #566670; font-size: 12px; }

.section-panel { padding: 22px; margin-bottom: 18px; }
.driver-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 10px; }
.driver-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfc; }
.driver-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.driver-card h3 { margin: 0; font-size: 16px; }
.driver-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border-radius: 999px; padding: 5px 8px; font-size: 10px; font-weight: 850; }
.status-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-1, .s-2 { color: var(--green); background: var(--green-light); }
.s-3, .s-4 { color: var(--blue); background: var(--blue-light); }
.s-5 { color: var(--purple); background: #f0eafb; }
.s-6 { color: var(--red); background: var(--red-light); }
.s-7 { color: var(--amber); background: var(--amber-light); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th { padding: 9px 10px; text-align: left; color: #6b7880; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
td { padding: 13px 10px; border-bottom: 1px solid #edf0f2; vertical-align: top; }
td strong { display: block; }
td small { color: var(--muted); }
.priority-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #9aa5aa; }
.priority-dot.urgent { background: var(--red); box-shadow: 0 0 0 3px var(--red-light); }
.filter-label { grid-template-columns: auto 160px; align-items: center; }
.filter-label select { padding: 8px 10px; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-panel { padding: 18px 20px; }
.admin-panel summary { cursor: pointer; font-size: 16px; font-weight: 800; }
.compact-form { margin-top: 18px; }
.compact-text { margin: 12px 0 0; font-size: 12px; }
.admin-list { display: grid; gap: 7px; margin-top: 16px; }
.admin-item { padding: 9px 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #f5f7f8; border-radius: 9px; }
.admin-item span { font-size: 12px; }

.driver-shell { width: min(720px, 100%); margin: 0 auto; padding: 24px 16px calc(50px + env(safe-area-inset-bottom)); }
.driver-intro { text-align: center; }
.driver-intro .eyebrow { margin-top: 0; }
.driver-intro h1 { margin: 0; font-size: clamp(29px, 8vw, 40px); letter-spacing: -.04em; }
.gps-pill { width: fit-content; margin: 12px auto 5px; padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: 12px; }
.gps-pill.success { color: var(--green); background: var(--green-light); }
.gps-pill.warning { color: var(--amber); background: var(--amber-light); }
.gps-pill.danger { color: var(--red); background: var(--red-light); }
.driver-hint { margin: 5px 0 20px; color: var(--muted); font-size: 12px; }
.driver-order-card { min-height: 180px; padding: 22px; color: white; border-radius: 19px; background: linear-gradient(145deg, var(--navy), #154d70); box-shadow: 0 17px 40px rgba(5,37,58,.23); }
.driver-order-card.empty { color: var(--ink); background: white; border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; text-align: center; }
.order-reference { color: #a8d6ed; font-size: 11px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.driver-order-card h2 { margin: 8px 0 6px; font-size: clamp(23px, 6vw, 32px); line-height: 1.15; letter-spacing: -.03em; }
.driver-order-card p { margin: 8px 0; color: #d4e3eb; }
.driver-order-card .order-note { padding: 10px 12px; background: rgba(255,255,255,.09); border-radius: 10px; }
.navigation-link { display: inline-flex; justify-content: center; width: 100%; margin-top: 12px; padding: 13px 15px; border-radius: 11px; color: var(--navy); background: white; font-weight: 850; text-decoration: none; }
.status-section { margin: 24px 0 14px; }
.status-heading { display: flex; justify-content: space-between; align-items: end; gap: 10px; margin-bottom: 12px; }
.status-heading .eyebrow { margin-top: 0; }
.status-heading h2 { margin: 0; font-size: 20px; }
.current-status { font-size: 11px; font-weight: 800; color: var(--muted); }
.status-button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-button { min-height: 92px; border: 2px solid transparent; border-radius: 15px; padding: 12px; text-align: left; background: white; box-shadow: 0 5px 18px rgba(18,42,58,.07); }
.status-button strong { display: block; font-size: 24px; line-height: 1; }
.status-button span { display: block; margin-top: 7px; font-size: 13px; font-weight: 800; line-height: 1.2; }
.status-button.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,107,155,.13); }
.status-button:disabled { opacity: .42; }
.status-button[data-status="1"], .status-button[data-status="2"] { color: var(--green); background: #f3fbf6; }
.status-button[data-status="3"], .status-button[data-status="4"] { color: var(--blue); background: #f2f8fb; }
.status-button[data-status="5"] { color: var(--purple); background: #f8f5fd; }
.status-button[data-status="6"] { color: var(--red); background: #fff7f7; }
.status-button[data-status="7"] { color: var(--amber); background: #fffaf0; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 2000; transform: translate(-50%, 20px); max-width: min(90vw, 520px); padding: 11px 16px; border-radius: 10px; color: white; background: #21323d; box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: .18s; text-align: center; font-weight: 700; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .dispatch-grid { grid-template-columns: 1fr; }
  .map-panel { min-height: 520px; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar { align-items: center; }
  .brand-row span, .connection-pill, .user-name { display: none; }
  .page-shell { padding-top: 20px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card:last-child { grid-column: span 2; }
  .form-row { grid-template-columns: 1fr; }
  .map-panel { padding: 17px 17px 0; min-height: 450px; }
  .map { min-height: 380px; margin: 0 -17px; }
  .panel-heading { align-items: start; }
  .panel-heading > .muted { display: none; }
  .map-note { display: none; }
  .login-card { padding: 28px 22px; }
  .input-action { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .status-button-grid { grid-template-columns: 1fr; }
  .status-button { min-height: 74px; }
}


.audit-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: 80vh;
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.audit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.audit-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 20px 10px;
}

.audit-dialog > .compact-text {
  padding: 0 20px 12px;
}

.audit-list {
  padding: 0 20px 20px;
  overflow-y: auto;
  max-height: 60vh;
}

.audit-entry {
  padding: 12px 0;
  border-top: 1px solid #dde2e5;
}

.audit-entry:first-child {
  border-top: 0;
}

.audit-entry strong {
  display: block;
}

.audit-entry small {
  display: block;
  margin-top: 3px;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Auftragsarchiv */
#orderArchivePanel .compact-text {
  margin-bottom: 16px;
}

#orderArchivePanel > .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  margin-top: 4px;
}

