:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-strong: #fcfdff;
  --border: #d3d9e2;
  --border-strong: #7f8ea3;
  --text: #16202a;
  --muted: #4b5b6a;
  --focus: #0b57d0;
  --danger: #b3261e;
  --success: #166534;
  --warning: #92400e;
  --header: #0f2742;
  --button-bg: #163a63;
  --button-border: #24476e;
  --button-hover: #0f2d4e;
  --button-text: #ffffff;
  --link-button-bg: #ffffff;
  --link-button-text: #163a63;
  --link-button-hover: #f0f6ff;
  --table-head: #eaf0f7;
  --input-bg: #ffffff;
  --code-bg: #f8fafc;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
}

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

body {
  min-height: 100vh;
  font-size: 1.0625rem;
}

.wrap {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  background: var(--header);
  color: #fff;
  padding: 1.25rem 0;
}

.site-header h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.3;
}

.subtitle {
  margin: 0.35rem 0 0;
}

.top-link {
  display: inline-block;
  margin: 1rem 0 0;
  font-weight: 700;
  color: inherit;
  text-decoration: underline;
}

.top-link:focus,
.top-link:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #fff;
  color: #000;
  padding: 0.75rem 1rem;
  z-index: 9999;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  margin: 1rem 0;
}

.hidden {
  display: none !important;
}

.form-grid,
.filter-grid,
.detail-grid,
.internal-booking-grid {
  display: grid;
  gap: 1rem;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  margin-bottom: 1rem;
}

.detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-bottom: 1rem;
}

.internal-booking-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-full {
  grid-column: 1 / -1;
}

.action-field {
  display: flex;
  align-items: end;
}

.checkbox-field {
  margin-top: 0.5rem;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
}

.checkbox-inline input[type="checkbox"] {
  transform: scale(1.2);
}

label,
legend,
h1,
h2,
h3,
h4,
th {
  font-weight: 700;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--border-strong);
  border-radius: 0.45rem;
  padding: 0.75rem 0.85rem;
  background: var(--input-bg);
  color: var(--text);
  min-height: 3rem;
}

button {
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-text);
  border-radius: 0.45rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  min-height: 3rem;
  font-weight: 700;
}

button:hover,
button:focus-visible {
  background: var(--button-hover);
}

input:focus,
select:focus,
textarea:focus,
button:focus,
.table-wrap:focus,
button:focus-visible,
summary:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.top-bar,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.filter-toggle-row,
.internal-booking-toggle-row {
  margin: 1rem 0;
}

.filter-toggle,
.internal-booking-toggle {
  min-width: 180px;
}

.help-text {
  color: var(--muted);
  margin-top: 0.25rem;
}

.status-message {
  margin-top: 0.75rem;
  min-height: 1.5rem;
}

.status-message[data-type="error"] {
  color: var(--danger);
  font-weight: 700;
}

.status-message[data-type="success"] {
  color: var(--success);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--panel);
}

.booking-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

.booking-table th,
.booking-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.booking-table th {
  background: var(--table-head);
}

.detail-panel .detail-box,
.internal-card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  background: var(--panel-strong);
}

.internal-card h4 {
  margin-top: 0;
}

.internal-estimate-box {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.85rem;
  background: var(--panel);
  margin-bottom: 1rem;
}

.internal-estimate-box p {
  margin: 0.35rem 0;
}

.meta-list {
  margin: 0;
}

.meta-list dt {
  font-weight: 700;
  margin-top: 0.5rem;
}

.meta-list dd {
  margin: 0.15rem 0 0.5rem 0;
  color: var(--muted);
}

.edit-fieldset {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #eef3f8;
  color: var(--text);
  font-size: 0.92rem;
  white-space: nowrap;
}

