:root {
  color-scheme: light;
  --page: var(--ground);
  --panel: var(--card);
  --panel-raised: var(--card);
  --border: var(--line);
  --border-light: var(--line-strong);
  --text: var(--ink);
  --muted: var(--ink-2);
  --faint: var(--ink-3);
  --blue: var(--primary);
  --blue-soft: var(--sky);
  --green: var(--dot-good);
  --amber: var(--butter-ink);
}

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

html {
  min-width: 0;
  background: var(--page);
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button,
select {
  font: inherit;
}

button,
a,
select,
[tabindex] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--primary-ink);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
}

.dispatch-app {
  width: min(100%, 100rem);
  margin: 0 auto;
  padding: 16px clamp(14px, 3vw, 32px) 40px;
}

.page-header,
.brand-lockup,
.header-meta,
.toolbar,
.toolbar-fields,
.section-heading,
.trip-meta,
.trip-actions,
.invoice-heading,
.invoice-footer,
.page-footer,
.status-row {
  display: flex;
  align-items: center;
}

.page-header {
  justify-content: space-between;
  gap: 20px;
  min-height: 56px;
  padding-bottom: 8px;
}

.brand-lockup {
  min-width: 0;
  gap: 12px;
}

.back-link {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 14px;
  background: var(--mist);
  color: var(--ink);
  font-size: 1.5rem;
  text-decoration: none;
}

.back-link:hover {
  background: var(--mist-hover);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.0625rem, 1.5vw, 1.25rem);
  font-weight: 800;
  line-height: 1.25;
}

.header-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: right;
}

.header-meta time {
  padding-left: 9px;
  border-left: 1px solid var(--border-light);
  color: var(--faint);
}

.online-indicator {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 158, 107, 0.18);
}

.intro-copy {
  max-width: 760px;
  margin: 18px 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 16px;
  background: var(--mist);
}

.tab-button,
.primary-button,
.secondary-button,
.invoice-select-button,
.trip-select-button,
.assign-button,
.future-print-button {
  min-height: 44px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 800;
  cursor: pointer;
}

.tab-button {
  padding: 8px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 700;
}

.tab-button:hover {
  background: var(--mist-hover);
  color: var(--ink);
}

.tab-button.is-active {
  background: var(--card);
  box-shadow: 0 1px 3px rgba(27, 37, 64, 0.12);
  color: var(--ink);
  font-weight: 800;
}

.status-row {
  gap: 9px;
  min-height: 42px;
  margin-bottom: 16px;
  padding: 9px 12px;
  border: 1px solid var(--sky-line);
  border-radius: 14px;
  background: var(--sky);
  color: var(--sky-ink);
  font-size: 0.9375rem;
  font-weight: 700;
}

.status-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.8125rem;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-view {
  width: min(100%, 520px);
  margin: clamp(24px, 10vh, 96px) auto 0;
  padding: 26px;
}

.login-copy {
  max-width: 420px;
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.login-form,
.resource-form {
  display: grid;
  gap: 14px;
}

.login-form .field-control,
.resource-form .field-control {
  width: 100%;
}

.login-form .primary-button,
.resource-form .primary-button {
  justify-self: start;
  min-width: 126px;
}

.login-message,
.resource-status {
  min-height: 22px;
  margin: 13px 0 0;
  color: var(--butter-ink);
  font-size: 0.875rem;
}

.toolbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 15px 17px;
}

.toolbar-fields {
  justify-content: flex-end;
  gap: 10px;
}

.field-group {
  display: grid;
  min-width: min(100%, 245px);
  gap: 6px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 700;
}

.field-control {
  min-height: 48px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}

.field-control:focus,
.field-control:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), 0 0 0 4px var(--sky);
}

.field-control::placeholder {
  color: var(--faint);
  opacity: 1;
}

.primary-button,
.secondary-button,
.assign-button,
.future-print-button {
  padding: 8px 14px;
}

.toolbar-fields .secondary-button {
  white-space: nowrap;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.secondary-button {
  border-color: var(--sky-line);
  background: var(--sky);
  color: var(--sky-ink);
}

.primary-button:disabled,
.assign-button:disabled,
.future-print-button:disabled {
  border-color: var(--border);
  background: var(--mist);
  color: var(--ink-3);
  opacity: 0.72;
}

.button-note {
  display: block;
  margin-top: 1px;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.8;
}

.board-layout {
  display: grid;
  align-items: start;
  gap: 16px;
}

.queue-panel,
.trips-panel,
.lorry-board-section {
  min-width: 0;
  padding: 17px;
}

.queue-heading {
  flex-wrap: wrap;
}

.queue-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* Wrapping grid: the queue fills the panel and grows downward, so more invoices show at once. */
.invoice-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  align-content: start;
  gap: 10px;
  min-height: 112px;
}

