:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #18202b;
  --muted: #667085;
  --line: #dde3ee;
  --primary: #0b5cab;
  --primary-dark: #084f94;
  --danger: #b42318;
  --success: #087443;
  --warning: #b54708;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; padding: 10px 18px; background: #111827; color: white; border-bottom: 1px solid rgba(255,255,255,.08); }
.topbar-brand { display: flex; align-items: baseline; gap: 8px; flex: 0 0 auto; white-space: nowrap; }
.brand { color: white; font-weight: 800; font-size: 19px; }
.version { color: #cbd5e1; font-size: 13px; }
.topnav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; justify-content: center; flex: 1 1 auto; }
.topnav a { color: #f8fafc; padding: 8px 9px; border-radius: 8px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.topnav a:hover, .topnav a:focus { background: #1f3b64; text-decoration: none; outline: none; }
.user-menu { position: relative; flex: 0 0 auto; }
.user-menu summary { list-style: none; display: grid; gap: 1px; min-width: 170px; max-width: 260px; padding: 7px 34px 7px 10px; border-radius: 9px; background: #1f2937; color: #fff; cursor: pointer; font-weight: 800; line-height: 1.15; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: '▾'; position: absolute; right: 12px; top: 14px; color: #cbd5e1; font-size: 13px; }
.user-menu[open] summary::after { content: '▴'; }
.user-menu summary:hover, .user-menu summary:focus { background: #263449; outline: 3px solid rgba(255,255,255,.12); }
.user-menu summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu summary small { color: #cbd5e1; font-size: 11px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-dropdown { position: absolute; z-index: 2000; right: 0; top: calc(100% + 7px); min-width: 190px; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 34px rgba(16,24,40,.24); padding: 7px; }
.user-menu-dropdown a { display: block; padding: 10px 12px; border-radius: 9px; color: #1f2937; font-weight: 700; }
.user-menu-dropdown a:hover, .user-menu-dropdown a:focus { background: #eef4ff; text-decoration: none; outline: none; }
.nav { display: none; }
.container { max-width: 1450px; margin: 0 auto; padding: 24px; }
.container.narrow { max-width: 620px; }
h1 { margin-top: 0; }
h2 { margin: 0 0 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 1px 2px rgba(16,24,40,.05); margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col, .two-col-view { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stat { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.stat span { color: var(--muted); display: block; }
.stat strong { font-size: 34px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dispatch-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.inline-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.mini-form { display: inline-block; margin: 0; }
.remove-form { margin-right: 8px; margin-bottom: 8px; }
label { display: grid; gap: 6px; font-weight: 600; color: #344054; }
label.check { display: flex; gap: 8px; align-items: center; }
input, select, textarea { width: 100%; border: 1px solid #cfd8e3; border-radius: 9px; padding: 10px 11px; font: inherit; background: white; }
textarea { min-height: 90px; resize: vertical; }
input.small { max-width: 64px; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: var(--primary); color: white; padding: 10px 14px; border-radius: 9px; cursor: pointer; font-weight: 700; font: inherit; }
button:hover, .button:hover { background: var(--primary-dark); text-decoration: none; }
button.secondary, .button.secondary { background: #eef4ff; color: var(--primary); }
button.secondary:hover, .button.secondary:hover { background: #dbeafe; }
button.danger { background: var(--danger); }
.actions, .filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { background: #f8fafc; color: #344054; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
tr:last-child td { border-bottom: 0; }
small { color: var(--muted); }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.alert-error { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.alert-warning { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.alert-info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.pill { display: inline-flex; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; background: #eaecf0; color: #344054; }
.pill.requested { background: #fffaeb; color: #b54708; }
.pill.planned { background: #eff8ff; color: #175cd3; }
.pill.in_progress { background: #eef4ff; color: #3538cd; }
.pill.completed { background: #ecfdf3; color: #067647; }
.pill.cancelled { background: #fef3f2; color: #b42318; }
dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; }
dt { font-weight: 700; color: #344054; }
dd { margin: 0; }
.route-day-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.route-card h3 { margin-top: 0; }
.stops { padding-left: 22px; }
.stops li { margin-bottom: 12px; }
.footer { color: var(--muted); text-align: center; padding: 30px; }
@media (max-width: 900px) {
  .cards-4, .two-col, .two-col-view, .form-grid.two-col, .dispatch-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .topbar { align-items: stretch; flex-direction: column; }
  .topbar-brand { justify-content: space-between; }
  .topnav { justify-content: flex-start; }
  .user-menu summary { max-width: none; width: 100%; }
  .user-menu-dropdown { left: 0; right: auto; width: 100%; }
  .container { padding: 16px; }
}
.address-autocomplete { position: relative; display: grid; gap: 6px; }
.address-suggestions {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: 360px;
  overflow-y: auto;
  background: #ffffff;
  border: 2px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 18px 34px rgba(16,24,40,.24);
}
.address-suggestions:empty { display: none; }
.address-suggestion {
  appearance: none;
  -webkit-appearance: none;
  display: block !important;
  width: 100% !important;
  min-height: 0;
  text-align: left;
  border: 0 !important;
  border-bottom: 1px solid #e4e7ec !important;
  border-radius: 0 !important;
  background: #ffffff !important;
  color: #18202b !important;
  padding: 12px 14px !important;
  font-weight: 400 !important;
  line-height: 1.25;
  cursor: pointer;
}
.address-suggestion:last-child { border-bottom: 0 !important; }
.address-suggestion:hover,
.address-suggestion:focus {
  background: #eef4ff !important;
  color: #18202b !important;
  outline: 3px solid rgba(11,92,171,.18);
  outline-offset: -3px;
}
.address-suggestion-name {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 3px;
}
.address-suggestion-address {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #344054;
  white-space: normal;
}
.address-suggestion-empty {
  padding: 12px 14px;
  background: #ffffff;
  color: #344054;
  font-weight: 600;
}
/* v1.0.5 dispatch board */
.container { max-width: 1880px; }
.readonly-box {
  border: 1px solid #cfd8e3;
  border-radius: 9px;
  padding: 10px 11px;
  background: #f8fafc;
  display: grid;
  gap: 3px;
}
.readonly-box span { font-weight: 700; color: #344054; }
.readonly-box strong { color: var(--text); }
.dispatch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
}
.dispatch-toolbar small { display: block; margin-top: 3px; }
.dispatch-date-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dispatch-date-form { display: flex; gap: 8px; align-items: center; }
.dispatch-date-form input { min-width: 150px; }
.dispatch-board {
  display: grid;
  grid-template-columns: 280px minmax(700px, 1fr) 340px;
  gap: 12px;
  align-items: start;
}
.dispatch-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
  overflow: hidden;
}
.panel-title {
  background: var(--primary);
  color: #fff;
  padding: 9px 12px;
  font-weight: 800;
  letter-spacing: .01em;
}
.dispatch-count {
  margin: 10px 12px 0;
  background: #eef4ff;
  border: 1px solid #c7d7fe;
  border-radius: 999px;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  min-width: 36px;
  height: 28px;
}
.unplanned-list { padding: 10px; max-height: 78vh; overflow: auto; }
.unplanned-item {
  display: block;
  border: 1px solid #d0d5dd;
  border-left: 8px solid #b9e6fe;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  background: #f8fafc;
  margin-bottom: 8px;
}
.unplanned-item:hover { text-decoration: none; background: #eef4ff; }
.unplanned-item.active {
  border-left-color: #ffeb3b;
  background: #eaf2ff;
  box-shadow: inset 0 0 0 2px rgba(11,92,171,.18);
}
.unplanned-item .bookingno { display: block; font-weight: 800; color: var(--primary); }
.unplanned-item strong { display: block; }
.unplanned-item small { display: block; line-height: 1.25; }
.empty-text { color: var(--muted); font-size: 13px; margin: 10px 0; }
.dispatch-center { min-width: 0; }
.selected-booking { padding: 14px 16px 4px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.selected-booking h2 { font-size: 18px; margin-bottom: 10px; }
.selected-booking-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.selected-booking-grid div {
  background: #fff;
  border: 1px solid #e4e7ec;
  border-radius: 10px;
  padding: 9px;
}
.selected-booking-grid small { display: block; }
.selected-booking-grid strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dispatch-assign-form { padding: 12px; }
.assign-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}
.dispatch-table-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: 10px; }
.dispatch-table th { background: #eef4ff; color: #1d2939; }
.dispatch-table td { font-size: 13px; }
.dispatch-table .row-selected td { background: #fff9c4; }
.dispatch-right { background: #f8fafc; }
.new-route-box { display: grid; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); background: #fff; }
.route-list { padding: 10px; max-height: 78vh; overflow: auto; }
.route-mini-card {
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  margin-bottom: 10px;
  padding: 10px;
}
.route-update-form { display: grid; gap: 7px; }
.route-card-head { display: grid; grid-template-columns: 36px 1fr; gap: 7px; align-items: center; }
.route-count {
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 999px;
  min-width: 34px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: #fff;
}
.route-card-head input, .route-update-form select, .new-route-box input, .new-route-box select { padding: 8px 9px; border-radius: 8px; }
.route-stop-list { margin: 9px 0; padding-left: 22px; }
.route-stop-list li { margin-bottom: 8px; font-size: 13px; }
@media (max-width: 1250px) {
  .dispatch-board { grid-template-columns: 1fr; }
  .selected-booking-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .assign-bar { grid-template-columns: 1fr; }
}

/* v1.0.17: flydende beskeder uden layout-forskydning */
.dispatch-message {
  position: fixed;
  z-index: 2500;
  top: 68px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(390px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(16, 24, 40, .20);
  font-weight: 700;
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-12px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
}
.dispatch-message.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dispatch-message.success { background: #ecfdf3; color: #027a48; border-color: #75e0a7; }
.dispatch-message.error { background: #fef3f2; color: #b42318; border-color: #fda29b; }
.dispatch-toast-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: currentColor;
  color: #fff;
  font-size: 14px;
}
@media (max-width: 720px) {
  .dispatch-message { top: 62px; right: 10px; width: calc(100vw - 20px); }
}
.dispatch-board.is-busy { opacity: .72; pointer-events: none; }
.dispatch-hint { margin: 8px 12px 0; font-size: 13px; color: var(--muted); }
.unplanned-item { cursor: grab; user-select: none; }
.unplanned-item:active { cursor: grabbing; }
.unplanned-item.dragging { opacity: .45; }
.route-mini-card { transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease; }
.route-mini-card.drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11,92,171,.18);
  transform: translateY(-1px);
  background: #eef4ff;
}
.route-mini-card.active-route {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(11,92,171,.18);
}
.dispatch-center { min-height: 72vh; }
.route-detail { padding: 14px; }
.route-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.route-detail-head h2 { margin: 0 0 4px; }
.route-detail-head p { margin: 0; color: var(--muted); }
.route-count.large { width: 44px; height: 38px; }
.route-detail-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 240px) minmax(140px, 200px) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.route-detail-stops { overflow: auto; max-height: 65vh; border: 1px solid var(--line); border-radius: 10px; }
.route-detail-table { margin: 0; }
.route-detail-table th { background: #eef4ff; color: #1d2939; position: sticky; top: 0; z-index: 1; }
.route-detail-table td { font-size: 13px; vertical-align: top; }
.small-action { padding: 6px 9px; font-size: 12px; }
.drag-help { margin: 0 0 10px; color: var(--muted); }
.selected-booking-grid span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); white-space: normal; }
.empty-center { color: var(--muted); }
@media (max-width: 1250px) {
  .route-detail-form { grid-template-columns: 1fr; }
}

/* v1.0.9: klik på turoverskrift og sletning uden reload */
.route-open-title {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  text-align: left;
  background: #eef4ff;
  color: var(--text);
  border: 1px solid #c7d7fe;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.route-open-title:hover,
.route-open-title:focus {
  background: #dbeafe;
  color: var(--text);
  outline: 3px solid rgba(11,92,171,.18);
  outline-offset: 0;
}
.route-title-text { min-width: 0; display: grid; gap: 2px; }
.route-title-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-title-text small { display: block; line-height: 1.2; }
.route-detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.route-detail-actions .route-delete { min-height: 38px; }

/* v1.0.9: hovedmenu flyttet til topbar, Brugere/Afdelinger i brugermenu */

/* v1.0.9: højre turkort viser ikke længere bookingoversigt; valg huskes pr. dato */
.route-mini-card .route-update-form button { display: none; }
.route-drop-hint {
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px dashed #b9c7d8;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  text-align: center;
}
.route-mini-card.drop-target .route-drop-hint {
  border-color: var(--primary);
  background: #dbeafe;
  color: var(--primary);
  font-weight: 700;
}

/* v1.0.11: globus-kort og trækbar rækkefølge i åben tur */
.route-map-toggle {
  min-width: 42px;
  min-height: 38px;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.route-map-toggle.active {
  background: #dbeafe;
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(11,92,171,.16);
}
.route-map-panel {
  border: 1px solid #c7d7fe;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px;
  margin: 0 0 12px;
}
.route-map-panel[hidden] { display: none !important; }
.route-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.route-map-toolbar strong { color: var(--primary); }
.route-map-toolbar span { color: var(--muted); font-size: 13px; }
.route-map-canvas {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #eef4ff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
}
.route-map-note { margin: 8px 2px 0; color: var(--muted); font-size: 12px; }
.route-map-missing { margin-top: 8px; color: var(--muted); font-size: 12px; }
.route-map-missing ul { margin: 6px 0 0 18px; }
.route-map-error { padding: 14px; color: #b42318; }
.route-stop-row { cursor: grab; }
.route-stop-row:active { cursor: grabbing; }
.route-stop-row.stop-dragging { opacity: .45; background: #eef4ff; }
.route-stop-row.drop-before td { box-shadow: inset 0 3px 0 var(--primary); }
.route-stop-row.drop-after td { box-shadow: inset 0 -3px 0 var(--primary); }
.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #eef4ff;
  color: var(--primary);
  font-weight: 900;
  margin-right: 4px;
  cursor: grab;
}
.route-detail-table tbody tr:hover .drag-handle { background: #dbeafe; }
@media (max-width: 1250px) {
  .route-map-canvas { min-height: 280px; }
}

/* v1.0.11: højreklik på booking for at fjerne, og farver på rutekort */
.route-rightclick-hint {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}
.route-stop-row:hover {
  background: #f8fafc;
}
.route-map-marker {
  background: transparent;
  border: 0;
}
.route-map-marker span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .35);
}
.route-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.route-map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.route-map-legend-item i {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}

/* v1.0.12: globus på uplanlagte og redigering af adresser */
.panel-title-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-globe-button {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary);
  border: 1px solid #c7d7fe;
  font-size: 16px;
  line-height: 1;
}
.panel-globe-button:hover,
.panel-globe-button:focus,
.panel-globe-button.active {
  background: #dbeafe;
  color: var(--primary);
  outline: 3px solid rgba(255,255,255,.25);
}
.panel-globe-button.active {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.unplanned-map-detail .route-map-panel {
  margin-bottom: 8px;
}
.address-edit-form h2 {
  margin-bottom: 0;
}
.address-edit-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.address-edit-actions small {
  color: var(--muted);
  font-weight: 600;
}

/* v1.0.13: adresse-geokodning */
.geocode-card p { margin-top: 0; }
.geocode-progress { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--line); font-weight: 700; }
.geocode-progress.working { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.geocode-progress.ok { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.geocode-progress.warning { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.geocode-progress.error { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.geocode-log { display: grid; gap: 4px; max-height: 170px; overflow: auto; margin: 10px 0; font-size: 13px; color: var(--muted); }
.geocode-row-ok td { background: #f6fef9; }
.geocode-row-error td { background: #fffbfa; }
.js-geocode-one { margin: 8px 0; width: 100%; }

/* v1.0.17: adressekartotek uden reload */
.address-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.address-toolbar small { display: block; margin-top: 4px; }
.address-filter-actions { margin: 0; }
.address-filter-actions button.active {
  background: var(--primary);
  color: #fff;
}
.address-table tr[hidden] { display: none !important; }
.address-actions-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 135px;
}
.address-actions-cell button { width: 100%; }
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-card {
  width: min(780px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  color: var(--text);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(16, 24, 40, .38);
  padding: 18px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-header h2 { margin: 0; }
.modal-close {
  min-width: 42px;
  min-height: 42px;
  font-size: 24px;
  line-height: 1;
}
.address-modal-status {
  min-height: 22px;
  font-weight: 700;
  border-radius: 10px;
  padding: 9px 11px;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.address-modal-status:empty {
  display: none;
}
.address-modal-status.working { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }
.address-modal-status.ok { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.address-modal-status.error { background: #fef3f2; border-color: #fecdca; color: #b42318; }

/* v1.0.17: mere plads på disponering + tættere adressekartotek */
.container.page-dispatch {
  max-width: none;
  padding: 10px 12px 14px;
}
.page-dispatch .alert {
  margin-bottom: 8px;
  padding: 8px 10px;
}
.page-dispatch .dispatch-toolbar {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: none;
}
.page-dispatch .dispatch-toolbar small {
  font-size: 12px;
  line-height: 1.2;
}
.page-dispatch .dispatch-date-actions {
  gap: 6px;
}
.page-dispatch .dispatch-date-actions .button,
.page-dispatch .dispatch-date-actions button,
.page-dispatch .dispatch-date-form input {
  padding: 7px 9px;
  min-height: 34px;
}
.page-dispatch .dispatch-board {
  grid-template-columns: 292px minmax(540px, 1fr) 355px;
  gap: 8px;
}
.page-dispatch .dispatch-panel {
  border-radius: 10px;
}
.page-dispatch .panel-title {
  padding: 7px 10px;
}
.page-dispatch .dispatch-count {
  margin: 7px 10px 0;
  height: 24px;
  min-width: 32px;
  font-size: 13px;
}
.page-dispatch .dispatch-hint {
  margin: 6px 10px 0;
  font-size: 12px;
}
.page-dispatch .unplanned-list,
.page-dispatch .route-list {
  padding: 8px;
  max-height: calc(100vh - 218px);
}
.page-dispatch .unplanned-item {
  padding: 7px 9px;
  margin-bottom: 6px;
  border-radius: 9px;
  font-size: 13px;
}
.page-dispatch .unplanned-item small {
  font-size: 11px;
}
.page-dispatch .new-route-box {
  padding: 8px;
  gap: 6px;
}
.page-dispatch .new-route-box label {
  gap: 4px;
  font-size: 12px;
}
.page-dispatch .new-route-box input,
.page-dispatch .new-route-box select,
.page-dispatch .new-route-box button,
.page-dispatch .route-update-form input,
.page-dispatch .route-update-form select {
  padding: 7px 8px;
  min-height: 33px;
  font-size: 13px;
}
.page-dispatch .route-mini-card {
  padding: 8px;
  margin-bottom: 7px;
  border-radius: 10px;
}
.page-dispatch .route-open-title {
  padding: 7px;
  margin-bottom: 6px;
  grid-template-columns: 34px minmax(0, 1fr);
}
.page-dispatch .route-update-form {
  gap: 5px;
}
.page-dispatch .route-drop-hint {
  margin-top: 6px;
  padding: 5px 7px;
}
.page-dispatch .dispatch-center {
  min-height: calc(100vh - 162px);
}
.page-dispatch .route-detail {
  padding: 10px;
}
.page-dispatch .route-detail-head {
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.page-dispatch .route-detail-head h2 {
  font-size: 18px;
}
.page-dispatch .route-detail-form {
  gap: 8px;
  margin-bottom: 8px;
}
.page-dispatch .route-detail-form input,
.page-dispatch .route-detail-form select,
.page-dispatch .route-detail-form button {
  padding: 7px 8px;
  min-height: 34px;
  font-size: 13px;
}
.page-dispatch .route-detail-stops {
  max-height: calc(100vh - 315px);
}
.page-dispatch .route-detail-table th,
.page-dispatch .route-detail-table td {
  padding: 8px 9px;
}
.page-dispatch .route-map-canvas {
  min-height: 320px;
}

.container.page-addresses {
  max-width: none;
  padding: 14px;
}
.page-addresses h1 {
  margin-bottom: 10px;
  font-size: 24px;
}
.page-addresses .card {
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 10px;
}
.page-addresses .geocode-card h2 {
  margin-bottom: 6px;
}
.page-addresses .geocode-card p {
  margin: 0 0 6px;
}
.page-addresses .geocode-card .actions,
.page-addresses .inline-form,
.page-addresses .address-filter-actions {
  gap: 6px;
}
.page-addresses .geocode-card button,
.page-addresses .inline-form button,
.page-addresses .inline-form .button,
.page-addresses .address-filter-actions button {
  padding: 7px 10px;
  min-height: 34px;
}
.page-addresses .inline-form {
  align-items: center;
}
.page-addresses .inline-form label {
  min-width: 360px;
  flex: 1 1 420px;
}
.page-addresses .geocode-progress {
  margin: 6px 0;
  padding: 7px 9px;
}
.page-addresses .geocode-log {
  max-height: 92px;
  margin: 6px 0;
}
.page-addresses .address-toolbar {
  padding: 10px 12px;
}
.page-addresses .table-wrap {
  max-height: calc(100vh - 365px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.page-addresses table.address-table {
  min-width: 1320px;
  table-layout: fixed;
  border: 0;
  border-radius: 0;
  margin: 0;
  font-size: 13px;
}
.page-addresses .address-table th,
.page-addresses .address-table td {
  padding: 7px 8px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-addresses .address-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}
.page-addresses .address-table th:nth-child(1) { width: 220px; }
.page-addresses .address-table th:nth-child(2) { width: 360px; }
.page-addresses .address-table th:nth-child(3),
.page-addresses .address-table th:nth-child(4) { width: 115px; }
.page-addresses .address-table th:nth-child(5) { width: 105px; }
.page-addresses .address-table th:nth-child(6) { width: 145px; }
.page-addresses .address-table th:nth-child(7) { width: 70px; }
.page-addresses .address-table th:nth-child(8) { width: 290px; }
.page-addresses .address-table td:nth-child(6) small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-addresses .address-actions-cell {
  display: table-cell;
  min-width: 0;
  white-space: nowrap;
  overflow: visible;
}
.page-addresses .address-actions-cell button,
.page-addresses .js-geocode-one {
  width: auto;
  margin: 0 4px 0 0;
  padding: 5px 8px;
  min-height: 30px;
  font-size: 12px;
}
.page-addresses .address-actions-cell button:last-child {
  margin-right: 0;
}
@media (max-width: 1250px) {
  .page-dispatch .dispatch-board { grid-template-columns: 1fr; }
  .page-dispatch .unplanned-list,
  .page-dispatch .route-list,
  .page-dispatch .route-detail-stops { max-height: none; }
}


/* v1.0.18: højreklik-menu til booking uden browser-confirm */
.booking-context-menu {
  position: fixed;
  z-index: 2500;
  min-width: 190px;
  max-width: 280px;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(15, 23, 42, .24);
  color: #172033;
}
.booking-context-menu button {
  font: inherit;
}
.booking-context-remove {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 9px 11px;
  background: transparent;
  color: #b42318;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}
.booking-context-remove:hover,
.booking-context-remove:focus-visible {
  background: #fff1f0;
  outline: none;
}
.booking-context-menu.confirming {
  padding: 10px;
}
.booking-context-confirm-text {
  margin-bottom: 9px;
  font-size: .9rem;
  line-height: 1.35;
  font-weight: 650;
}
.booking-context-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}
.booking-context-actions button {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 7px 10px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}
.booking-context-actions .booking-context-confirm {
  border-color: #b42318;
  background: #b42318;
  color: #fff;
}
.booking-context-actions .booking-context-cancel:hover {
  background: #f1f5f9;
}
.booking-context-actions .booking-context-confirm:hover {
  background: #912018;
}


/* v1.1.1: tydelig bekræftelse og klikbar uplanlagt booking */
.booking-context-menu.confirming {
  min-width: 270px;
  padding: 12px;
  border: 2px solid #b42318;
}
.booking-context-confirm-text {
  margin-bottom: 11px;
  font-size: .95rem;
  font-weight: 800;
  color: #172033;
}
.booking-context-actions {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 9px;
}
.booking-context-actions button {
  min-height: 42px;
  padding: 9px 12px;
  font-size: .9rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.booking-context-actions .booking-context-cancel {
  border: 2px solid #64748b;
  background: #e2e8f0;
  color: #172033;
}
.booking-context-actions .booking-context-cancel:hover,
.booking-context-actions .booking-context-cancel:focus-visible {
  background: #cbd5e1;
  outline: 3px solid rgba(100,116,139,.2);
}
.booking-context-actions .booking-context-confirm {
  border: 2px solid #b42318;
  background: #b42318;
  color: #fff;
}
.unplanned-item {
  cursor: pointer;
}
.unplanned-item:hover,
.unplanned-item.is-selected {
  border-color: #0b63b6;
  box-shadow: 0 0 0 2px rgba(11,99,182,.16);
  background: #f0f7ff;
}
.unplanned-item.dragging {
  cursor: grabbing;
}

/* v1.1.1: Kun TR-nummeret markeres ved hastebooking */
.urgent-booking-no,
.bookingno.urgent-booking-no,
a.urgent-booking-no,
strong.urgent-booking-no { color: #c62828 !important; }

/* v1.1.3 - afdelingsstyring af bookingfelter */
.department-settings-table .check-cell { text-align: center; vertical-align: middle; }
.department-settings-table input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }
.department-settings-table small { font-weight: 400; opacity: .75; }
.department-controlled-field[hidden], .required-mark[hidden] { display: none !important; }
.required-mark { color: #c62828; font-weight: 700; }
.small-button { padding: .45rem .8rem; white-space: nowrap; }
.muted { opacity: .75; }

/* v1.1.4 - forenklet footer */

/* v1.1.5 chaufføradresse og ruteoptimering */
.driver-row-form{display:grid;grid-template-columns:1.1fr .8fr 2.4fr .55fr .55fr auto;gap:.55rem;align-items:center}
.driver-row-form input{min-width:0;margin:0}.driver-toggle-form{margin-top:.4rem;display:flex;justify-content:flex-end}
.driver-geocode-status{font-weight:700;font-size:.78rem;padding:.25rem .45rem;border-radius:999px;text-align:center}.driver-geocode-status.ok{background:#dcfce7;color:#166534}.driver-geocode-status.missing{background:#fee2e2;color:#991b1b}
.route-optimizer-panel{margin:.7rem 0;padding:.85rem;border:1px solid #93c5fd;border-radius:.65rem;background:#eff6ff;box-shadow:0 6px 18px rgba(15,23,42,.08)}
.route-optimizer-head,.route-optimizer-actions{display:flex;align-items:center;justify-content:space-between;gap:.75rem}.route-optimizer-head small{display:block;color:#475569;margin-top:.2rem}
.route-optimizer-stats{display:flex;flex-wrap:wrap;gap:.55rem;margin:.75rem 0}.route-optimizer-stats span{background:#fff;border:1px solid #dbeafe;border-radius:.45rem;padding:.45rem .6rem}
.route-optimizer-list{margin:.45rem 0 .75rem;padding-left:1.5rem}.route-optimizer-list li{padding:.25rem 0}.warning-text{color:#92400e;background:#fef3c7;padding:.5rem;border-radius:.4rem}
@media(max-width:900px){.driver-row-form{grid-template-columns:1fr}.driver-toggle-form{justify-content:flex-start}}


.settings-card{max-width:900px}.settings-example{display:flex;flex-direction:column;justify-content:center;padding:14px 16px;border:1px solid var(--border,#d7dde5);border-radius:10px;background:#f7f9fc}.settings-example strong{font-size:1.35rem;margin-top:4px}.route-optimizer-stats span{display:flex;flex-direction:column;gap:2px}.route-optimizer-stats small{font-size:.78rem;color:#5e6b7a}.route-time-note{margin:8px 0 0;font-size:.82rem;color:#5e6b7a}


/* v1.1.7: tydelig aktiv midtervisning */
.center-context { display:flex; align-items:center; gap:8px; min-height:32px; padding:6px 10px; margin:-2px -2px 10px; border-bottom:1px solid var(--line); background:#f1f5f9; font-size:13px; color:var(--muted); }
.center-context strong { color:var(--text); }
.unplanned-item.active-booking { outline:2px solid #2563eb; outline-offset:-2px; background:#eff6ff; }

/* v1.1.8 */
.selected-booking-remarks{grid-column:1/-1;background:#f6f8fb;border:1px solid #dfe5ec;padding:.75rem;border-radius:8px}.selected-booking-remarks strong{font-weight:500;white-space:normal}
.route-detail-table th:last-child,.route-detail-table td:last-child{white-space:nowrap}

/* v1.2.0: starttid på tur */
.route-detail-form { grid-template-columns: minmax(170px,1fr) minmax(110px,140px) minmax(160px,240px) minmax(140px,200px) auto; }
.route-update-form input[type=time] { min-width: 0; }
@media (max-width:1250px){ .route-detail-form{grid-template-columns:1fr;} }

/* v1.2.4: flyt bookinger mellem ture og tilbage til uplanlagt */
.unplanned-drop-label {
  margin: 8px 10px 0;
  padding: 7px 9px;
  border: 1px dashed #9cb4c9;
  border-radius: 6px;
  background: #f5f9fc;
  color: #49657c;
  font-size: .78rem;
  text-align: center;
}
.unplanned-list.drop-target,
.unplanned-panel:has(.unplanned-list.drop-target) .unplanned-drop-label {
  background: #e8f5ee;
  border-color: #2f855a;
}
.unplanned-list.drop-target {
  outline: 2px dashed #2f855a;
  outline-offset: -4px;
}


/* v1.2.5: robust drag/drop mellem ture og uplanlagt */
.route-stop-row { cursor: grab; user-select: none; }
.route-stop-row:active { cursor: grabbing; }
.unplanned-panel.drop-target,
.unplanned-panel.drop-target .unplanned-drop-label,
.unplanned-panel.drop-target .unplanned-list {
  background: #e8f5ee;
  border-color: #2f855a;
}
.unplanned-panel.drop-target { outline: 2px dashed #2f855a; outline-offset: -4px; }
.route-mini-card.drop-target { box-shadow: 0 0 0 3px rgba(47,133,90,.35); }

/* v1.2.6: fri datonavigation på hverdage */
.page-dispatch .dispatch-date-actions .button {
  white-space: nowrap;
}


/* v1.2.7: sammenklappeligt Ture/planer-panel og tydelig kortdatastatus */
.page-dispatch .dispatch-board {
  transition: grid-template-columns .2s ease;
}
.page-dispatch .dispatch-board.routes-panel-collapsed {
  grid-template-columns: 292px minmax(540px, 1fr) 48px;
}
.routes-panel-heading {
  padding: 0 !important;
}
.routes-panel-toggle {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}
.routes-panel-toggle:hover,
.routes-panel-toggle:focus-visible {
  background: rgba(255,255,255,.12);
}
.routes-panel-arrow {
  display: inline-block;
  transition: transform .2s ease;
}
.routes-panel-total {
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  font-size: 12px;
}
.routes-panel-content {
  min-width: 0;
}
.dispatch-right.is-collapsed {
  overflow: visible;
}
.dispatch-right.is-collapsed .routes-panel-content {
  display: none;
}
.dispatch-right.is-collapsed .routes-panel-toggle {
  min-height: 132px;
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: start;
  padding: 10px 5px;
}
.dispatch-right.is-collapsed .routes-panel-arrow {
  transform: rotate(180deg);
}
.dispatch-right.is-collapsed .routes-panel-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: 12px;
}
.dispatch-right.is-collapsed .routes-panel-total {
  margin-top: 4px;
}
.unplanned-map-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
}
.unplanned-map-summary > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.map-missing-badge {
  color: #b54708;
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.unplanned-map-missing-list {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid #fedf89;
  border-radius: 8px;
  background: #fffaeb;
  color: #7a2e0e;
  font-size: 12px;
}
.unplanned-map-missing-list summary {
  cursor: pointer;
  font-weight: 800;
}
.unplanned-map-missing-list ul {
  margin: 7px 0 0 18px;
}
@media (max-width: 1250px) {
  .page-dispatch .dispatch-board.routes-panel-collapsed { grid-template-columns: 1fr; }
  .dispatch-right.is-collapsed .routes-panel-toggle { min-height: 38px; grid-template-columns: auto minmax(0,1fr) auto; justify-items: stretch; align-content: center; padding: 7px 9px; }
  .dispatch-right.is-collapsed .routes-panel-label { writing-mode: initial; transform: none; }
  .dispatch-right.is-collapsed .routes-panel-arrow { transform: rotate(90deg); }
  .dispatch-right.is-collapsed .routes-panel-total { margin-top: 0; }
}

/* v1.2.8: kun formularen til ny tur kan foldes sammen; planerne er altid synlige */
.page-dispatch .dispatch-board,
.page-dispatch .dispatch-board.routes-panel-collapsed {
  grid-template-columns: 292px minmax(540px, 1fr) minmax(285px, 340px);
}
.dispatch-right,
.dispatch-right.is-collapsed {
  overflow: hidden;
}
.dispatch-right .routes-panel-content,
.dispatch-right.is-collapsed .routes-panel-content {
  display: block;
}
.routes-panel-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px !important;
}
.routes-panel-heading > .routes-panel-label {
  flex: 1;
  writing-mode: initial;
  transform: none;
  white-space: nowrap;
  font-size: inherit;
}
.routes-panel-heading > .routes-panel-total {
  margin: 0;
}
.new-route-toggle {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 7px;
  padding: 4px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.new-route-toggle:hover,
.new-route-toggle:focus-visible { background: rgba(255,255,255,.22); }
.new-route-toggle-icon { transition: transform .18s ease; }
.new-route-toggle.is-open .new-route-toggle-icon { transform: rotate(45deg); }
.new-route-panel[hidden] { display: none !important; }
.new-route-panel { border-bottom: 1px solid var(--line); }
.new-route-panel .new-route-box { margin: 8px; }
@media (max-width: 1180px) {
  .page-dispatch .dispatch-board,
  .page-dispatch .dispatch-board.routes-panel-collapsed { grid-template-columns: 1fr; }
}