.badge.pending { background: #f5f3ff; }
.badge.confirmed { background: #eff6ff; }
.badge.assigned { background: #ecfeff; }
.badge.completed { background: #ecfdf5; }
.badge.canceled { background: #fef2f2; }

.link-button {
  border: 1px solid var(--button-border);
  background: var(--link-button-bg);
  color: var(--link-button-text);
}

.link-button:hover,
.link-button:focus-visible {
  background: var(--link-button-hover);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
}

.collapsible-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.collapse-toggle {
  min-width: 220px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.code-preview {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 0.5rem;
}

/* Appearance settings section */

.appearance-details {
  margin: 1rem 0;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.appearance-details summary {
  cursor: pointer;
  font-weight: 700;
  list-style: revert;
}

.appearance-details summary::-webkit-details-marker {
  display: inline;
}

.appearance-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.appearance-form {
  display: block;
}

.appearance-fieldset {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 0;
  background: var(--panel-strong);
}

.appearance-fieldset legend {
  font-weight: 700;
  padding: 0 0.25rem;
}

.appearance-actions {
  margin-top: 1rem;
}

/* Dispatch appearance classes */

body.theme-light {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-strong: #fcfdff;
  --border: #d3d9e2;
  --border-strong: #7f8ea3;
  --text: #16202a;
  --muted: #4b5b6a;
  --focus: #0b57d0;
  --danger: #b3261e;
  --success: #166534;
  --warning: #92400e;
  --header: #0f2742;
  --button-bg: #163a63;
  --button-border: #24476e;
  --button-hover: #0f2d4e;
  --button-text: #ffffff;
  --link-button-bg: #ffffff;
  --link-button-text: #163a63;
  --link-button-hover: #f0f6ff;
  --table-head: #eaf0f7;
  --input-bg: #ffffff;
  --code-bg: #f8fafc;
}

body.theme-dark {
  --bg: #0b1220;
  --panel: #111827;
  --panel-strong: #1f2937;
  --border: #374151;
  --border-strong: #9ca3af;
  --text: #f9fafb;
  --muted: #d1d5db;
  --focus: #93c5fd;
  --danger: #fca5a5;
  --success: #86efac;
  --warning: #fcd34d;
  --header: #000000;
  --button-bg: #374151;
  --button-border: #4b5563;
  --button-hover: #4b5563;
  --button-text: #ffffff;
  --link-button-bg: #111827;
  --link-button-text: #f9fafb;
  --link-button-hover: #1f2937;
  --table-head: #1f2937;
  --input-bg: #111827;
  --code-bg: #111827;
}

body.bg-soft {
  --bg: #eef4f8;
}

body.bg-warm {
  --bg: #fbf4ea;
}

body.bg-cool {
  --bg: #edf6f9;
}

body.large-font {
  font-size: 1.22rem;
}

body.large-font input,
body.large-font select,
body.large-font textarea,
body.large-font button {
  font-size: 1.08em;
}

body.high-contrast {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --border: #000000;
  --border-strong: #000000;
  --text: #000000;
  --muted: #111111;
  --focus: #ffbf47;
  --danger: #8b0000;
  --success: #006400;
  --warning: #8b4513;
  --header: #000000;
  --button-bg: #000000;
  --button-border: #000000;
  --button-hover: #222222;
  --button-text: #ffffff;
  --link-button-bg: #ffffff;
  --link-button-text: #000000;
  --link-button-hover: #f2f2f2;
  --table-head: #f0f0f0;
  --input-bg: #ffffff;
  --code-bg: #ffffff;
}

body.high-contrast .panel,
body.high-contrast .detail-panel .detail-box,
body.high-contrast .internal-card,
body.high-contrast .internal-estimate-box,
body.high-contrast .edit-fieldset,
body.high-contrast .appearance-fieldset,
body.high-contrast .table-wrap,
body.high-contrast input,
body.high-contrast select,
body.high-contrast textarea,
body.high-contrast .booking-table th,
body.high-contrast .booking-table td,
body.high-contrast .code-preview {
  border-width: 2px;
}

body.btn-large button {
  min-height: 3.5rem;
  padding: 1rem 1.3rem;
  font-size: 1.05em;
}

body.btn-xlarge button {
  min-height: 4rem;
  padding: 1.15rem 1.5rem;
  font-size: 1.12em;
}

@media (max-width: 768px) {
  body {
    font-size: 1rem;
  }

  .site-header h1 {
    font-size: 1.5rem;
  }

  .top-bar,
  .actions,
  .collapsible-header {
    align-items: stretch;
  }

  .filter-toggle,
  .internal-booking-toggle,
  .collapse-toggle,
  button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto;
  }
}

:root {
  --estimate-highlight: #facc15;
  --booked-highlight: #22c55e;
}

.estimate-section {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: var(--panel-strong);
}

.estimate-toggle-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.estimate-toggle-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 280px;
}

.estimate-toggle-button {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.estimate-toggle-button.has-estimates {
  border-color: color-mix(in srgb, var(--estimate-highlight) 55%, #7a5d00);
  background: color-mix(in srgb, var(--estimate-highlight) 30%, white);
  color: #3f3200;
}

.estimate-toggle-button.has-new-estimates {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--estimate-highlight) 35%, transparent);
}

.estimate-count-badge,
.estimate-new-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
}

.estimate-count-badge {
  min-width: 2rem;
}

.estimate-new-badge {
  background: color-mix(in srgb, var(--estimate-highlight) 28%, white);
  color: #4d3b00;
  border-color: color-mix(in srgb, var(--estimate-highlight) 60%, #7a5d00);
}

.estimate-toggle-note {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.estimate-panel {
  margin-top: 1rem;
}

.row-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.warn-button {
  background: #fff7d6;
  color: #6b4e00;
  border-color: #b58a00;
}

.warn-button:hover,
.warn-button:focus-visible {
  background: #ffefb0;
}

.danger-button {
  background: #ffe2e2;
  color: #7a1111;
  border-color: #b52a2a;
}

.danger-button:hover,
.danger-button:focus-visible {
  background: #ffcaca;
}

.booking-row-estimate {
  background: color-mix(in srgb, var(--estimate-highlight) 18%, white);
}

.booking-row-booked {
  background: color-mix(in srgb, var(--booked-highlight) 14%, white);
}

.status-badge-estimate {
  background: color-mix(in srgb, var(--estimate-highlight) 28%, white);
  color: #4d3b00;
  border-color: color-mix(in srgb, var(--estimate-highlight) 60%, #7a5d00);
}

.status-badge-booked {
  background: color-mix(in srgb, var(--booked-highlight) 20%, white);
  color: #114b28;
  border-color: color-mix(in srgb, var(--booked-highlight) 60%, #1f6d3f);
}

@media (max-width: 700px) {
  .estimate-toggle-controls {
    min-width: 100%;
  }

  .estimate-toggle-button {
    width: 100%;
    justify-content: center;
  }

  .row-action-group {
    flex-direction: column;
  }
}


.pending-review-table .link-button { margin-right: 0.5rem; }
.detail-actions-wrap { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hidden-action { display: none !important; }


.estimate-alert-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-top: 0.75rem;
}

.estimate-alert-toggle {
  min-width: 220px;
}


.estimate-alert-volume-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 220px;
}

.estimate-alert-volume-wrap label {
  font-weight: 700;
}

#estimate-alert-volume {
  min-height: auto;
  padding: 0;
}

.estimate-alert-volume-value {
  font-weight: 700;
  color: var(--muted);
}

.estimate-alert-status {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.estimate-alert-banner {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 0.65rem;
  border: 2px solid color-mix(in srgb, var(--estimate-highlight) 70%, #7a5d00);
  background: color-mix(in srgb, var(--estimate-highlight) 20%, white);
  color: #3f3200;
  font-weight: 700;
}

.estimate-alert-banner.is-flashing {
  animation: estimateBannerFlash 1.2s linear infinite;
}

@keyframes estimateBannerFlash {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  }
  50% {
    opacity: 0.65;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--estimate-highlight) 45%, transparent);
  }
}

.estimate-inline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--estimate-highlight) 60%, #7a5d00);
  background: color-mix(in srgb, var(--estimate-highlight) 24%, white);
  color: #4d3b00;
  font-size: 0.85rem;
  font-weight: 700;
}

.estimate-inline-badge.reminder-due {
  background: #fff1f1;
  color: #8a1d1d;
  border-color: #b52a2a;
}

.acknowledge-button {
  background: #ecfff2;
  color: #114b28;
  border-color: #1f6d3f;
}

.acknowledge-button:hover,
.acknowledge-button:focus-visible {
  background: #d9fbe5;
}

.booking-row-new-estimate {
  box-shadow: inset 4px 0 0 0 color-mix(in srgb, var(--estimate-highlight) 85%, #7a5d00);
}

.booking-row-reminder-due {
  outline: 2px solid #b52a2a;
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .estimate-alert-banner.is-flashing {
    animation: none;
  }
}




/* Messaging drawer and compact workspace updates */
#dashboard-section {
  display: block;
}

.bookings-panel-content-collapsed #bookings-panel-content {
  display: none;
}

.bookings-panel .top-bar .actions {
  flex-wrap: wrap;
}

.message-panel {
  margin: 0;
}

.message-drawer {
  position: fixed;
  top: 5.25rem;
  right: 0.75rem;
  width: min(25rem, calc(100vw - 1.5rem));
  height: calc(100vh - 6rem);
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  z-index: 1400;
  box-shadow: 0 1rem 2rem rgba(15, 39, 66, 0.22);
  transform: translateX(calc(100% + 1rem));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.2s ease, visibility 0.2s ease;
}

body.messages-drawer-open .message-drawer {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.dispatch-messages-backdrop {
  display: none;
}

.dispatch-messages-tab {
  position: fixed;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1390;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  min-width: 0;
  border-radius: 0.75rem 0.75rem 0 0;
  padding: 0.85rem 0.55rem;
}

body.messages-drawer-open .dispatch-messages-tab {
  opacity: 0;
  pointer-events: none;
}

.messages-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: start;
  flex: 0 0 auto;
}

.messages-toolbar .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.messages-toolbar .actions button {
  flex: 1 1 9rem;
}

.message-compose-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  margin-bottom: 0.25rem;
  flex: 0 0 auto;
}

.message-thread-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  flex: 0 0 auto;
}