.invoice-rail[data-drop-unassigned] {
  padding: 8px;
  border: 1px dashed var(--border-light);
  border-radius: 10px;
  background: var(--ground);
}

.invoice-rail > .empty-dropzone {
  grid-column: 1 / -1;
}

/* Loading plan visible, stacked: cap the queue so the lanes stay within reach. */
.board-layout[data-has-trips="true"] .invoice-rail {
  max-height: min(55vh, 520px);
  overflow-y: auto;
}

.invoice-card--rail {
  padding: 11px;
  border: 2px solid var(--mint-ink);
}

.invoice-card--rail.is-selected {
  border-color: var(--primary);
}

.invoice-card--rail .invoice-customer {
  font-size: 0.875rem;
}

.invoice-card--rail .invoice-address {
  margin-bottom: 9px;
  font-size: 0.75rem;
}

.invoice-card--rail .invoice-items,
.invoice-card--rail .invoice-date,
.invoice-card--rail .invoice-address {
  font-size: 0.75rem;
}

.invoice-card--rail .drag-affordance {
  font-size: 0.75rem;
}

.invoice-card--rail .invoice-date {
  white-space: nowrap;
}

.lorry-board-section {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lorry-board-heading {
  align-items: flex-start;
}

.lorry-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.lorry-lane {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.lorry-lane-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.lorry-lane-title h3 {
  margin: 0;
  font-size: clamp(0.98rem, 1.4vw, 1.1rem);
}

.lorry-driver-field {
  display: grid;
  gap: 4px;
  min-width: min(100%, 200px);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.lorry-driver-field .field-control {
  min-height: 38px;
  font-size: 0.8125rem;
}

.lorry-trips {
  display: grid;
  gap: 10px;
}

.empty-lane {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--border-light);
  border-radius: 10px;
  background: var(--ground);
}

.empty-lane .section-help {
  margin: 0;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
}

.trips-heading {
  align-items: flex-start;
}

.count-pill,
.queue-key,
.company-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
}

.count-pill {
  min-width: 24px;
  min-height: 22px;
  padding: 3px 7px;
  background: var(--blue-soft);
  color: var(--sky-ink);
}

.queue-key {
  min-width: 34px;
  min-height: 28px;
  padding: 6px 8px;
  background: var(--mist);
  color: var(--ink-2);
}

.section-help {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.875rem;
}

.invoice-list,
.trip-list {
  display: grid;
  gap: 10px;
}

.invoice-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--ground);
}

.invoice-card:hover,
.invoice-card.is-selected {
  border-color: var(--primary);
  background: var(--card);
}

.invoice-card.is-selected {
  box-shadow: 0 0 0 1px var(--primary);
}