.thread-filter-button {
  min-width: 8rem;
}

.thread-filter-button.active-thread-filter {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.message-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  min-height: 0;
  flex: 1 1 auto;
}

.message-thread-list-wrap,
.message-thread-view {
  min-height: 0;
}

.message-thread-list,
.message-thread {
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--panel-strong);
  min-height: 8rem;
  max-height: 12rem;
  overflow: auto;
  padding: 0.75rem;
}

.message-thread {
  max-height: 16rem;
}

.message-thread-list button.thread-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.message-thread-list button.thread-item.active-thread {
  border-color: var(--focus);
  box-shadow: inset 0 0 0 2px var(--focus);
}

.message-thread-list .thread-meta,
.message-bubble-meta,
.shortcut-note {
  font-size: 0.95rem;
  color: var(--muted);
}

.message-subheading {
  margin: 0 0 0.5rem;
}

.message-bubble {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: #fff;
}

.message-bubble.from-dispatch {
  border-left: 5px solid #0b57d0;
}

.message-bubble.from-driver {
  border-left: 5px solid #166534;
}

.message-bubble.urgent-message {
  background: #fff7ed;
}

.empty-state {
  color: var(--muted);
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 901px) {
  .message-drawer {
    width: min(27rem, calc(100vw - 2rem));
  }

  .message-layout {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }

  .message-thread-list,
  .message-thread {
    max-height: calc(100vh - 23rem);
  }
}

@media (max-width: 900px) {
  .dispatch-messages-tab {
    display: none;
  }

  .message-drawer {
    top: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    transform: translateX(100%);
  }

  .dispatch-messages-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 39, 66, 0.35);
    border: 0;
    padding: 0;
    z-index: 1350;
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    text-indent: -9999px;
    overflow: hidden;
  }

  body.messages-drawer-open .dispatch-messages-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.messages-drawer-open {
    overflow: hidden;
  }

  .messages-toolbar .actions button {
    flex: 1 1 calc(50% - 0.6rem);
  }

  .message-thread-list,
  .message-thread {
    max-height: 24vh;
  }
}

@media (max-width: 560px) {
  #dashboard-section .panel {
    padding: 0.85rem;
  }

  .bookings-panel .top-bar .actions button,
  .messages-toolbar .actions button {
    width: 100%;
    flex-basis: 100%;
  }

  .message-drawer {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .message-thread-list,
  .message-thread {
    max-height: 22vh;
  }
}


.message-center-group,
.message-center-subgroup {
  margin-top: 0.85rem;
  border: 1px solid #d0d5dd;
  border-radius: 0.85rem;
  background: #fff;
}

.message-center-group > summary,
.message-center-subgroup > summary {
  cursor: pointer;
  padding: 0.85rem 1rem;
  font-weight: 700;
}

.message-center-section {
  padding: 0 0.85rem 0.85rem;
}

.message-card-list {
  display: grid;
  gap: 0.75rem;
  padding: 0 0.15rem 0.75rem;
}

.website-chat-card {
  border: 1px solid #d0d5dd;
  border-radius: 0.85rem;
  padding: 0.85rem;
  background: #f8fafc;
}

.website-chat-card.is-unread {
  border-color: #0b5fff;
}

.website-chat-card h4 {
  margin: 0 0 0.45rem;
}

.website-chat-meta {
  font-size: 0.95rem;
  color: #475467;
  margin-bottom: 0.55rem;
}

.website-chat-message {
  white-space: pre-wrap;
  margin: 0 0 0.75rem;
}

.website-chat-actions,
.thread-management-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.website-chat-actions button,
.thread-management-actions button {
  width: auto;
}

@media (max-width: 560px) {
  .website-chat-actions button,
  .thread-management-actions button {
    width: 100%;
  }
}

/* Dispatch Needs Attention alert rebuild: alerts are a normal collapsible dashboard section, never a full-page trap. */
.dispatch-alert-panel {
  scroll-margin-top: 1rem;
}

.dispatch-alert-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: #92400e;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dispatch-alert-content[hidden] {
  display: none !important;
}

.alert-status {
  min-height: 1.4rem;
  margin: 0.75rem 0;
  font-weight: 700;
}

.alert-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.625rem;
  margin: 0.75rem 0;
}

.summary-card {
  padding: 0.75rem;
  border: 1px solid #d7dee8;
  border-radius: 0.75rem;
  background: #f8fafc;
}

.summary-card strong {
  display: block;
  color: #0f2a45;
  font-size: 1.35rem;
  line-height: 1;
}

.summary-card span {
  display: block;
  margin-top: 0.25rem;
  color: #4b5563;
  font-size: 0.9rem;
}

.alert-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 0.75rem;
  align-items: start;
  margin: 0.875rem 0;
  padding: 0.75rem;
  border: 1px solid #d7dee8;
  border-radius: 0.875rem;
  background: #f8fbff;
}

.bulk-left,
.bulk-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.bulk-right {
  justify-content: flex-end;
}

.alert-btn {
  min-height: 42px;
}

.alert-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.selected-count {
  padding: 0.5rem 0.625rem;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0f2a45;
  font-size: 0.9rem;
  font-weight: 800;
}

.alerts-list {
  display: grid;
  gap: 0.625rem;
}

.alert-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #d7dee8;
  border-left: 7px solid #b45309;
  border-radius: 0.875rem;
  background: #fffaf2;
}

.alert-row.alert-urgent,
.alert-row.alert-overdue {
  border-left-color: #dc2626;
  background: #fff5f5;
}

.alert-row.alert-selected {
  border-color: #14395d;
  box-shadow: 0 0 0 3px rgba(20, 57, 93, 0.16);
}

.alert-check {
  width: 1.5rem;
  height: 1.5rem;
  accent-color: #14395d;
}

.alert-main {
  min-width: 0;
}

.alert-title-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  line-height: 1.25;
}

.alert-title-line strong {
  color: #0f2a45;
}

.alert-customer {
  color: #111827;
  font-weight: 700;
}

.alert-message,
.alert-meta {
  margin-top: 0.25rem;
  font-size: 0.95rem;
  line-height: 1.35;
}

.alert-meta {
  color: #4b5563;
}

.alert-open-btn {
  white-space: nowrap;
}

.no-alerts {
  padding: 1rem;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 0.875rem;
  color: #14532d;
  font-weight: 800;
}

@media (max-width: 820px) {
  .dispatch-alert-header {
    align-items: stretch;
  }

  .alert-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alert-actions {
    grid-template-columns: 1fr;
  }

  .bulk-left,
  .bulk-right {
    justify-content: stretch;
  }

  .alert-btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 560px) {
  .dispatch-alert-header {
    flex-direction: column;
  }

  .dispatch-alert-header .secondary-button {
    width: 100%;
  }

  .alert-summary {
    grid-template-columns: 1fr 1fr;
  }

  .alert-actions {
    padding: 0.625rem;
  }

  .bulk-left,
  .bulk-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .selected-count,
  #mark-selected-paid,
  #mark-selected-followup,
  #dismiss-selected-alerts,
  #admin-cleanup-paid {
    grid-column: 1 / -1;
    width: 100%;
  }

  .alert-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    padding: 0.75rem 0.625rem;
  }

  .alert-open-btn {
    grid-column: 2;
    width: 100%;
  }

  .alert-title-line {
    display: grid;
    gap: 0.125rem;
  }
}