.invoice-heading {
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.invoice-heading > span:first-child {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.invoice-number {
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 800;
}

.company-badge {
  min-height: 22px;
  padding: 5px 8px;
}

.company-badge.enterprise {
  background: var(--sky);
  color: var(--sky-ink);
}

.company-badge.sdn-bhd {
  background: var(--lilac);
  color: var(--lilac-ink);
}

.invoice-customer {
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-address,
.invoice-items,
.invoice-date,
.trip-route,
.trip-subtotal {
  color: var(--muted);
  font-size: 0.8125rem;
}

.invoice-address {
  overflow: hidden;
  margin-bottom: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-footer {
  justify-content: space-between;
  gap: 8px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.invoice-select-button,
.trip-select-button {
  border-color: var(--sky-line);
  background: var(--sky);
  color: var(--sky-ink);
  cursor: pointer;
}

.invoice-select-button {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
}

.trip-select-button {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px 12px;
}

.invoice-select-button:hover,
.trip-select-button:hover {
  border-color: var(--primary);
  background: var(--blue-soft);
}

.invoice-items {
  min-width: 0;
  color: var(--ink-2);
}

.invoice-items strong {
  color: var(--ink);
  font-weight: 700;
}

.drag-affordance {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.assign-button {
  width: 100%;
  margin-top: 10px;
}

.trip-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--ground);
}

.trip-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.trip-meta {
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 7px;
  color: var(--ink-2);
  font-size: 0.875rem;
}

.trip-meta strong {
  color: var(--ink);
}

.trip-driver-field {
  display: inline-grid;
  gap: 4px;
  min-width: min(100%, 200px);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.trip-driver-field .field-control {
  min-height: 32px;
  font-size: 0.8125rem;
}

.lorry-driver-note {
  max-width: 210px;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.35;
  text-align: right;
}

.status-badge {
  min-height: 24px;
  padding: 5px 8px;
  background: var(--mint);
  color: var(--mint-ink);
  text-transform: capitalize;
}

.trip-route {
  margin-bottom: 12px;
}

.trip-invoices {
  display: grid;
  gap: 8px;
  min-height: 88px;
  padding: 9px;
  border: 1px dashed var(--border-light);
  border-radius: 12px;
  background: var(--card);
}

.trip-invoices .invoice-card {
  padding: 10px;
  background: var(--ground);
}

.trip-invoices .invoice-card .assign-button {
  display: none;
}

.empty-dropzone {
  display: grid;
  min-height: 70px;
  place-items: center;
  color: var(--faint);
  font-size: 0.875rem;
  text-align: center;
}

.trip-actions {
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.trip-subtotal {
  min-width: 0;
}

.future-print-button {
  flex: 0 1 auto;
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--sky-line);
  border-radius: 12px;
  background: var(--sky);
  color: var(--sky-ink);
  text-decoration: none;
  white-space: normal;
}

.future-print-button:hover {
  border-color: var(--primary);
  background: #cfe0fd;
  color: var(--sky-ink);
}

.trip-action-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.selection-panel {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 16px;
  padding: 15px 17px;
}

.selection-panel p:last-child {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  text-align: right;
}

.resources-view {
  padding: 17px;
}

.trips-view,
.reports-view {
  min-width: 0;
  padding: 17px;
}

.trip-detail-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--ground);
}

.trip-detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.trip-detail-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 15px 0 0;
}

.trip-detail-meta dt {
  color: var(--faint);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.trip-detail-meta dd {
  overflow: hidden;
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-detail-card .trip-route {
  margin-top: 13px;
}

.trip-detail-card .future-print-button {
  width: fit-content;
  margin-top: 4px;
  padding: 7px 12px;
}

.report-boundary {
  color: var(--faint);
  font-size: 0.8125rem;
  font-weight: 700;
}

.report-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  margin-top: 15px;
}

.report-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.report-actions button {
  flex: 1 1 0;
}

.report-state,
.view-state {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.report-table-wrap {
  overflow-x: auto;
  margin-top: 4px;
}

.report-table {
  min-width: 560px;
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8125rem;
}

.report-table th,
.report-table td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.report-table td {
  color: var(--ink);
}

.report-table td strong {
  color: var(--ink);
}

.report-table .report-trip-row th {
  padding: 14px 9px 8px;
  background: var(--ground);
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 0.875rem;
  letter-spacing: 0;
  text-transform: none;
}

.report-trip-title {
  font-weight: 800;
}

.report-trip-meta {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

.report-trip-status,
.report-status {
  text-transform: capitalize;
}

.report-status {
  font-weight: 800;
}

.report-status-delivered {
  color: #1d7a46;
}

.report-status-failed,
.report-status-returned {
  color: #b42318;
}

.report-secondary {
  display: block;
  margin-top: 2px;
  color: var(--faint);
  font-size: 0.75rem;
}

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

.resource-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
}

.resource-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.resource-list-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--ground);
}

.resource-list-panel h3,
.resource-form h3 {
  margin: 0;
  font-size: 0.9375rem;
}

.resource-list {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.resource-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
}

.resource-card.is-inactive {
  opacity: 0.7;
}

.resource-card > div:first-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.resource-card strong,
.resource-identity,
.resource-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-card strong {
  font-size: 0.875rem;
}

.resource-identity,
.resource-detail,
.empty-resource-list {
  color: var(--muted);
  font-size: 0.8125rem;
}

.resource-card-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.resource-toggle-button {
  min-height: 38px;
  padding: 6px 9px;
  font-size: 0.8125rem;
}

.resource-form {
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.resource-fields {
  display: grid;
  gap: 14px;
}

.placeholder-view {
  min-height: 220px;
  padding: 28px;
}

.placeholder-view p:last-child {
  max-width: 600px;
  margin: 12px 0 0;
  color: var(--muted);
}

.page-footer {
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 0.8125rem;
}

.future-action {
  color: var(--ink-3);
}

@media (max-width: 860px) {
  .queue-panel,
  .lorry-board-section {
    padding: 15px;
  }

  .lorry-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .dispatch-app {
    padding: 14px 12px 24px;
  }

  .page-header,
  .toolbar,
  .selection-panel,
  .page-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-header,
  .toolbar {
    gap: 12px;
  }

  .header-meta {
    justify-content: flex-start;
    text-align: left;
  }

  .toolbar-fields {
    width: 100%;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .field-group {
    flex: 1 1 210px;
  }

  .secondary-button {
    flex: 1 1 130px;
  }

  .selection-panel p:last-child {
    max-width: none;
    text-align: left;
  }

  .resource-grid {
    grid-template-columns: 1fr;
  }

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

  .report-actions {
    grid-column: 1 / -1;
  }

  .resource-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .resource-card-actions {
    width: 100%;
    justify-content: space-between;
  }

  .page-footer {
    gap: 5px;
  }
}

@media (max-width: 390px) {
  .dispatch-app {
    padding-right: 10px;
    padding-left: 10px;
  }

  .tab-list {
    gap: 3px;
    padding: 3px;
  }

  .tab-button {
    padding-right: 4px;
    padding-left: 4px;
    font-size: 0.8125rem;
  }

  .queue-panel,
  .trips-panel,
  .lorry-board-section {
    padding: 12px;
  }

  .trip-card-header,
  .trip-actions,
  .trip-detail-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .future-print-button,
  .trip-action-buttons {
    width: 100%;
  }

  .trip-action-buttons {
    align-items: stretch;
    flex-direction: column;
  }

  .report-form,
  .trip-detail-meta {
    grid-template-columns: 1fr;
  }

  .report-actions {
    grid-column: auto;
  }
}

.offline-status {
  margin-left: auto;
  color: var(--rose-ink);
  font-weight: 800;
}

.source-status,
.board-state {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.source-status:not(:empty) {
  color: var(--amber);
}

.board-state:not(:empty) {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--blue-soft);
}

.invoice-card[draggable="true"] {
  cursor: grab;
}

.invoice-card[draggable="true"]:active {
  cursor: grabbing;
}

.trip-invoices {
  min-height: 92px;
}

.assign-selected-button,
.assign-button,
.remove-trip-button,
.remove-assignment-button {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--sky-line);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--sky-ink);
  font-size: 0.8125rem;
  font-weight: 800;
}

.remove-trip-button,
.remove-assignment-button {
  border-color: var(--rose-line);
  background: var(--rose);
  color: var(--rose-ink);
}

.assign-selected-button:disabled,
.assign-button:disabled,
.remove-trip-button:disabled,
.remove-assignment-button:disabled {
  opacity: 0.45;
}

.trip-subtotal {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}

.dialog-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(27, 37, 64, 0.45);
}

.dialog-backdrop[hidden] {
  display: none;
}

.trip-dialog {
  width: min(100%, 520px);
  max-height: min(100%, 680px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(27, 37, 64, 0.25);
}

.trip-form {
  display: grid;
  gap: 14px;
}

.trip-form textarea {
  resize: vertical;
}

.dialog-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Wide screens: the app bar carries navigation, the loading plan (once a trip
   exists) sits beside the queue, and the tab strip stays a compact control. */
@media (min-width: 960px) {
  .back-link {
    display: none;
  }

  .page-header {
    padding-top: 12px;
  }

  .tab-list {
    width: min(100%, 520px);
  }

  /* Loading plan visible: plan beside the queue; the queue sticks while the lanes scroll. */
  .board-layout[data-has-trips="true"] {
    grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 440px);
  }

  .board-layout[data-has-trips="true"] .queue-panel {
    position: sticky;
    top: 12px;
    display: flex;
    max-height: calc(100vh - 24px);
    flex-direction: column;
  }

  .board-layout[data-has-trips="true"] .invoice-rail {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
  }

  .resource-form {
    max-width: 820px;
  }

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

.remove-trip-button,
.add-trip-button {
  min-height: 44px;
}

.assign-trip-picker {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.8rem;
}

.assign-trip-select {
  width: 100%;
  min-height: 40px;
  font: inherit;
}

.invoice-card--compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
}

.invoice-card--compact .invoice-customer {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.invoice-card--compact .remove-assignment-button {
  flex: none;
  min-height: 32px;
  margin: 0;
}

.invoice-card--rail .invoice-customer {
  white-space: normal;
  overflow-wrap: anywhere;
}

.board-date-block { display: grid; gap: 6px; min-width: 0; }
.board-date-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.board-date-step { min-width: 44px; }
.board-date-input { width: auto; min-width: 150px; }
.board-date-banner {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--butter-line);
  border-radius: 8px;
  background: var(--butter);
  color: var(--butter-ink);
  font-weight: 600;
}
.board-date-banner[hidden] { display: none; }

.invoice-date-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.invoice-date-tag-older { background: var(--butter); color: var(--butter-ink); border: 1px solid var(--butter-line); }
.invoice-date-tag-newer { background: var(--blue-soft); color: var(--blue); }

.older-invoice-dialog { width: min(100%, 640px); }
.older-invoice-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.older-invoice-list { display: grid; gap: 6px; max-height: 45vh; overflow-y: auto; margin: 10px 0; }
.older-invoice-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}
.older-invoice-row input { width: 20px; height: 20px; }
.older-invoice-main { min-width: 0; overflow-wrap: anywhere; }
.older-invoice-date { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.older-invoice-error { grid-column: 2 / -1; color: var(--amber); font-weight: 600; font-size: 0.85rem; }
.older-invoice-actions { display: flex; justify-content: flex-end; gap: 8px; }