.secondary-button {
  border: 1px solid var(--button-border, #24476e);
  background: var(--link-button-bg, #ffffff);
  color: var(--link-button-text, #163a63);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: var(--link-button-hover, #f0f6ff);
}

/* Mobile dispatch table refinement - keeps desktop tables unchanged */
@media (max-width: 760px) {
  .table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }

  .booking-table,
  .booking-table thead,
  .booking-table tbody,
  .booking-table tr,
  .booking-table th,
  .booking-table td {
    display: block;
    width: 100%;
  }

  .booking-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .booking-table tr {
    margin: 0 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--panel);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    overflow: hidden;
  }

  .booking-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    word-break: break-word;
  }

  .booking-table td:last-child {
    border-bottom: 0;
  }

  .booking-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.125rem;
    font-size: 0.78rem;
    line-height: 1.2;
    font-weight: 700;
    color: var(--muted);
  }

  .booking-table td.mobile-customer-cell,
  .booking-table td[data-label="Customer"] {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    background: var(--table-head);
  }

  .booking-table td.mobile-customer-cell::before,
  .booking-table td[data-label="Customer"]::before {
    color: var(--muted);
  }

  .row-action-group,
  .mobile-actions-cell {
    display: grid;
    gap: 0.5rem;
  }

  .mobile-actions-cell .link-button,
  .row-action-group .link-button {
    width: 100%;
    min-height: 44px;
    text-align: center;
  }

  #dashboard-message.status-message {
    display: block;
    margin: 0.75rem 0 1rem;
    font-size: 1rem;
    font-weight: 700;
  }
}

/* Dispatch responsive polish - May 2026
   Safe CSS-only refinement. Keeps full Dispatch HTML and JavaScript intact. */
html,
body {
  min-height: 100%;
  overflow-y: auto;
}

#dashboard-section,
.bookings-panel,
.dispatch-alert-panel {
  position: relative;
  overflow: visible;
}

.dispatch-alert-panel {
  margin-bottom: 1rem;
}

.dispatch-alert-header h2,
.bookings-panel h2 {
  margin-top: 0;
}

.alert-actions {
  align-items: center;
}

.alert-actions .alert-btn,
.top-bar .actions button {
  white-space: nowrap;
}

.no-alerts {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
}

.bookings-panel .top-bar {
  align-items: flex-start;
}

.bookings-panel .top-bar .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  justify-content: flex-start;
}

.bookings-panel .top-bar .actions button {
  min-height: 44px;
}

#dashboard-message.status-message[data-type="success"] {
  display: block;
  margin: 1rem 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.dispatch-messages-tab {
  z-index: 20;
}

.booking-table td[data-label="Time"] {
  white-space: nowrap;
}

.booking-table td[data-label="Phone"],
.booking-table td[data-label="Email"] {
  word-break: normal;
  overflow-wrap: anywhere;
}

@media (min-width: 761px) {
  .booking-table th,
  .booking-table td {
    padding: 0.65rem 0.75rem;
  }

  .booking-table td[data-label="Customer"] {
    min-width: 10rem;
  }

  .booking-table td[data-label="Phone"] {
    min-width: 8.5rem;
  }

  .booking-table td[data-label="Details"] .link-button {
    white-space: nowrap;
  }
}

@media (max-width: 760px) {
  .wrap {
    width: min(100% - 1rem, 1100px);
  }

  .site-header,
  .top-link {
    display: none;
  }

  .panel,
  .bookings-panel,
  .dispatch-alert-panel {
    padding: 0.875rem;
    margin: 0.75rem 0;
    border-radius: 0.875rem;
  }

  .dispatch-alert-header,
  .bookings-panel .top-bar {
    display: block;
  }

  .dispatch-alert-header .help-text,
  .bookings-panel .help-text {
    margin-bottom: 0.75rem;
  }

  .dispatch-alert-header .secondary-button,
  .bookings-panel .top-bar .actions button {
    width: 100%;
    margin: 0;
  }

  .bookings-panel .top-bar .actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .alert-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.625rem;
  }

  .bulk-left,
  .bulk-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .bulk-left .selected-count,
  .bulk-right .alert-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .alerts-list {
    gap: 0.5rem;
  }

  .alert-row {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 0.75rem;
  }

  .alert-open-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: visible;
  }

  .booking-table tr {
    margin-bottom: 0.625rem;
    border-radius: 0.875rem;
  }

  .booking-table td {
    padding: 0.45rem 0.75rem;
    line-height: 1.35;
  }

  .booking-table td::before {
    margin-bottom: 0.05rem;
  }

  .booking-table td[data-label="Time"] {
    white-space: normal;
  }

  .booking-table td[data-label="Phone"],
  .booking-table td[data-label="Email"] {
    overflow-wrap: anywhere;
  }

  .booking-table td[data-label="Details"] {
    padding-top: 0.7rem;
  }

  .mobile-actions-cell .link-button,
  .row-action-group .link-button {
    min-height: 42px;
  }

  .dispatch-messages-tab {
    right: 0;
    top: auto;
    bottom: 1rem;
    writing-mode: horizontal-tb;
    transform: none;
    border-radius: 0.75rem 0 0 0.75rem;
    padding: 0.65rem 0.85rem;
  }
}

/* =========================================================
   Dispatch desktop + Surface Pro refinement patch
   Added 2026-05-03
   Purpose: preserve the original Dispatch CSS while tightening
   desktop layout, preventing the floating Messages tab from
   covering controls, and keeping mobile behavior intact.
   ========================================================= */

/* Keep the page scrollable at all times. No Dispatch panel should trap the user. */
html,
body {
  min-height: 100%;
  overflow-y: auto !important;
}

#dashboard-section,
.bookings-panel,
.dispatch-alert-panel,
.panel {
  max-width: 100%;
}

/* Create safe right-side breathing room on desktop so the vertical Messages tab
   does not cover Show Admin / Promo / Import buttons on Surface Pro width. */
@media (min-width: 901px) {
  .wrap {
    width: min(1180px, calc(100% - 2rem));
    padding-right: 3.75rem;
  }

  .dispatch-messages-tab {
    right: 0.35rem;
    top: 58%;
    z-index: 30;
    padding: 0.7rem 0.45rem;
    border-radius: 0.6rem 0 0 0.6rem;
    box-shadow: 0 0.5rem 1rem rgba(15, 39, 66, 0.18);
  }

  .message-drawer {
    right: 0.75rem;
    width: min(27rem, calc(100vw - 2.5rem));
  }
}

/* Standardize collapsible section headers: title left, action button right. */
.collapsible-header,
.admin-section-header,
.promo-section-header,
.import-section-header,
.bookings-panel .top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.collapsible-header h2,
.admin-section-header h2,
.promo-section-header h2,
.import-section-header h2,
.bookings-panel .top-bar h2 {
  margin: 0;
  line-height: 1.25;
}

.collapsible-header button,
.admin-section-header button,
.promo-section-header button,
.import-section-header button {
  flex: 0 0 auto;
  max-width: 26rem;
}

/* Make large show/hide buttons more consistent without making them tiny. */
.collapse-toggle,
.filter-toggle,
.internal-booking-toggle,
#admin-toggle,
#promo-code-toggle,
#import-toggle,
button[id*="admin"],
button[id*="promo"],
button[id*="import"] {
  min-height: 3rem;
  padding: 0.75rem 1rem;
}

/* Tighten desktop spacing so Surface Pro users can see more without excess scroll. */
@media (min-width: 761px) {
  .panel {
    padding: 0.95rem 1rem;
    margin: 0.8rem 0;
  }

  .appearance-details {
    margin: 0.75rem 0;
    padding-top: 0.75rem;
  }

  .filter-toggle-row,
  .internal-booking-toggle-row {
    margin: 0.75rem 0;
  }

  .admin-grid,
  .form-grid,
  .filter-grid,
  .detail-grid,
  .internal-booking-grid {
    gap: 0.8rem;
  }
}

/* Better toolbar grouping for alerts and bookings. */
.alert-actions,
.bookings-panel .top-bar .actions {
  gap: 0.65rem;
}

.alert-actions .alert-btn,
.bookings-panel .top-bar .actions button {
  min-width: 8.5rem;
}

.no-alerts {
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
}

/* Prevent wide action buttons from disappearing under the messages tab on
   middle-width desktops and Surface Pro landscape. */
@media (min-width: 901px) and (max-width: 1180px) {
  .collapsible-header,
  .admin-section-header,
  .promo-section-header,
  .import-section-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .collapsible-header button,
  .admin-section-header button,
  .promo-section-header button,
  .import-section-header button {
    max-width: 22rem;
    white-space: normal;
    text-align: center;
  }

  .panel {
    scroll-margin-right: 4rem;
  }
}

/* On tablet/mobile, do not reserve right padding for the Messages tab. */
@media (max-width: 900px) {
  .wrap {
    padding-right: 0;
  }

  .collapsible-header,
  .admin-section-header,
  .promo-section-header,
  .import-section-header,
  .bookings-panel .top-bar {
    align-items: stretch;
  }

  .collapsible-header button,
  .admin-section-header button,
  .promo-section-header button,
  .import-section-header button {
    max-width: none;
  }
}

/* Final mobile safeguard: tables become cards but desktop remains a table. */
@media (max-width: 760px) {
  .booking-table td[data-label="Time"] {
    white-space: normal;
  }

  .booking-table td[data-label="Customer"] {
    font-weight: 800;
  }

  .booking-table td[data-label="Phone"],
  .booking-table td[data-label="Email"] {
    overflow-wrap: anywhere;
  }
}

/* =========================================================
   Dispatch final visual polish patch - May 2026
   CSS-only. No JavaScript, SQL, or alert behavior changed.
   Purpose: tighten empty alert state, improve bulk action layout,
   strengthen focus/selected states, and reduce visual clutter.
   ========================================================= */

/* Needs Attention: make the cleared/no-alert state compact and intentional. */
.dispatch-alert-panel {
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.dispatch-alert-content {
  margin-top: 0.45rem;
}

.alert-status {
  margin: 0.45rem 0 0.55rem;
  min-height: 1.15rem;
  line-height: 1.35;
}

.alert-status[data-status="success"],
.alert-status[data-type="success"] {
  color: var(--success);
}

.alert-status[data-status="warning"],
.alert-status[data-type="warning"] {
  color: var(--warning);
}

.alert-status[data-status="error"],
.alert-status[data-type="error"] {
  color: var(--danger);
}

/* Empty state should not look like a large active alert card. */
.no-alerts {
  margin: 0.45rem 0 0;
  padding: 0.65rem 0.85rem;
  min-height: 0;
  border-radius: 0.65rem;
  font-size: 0.98rem;
  line-height: 1.35;
}

/* Hide empty summary/action containers fully when JS marks them hidden. */
.alert-summary[hidden],
.alert-actions[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* Bulk controls: clearer grouping, less visual weight. */
.alert-actions {
  grid-template-columns: minmax(12rem, 0.85fr) minmax(22rem, 2fr);
  gap: 0.65rem;
  padding: 0.65rem;
  margin: 0.65rem 0;
  align-items: center;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8fd 100%);
}

.bulk-left,
.bulk-right {
  gap: 0.45rem;
}

.bulk-left {
  justify-content: flex-start;
}

.bulk-right {
  justify-content: flex-end;
}

.alert-btn {
  min-height: 40px;
  padding: 0.62rem 0.8rem;
  line-height: 1.25;
}

.selected-count {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.7rem;
  border: 1px solid #bae6fd;
  background: #eff6ff;
}

.alert-btn:disabled,
button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

/* Alert rows: stronger keyboard and selected states without looking noisy. */
.alert-row {
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
}

.alert-row:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.alert-row.alert-selected {
  border-color: #0b57d0;
  background: #eef6ff;
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.18);
}

.alert-check-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 2rem;
}

.alert-check {
  margin: 0;
}

.alert-title-line strong,
.alert-customer {
  line-height: 1.25;
}

.alert-message,
.alert-meta {
  line-height: 1.32;
}

.alert-open-btn {
  min-height: 40px;
  padding: 0.55rem 0.75rem;
}

/* Summary cards: less bulky on desktop. */
.alert-summary {
  gap: 0.5rem;
  margin: 0.55rem 0;
}

.summary-card {
  padding: 0.6rem 0.7rem;
}

.summary-card strong {
  font-size: 1.2rem;
}

.summary-card span {
  font-size: 0.86rem;
}

/* Clean the top alert header spacing. */
.dispatch-alert-header h2 {
  margin-bottom: 0.2rem;
}

.dispatch-alert-header .help-text {
  margin-bottom: 0;
}

/* Surface Pro and mid-width desktop polish. */
@media (min-width: 761px) and (max-width: 1180px) {
  .alert-actions {
    grid-template-columns: 1fr;
  }

  .bulk-right {
    justify-content: flex-start;
  }

  .alert-actions .alert-btn {
    min-width: 10rem;
  }
}

/* Mobile: compact, readable controls without cramped buttons. */
@media (max-width: 760px) {
  .dispatch-alert-panel {
    padding: 0.75rem;
  }

  .alert-status {
    margin: 0.35rem 0 0.45rem;
  }

  .no-alerts {
    padding: 0.6rem 0.75rem;
    margin-top: 0.35rem;
  }

  .alert-actions {
    padding: 0.55rem;
    margin: 0.55rem 0;
    gap: 0.5rem;
  }

  .bulk-left,
  .bulk-right {
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .alert-btn,
  .selected-count {
    min-height: 42px;
  }

  .alert-row {
    padding: 0.65rem;
    gap: 0.55rem;
  }

  .alert-open-btn {
    min-height: 42px;
  }
}

@media (max-width: 420px) {
  .bulk-left,
  .bulk-right {
    grid-template-columns: 1fr;
  }

  .bulk-left .selected-count,
  .bulk-right .alert-btn,
  #select-all-alerts,
  #clear-alert-selection {
    grid-column: 1 / -1;
    width: 100%;
  }
}


/* =========================================================
   Dispatch premium final polish pass - May 2026
   CSS-only. Preserves working Dispatch behavior.
   ========================================================= */

/* Remove duplicate-feeling space in the alert cleared state and improve card depth. */
.dispatch-alert-panel,
.bookings-panel,
.detail-panel,
.estimate-section,
#admin-controls-section,
#promo-management-section,
#csv-upload-section {
  border-color: #c9d3df;
  box-shadow: 0 2px 8px rgba(15, 39, 66, 0.045);
}

.dispatch-alert-panel {
  margin-top: 0.9rem;
}

.dispatch-alert-header {
  gap: 1.25rem;
}

.dispatch-alert-header h2,
.bookings-panel h2,
#detail-heading {
  letter-spacing: -0.015em;
}

.alert-status {
  font-size: 1rem;
}

.alert-status:empty {
  display: none;
}

/* When there are no alerts, keep the section professional and compact. */
.alerts-list .no-alerts {
  margin-top: 0.35rem;
  padding: 0.72rem 0.95rem;
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
  box-shadow: inset 0 0 0 1px rgba(6, 95, 70, 0.03);
}

/* Improve visual grouping of booking controls. */
.bookings-panel .top-bar {
  border-bottom: 1px solid #d8e0ea;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.bookings-panel .top-bar .actions {
  gap: 0.7rem;
}

.bookings-panel .top-bar .actions button {
  border-radius: 0.55rem;
  min-width: 8.25rem;
  padding-inline: 0.95rem;
}

/* Make destructive/admin cleanup visually important but less oversized. */
#admin-cleanup-paid {
  border-width: 1px;
  font-weight: 800;
}

/* Back link feels more integrated without changing HTML. */
.top-link {
  margin-bottom: 0.25rem;
  padding: 0.15rem 0;
}

/* Slightly more refined controls without weakening accessibility. */
button {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
input:focus,
select:focus,
textarea:focus,
.table-wrap:focus,
summary:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 1px #ffffff;
}

/* Stronger but clean selected alert state. */
.alert-row.alert-selected {
  border-color: #0b57d0;
  border-left-color: #0b57d0;
  background: #edf6ff;
}

/* Keep the vertical messages tab visible but less intrusive. */
.dispatch-messages-tab {
  letter-spacing: 0.01em;
}

@media (min-width: 901px) {
  .dispatch-messages-tab {
    right: 0.25rem;
    padding: 0.68rem 0.42rem;
  }
}

/* Desktop balance for action toolbar. */
@media (min-width: 1181px) {
  .alert-actions {
    grid-template-columns: minmax(13rem, 0.8fr) minmax(30rem, 2fr);
  }

  .bulk-right .alert-btn {
    min-width: 11rem;
  }
}

/* Surface Pro / mid-width refinement. */
@media (min-width: 761px) and (max-width: 1180px) {
  .bookings-panel .top-bar .actions button {
    min-width: 7.5rem;
  }

  .dispatch-alert-header .secondary-button {
    min-width: 8.75rem;
  }
}

/* Mobile polish. */
@media (max-width: 760px) {
  .bookings-panel .top-bar {
    padding-bottom: 0.65rem;
  }

  .bookings-panel .top-bar .actions {
    gap: 0.55rem;
  }

  .dispatch-alert-header h2,
  .bookings-panel h2 {
    font-size: 1.45rem;
  }

  .alerts-list .no-alerts {
    font-size: 0.96rem;
  }
}

/* Reduce motion respectfully. */
@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }

  button:active:not(:disabled) {
    transform: none;
  }
}

/* =========================================================
   Internal Booking Trip Builder Restore - May 2026
   Applies only to Create Internal Booking route entry.
   ========================================================= */
.trip-builder {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.trip-stop {
  display: block;
  border: 1px solid var(--border);
  border-left: 6px solid var(--button-bg);
  border-radius: 0.85rem;
  background: var(--panel);
  padding: 0.85rem;
}

.trip-stop:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.trip-stop-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.trip-stop-title {
  margin: 0;
  font-size: 1.05rem;
  color: var(--header);
}

.trip-stop-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.trip-stop-controls button {
  min-height: 2.6rem;
  padding: 0.55rem 0.7rem;
}

.trip-stop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.trip-builder-actions {
  margin-top: 0.75rem;
  justify-content: flex-start;
}

.trip-builder-actions button {
  min-width: 11rem;
}

#internal-trip-builder-status[data-type="error"] {
  color: var(--danger);
  font-weight: 800;
}

#internal-trip-builder-status[data-type="success"] {
  color: var(--success);
  font-weight: 800;
}

@media (max-width: 760px) {
  .trip-stop {
    padding: 0.75rem;
  }

  .trip-stop-header,
  .trip-stop-controls,
  .trip-builder-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .trip-stop-controls button,
  .trip-builder-actions button {
    width: 100%;
  }

  .trip-stop-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Internal Booking Route Unknown / Follow-Up Mode - May 2026
   Applies only to Create Internal Booking Trip Builder.
   ========================================================= */
.route-unsure-field {
  margin: 0.65rem 0 0.75rem;
  padding: 0.75rem;
  border: 1px solid #f5c26b;
  border-radius: 0.75rem;
  background: #fff8e6;
}

.route-unsure-field .help-text {
  margin: 0.35rem 0 0;
}

.trip-builder-route-unknown {
  opacity: 0.72;
}

.trip-builder-route-unknown .trip-stop {
  border-left-color: #b45309;
  background: #fffaf2;
}

.trip-builder-route-unknown input:disabled,
.trip-builder-route-unknown textarea:disabled,
.trip-builder-route-unknown button:disabled {
  cursor: not-allowed;
}

/* =========================================================
   Dispatch booking history panel - May 2026
   Keeps past trips out of the main active booking list.
   ========================================================= */
.upcoming-bookings-section,
.booking-history-section {
  margin-top: 1rem;
}

.history-toggle-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.history-toggle-header h3 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.history-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 14rem;
}

.history-toggle-button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.history-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  min-height: 1.85rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #eef6ff;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.history-panel {
  margin-top: 0.75rem;
}

.history-table tr {
  background: color-mix(in srgb, var(--panel) 88%, #eef2f7);
}

.history-table .link-button::after {
  content: " History";
  font-weight: 700;
}

.contact-requirement-note {
  margin-top: -0.25rem;
  font-weight: 700;
}

@media (max-width: 760px) {
  .history-toggle-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .history-toggle-button {
    width: 100%;
  }
}

