:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #fbfcfd;
  --text: #18202a;
  --muted: #697382;
  --border: #d9dee7;
  --border-strong: #c2cad6;
  --accent: #1468d8;
  --accent-dark: #0f55b3;
  --issue: #b42318;
  --ok: #067647;
  --warning: #b54708;
  --shadow: 0 12px 30px rgba(22, 34, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  min-height: 100vh;
  max-width: none;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
}

.topbar p,
.table-header p,
.empty-state p,
.detail-empty p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 7px;
  min-height: 38px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.button.primary {
  position: relative;
  overflow: hidden;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.manual-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 32, 42, 0.42);
}

.manual-card {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: auto;
}

.manual-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.manual-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.manual-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.manual-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 16px 16px;
}

.manual-panel.hidden {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 32, 42, 0.46);
}

.modal-backdrop.hidden {
  display: none;
}

.import-summary-float {
  position: fixed;
  top: 84px;
  right: 24px;
  z-index: 40;
  width: min(800px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
}

.import-summary-float.hidden {
  display: none;
}

.import-summary-float .modal-card {
  width: 100%;
  max-height: min(720px, calc(100vh - 112px));
}

.modal-card {
  width: min(860px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.import-summary-body {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 16px;
  font-size: 6px;
}

.import-summary-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 0.06fr));
  gap: 10px;
}

.import-summary-counts span,
.import-summary-record span,
.import-summary-record dt {
  color: #b54709;
  font-size: 10px;
  font-weight: 800;
}

.import-summary-counts strong {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.import-summary-empty {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-weight: 800;
}

.import-summary-section {
  display: grid;
  gap: 10px;
}

.import-summary-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}

.import-summary-record {
  background: transparent;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

.import-summary-record strong {
  display: inline;
  margin: 0 6px 0 0;
  overflow-wrap: anywhere;
}

.import-summary-row {
  display: block;
  font-size: 10px;
}

.import-summary-row span {
  display: inline-block;
  margin-right: 1px;
}

.import-summary-more {
  margin: 0;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.button.subtle {
  width: 100%;
  background: var(--panel-soft);
}

.stats {
  display: grid;
  gap: 12px;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.stats article {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(22, 34, 51, 0.04);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.filters,
.table-panel,
.detail-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  gap: 14px;
  padding: 14px;
  position: sticky;
  top: 69px;
  align-content: start;
}

.top-toolbar {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.top-toolbar .filter-search {
  flex: 1 1 320px;
  min-width: 320px;
}

.top-toolbar .filter-grid,
.top-toolbar .date-filter-grid {
  display: contents;
}

.top-toolbar .filter-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  flex: 1 1 320px;
  gap: 10px;
  align-items: end;
}

.top-toolbar .filter-group-title {
  grid-column: 1 / -1;
}

.top-toolbar .button {
  flex: 0 0 auto;
  width: auto;
  min-width: 112px;
  white-space: nowrap;
}

.top-toolbar > label:not(.filter-search),
.top-toolbar .filter-grid > label,
.top-toolbar .date-filter-grid > label {
  flex: 0 1 170px;
  min-width: 140px;
}

.more-filters {
  position: relative;
  flex: 0 0 auto;
}

.more-filters summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.more-filters summary::-webkit-details-marker {
  display: none;
}

.more-filters[open] summary {
  border-color: var(--accent);
  color: var(--accent);
}

.more-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  width: min(520px, calc(100vw - 48px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.filter-search {
  min-width: 0;
}

.filter-grid {
  display: grid;
  gap: 10px;
}

.date-filter-grid {
  gap: 10px;
}

.filter-group {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.filter-group-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

input[type="search"] {
  appearance: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 104, 216, 0.12);
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.view-controls {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
  flex: 0 0 auto;
}

.time-controls {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
  flex: 0 0 auto;
}

.view-button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.time-button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.view-button:last-child,
.time-button:last-child {
  border-right: 0;
}

.view-button.active,
.time-button.active {
  background: var(--accent);
  color: #fff;
}

.import-status {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  max-width: 260px;
}

.change-log-list ul {
  margin: 0;
  padding-left: 18px;
}

.change-log-list li {
  margin: 4px 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 225px);
  scrollbar-gutter: stable;
}

.time-primary,
.time-secondary {
  display: block;
}

.time-secondary {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.calendar-view {
  padding: 14px 16px 16px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.calendar-nav,
.calendar-subviews {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.calendar-nav {
  gap: 6px;
  justify-self: start;
  flex-wrap: wrap;
}

.calendar-nav .button.subtle {
  width: auto;
  min-height: 34px;
}

.calendar-export-button {
  white-space: nowrap;
}

.calendar-toolbar strong {
  text-align: center;
  font-size: 15px;
}

.calendar-subviews {
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  overflow: hidden;
  justify-self: end;
}

.calendar-subview-button {
  min-width: 64px;
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.calendar-subview-button:last-child {
  border-right: 0;
}

.calendar-subview-button.active {
  background: var(--accent);
  color: #fff;
}

.calendar-grid.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  overflow: auto;
}

.calendar-weekday {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  padding: 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-day-cell {
  min-height: 112px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fff;
  padding: 7px;
}

.calendar-day-cell.muted {
  background: #f8fafc;
  color: var(--muted);
}

.calendar-day-cell.today {
  box-shadow: inset 0 0 0 2px rgba(20, 104, 216, 0.35);
}

.calendar-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.calendar-items {
  display: grid;
  gap: 5px;
}

.calendar-appointment {
  --load-type-text: #334155;
  width: 100%;
  min-height: 32px;
  border: 1px solid #c7d7ef;
  border-left: 5px solid #7ddf9a;
  border-radius: 6px;
  background: #eef5ff;
  color: #163b69;
  padding: 4px 6px;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}

.calendar-appointment:hover,
.calendar-appointment.selected {
  border-color: var(--accent);
  background: #dbeafe;
}

.calendar-appointment.appt-status-normal {
  border-left-color: #7ddf9a;
}

.calendar-appointment.appt-status-pending {
  border-left-color: #ffbd73;
}

.calendar-appointment.appt-status-done {
  border-left-color: #9aa4b2;
}

.calendar-appointment.appt-status-issue {
  border-left-color: #f97066;
}

.calendar-appointment.trip-bound {
  border-color: rgba(15, 23, 42, 0.2);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.calendar-appointment.trip-bound.status-planned {
  background: #bfdbfe;
  color: #0b3b85;
}

.calendar-appointment.trip-bound.status-scheduled,
.calendar-appointment.trip-bound.status-pending,
.calendar-appointment.trip-bound.status-loading {
  background: #fed7aa;
  color: #5a2a07;
}

.calendar-appointment.trip-bound.status-in-transit {
  background: #bbf7d0;
  color: #06452c;
}

.calendar-appointment.trip-bound.status-delivered,
.calendar-appointment.trip-bound.status-locked {
  background: #cbd5e1;
  color: #344054;
}

.calendar-appointment.trip-bound.status-cancelled {
  background: #e4e4e7;
  color: var(--muted);
}

.calendar-appointment.trip-bound.status-at-risk {
  background: #fecaca;
  color: var(--issue);
}

.calendar-appointment.trip-bound:hover,
.calendar-appointment.trip-bound.selected {
  border-color: var(--accent);
}

.calendar-appointment.trip-bound.appt-status-normal,
.calendar-appointment.selected.appt-status-normal {
  border-left-color: #7ddf9a;
}

.calendar-appointment.trip-bound.appt-status-pending,
.calendar-appointment.selected.appt-status-pending {
  border-left-color: #ffbd73;
}

.calendar-appointment.trip-bound.appt-status-done,
.calendar-appointment.selected.appt-status-done {
  border-left-color: #9aa4b2;
}

.calendar-appointment.trip-bound.appt-status-issue,
.calendar-appointment.selected.appt-status-issue {
  border-left-color: #f97066;
}

.calendar-appointment strong,
.calendar-appointment small,
.calendar-appointment small span,
.calendar-appointment small em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-appointment strong {
  font-size: 12px;
  line-height: 1.1;
}

.calendar-appointment small {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.1;
  color: #385b86;
}

.calendar-appointment small em {
  display: inline;
  color: var(--load-type-text);
  font-style: normal;
  font-weight: 750;
}

.calendar-appointment small span {
  display: inline;
}

.calendar-time-scroll {
  max-height: calc(100vh - 285px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.calendar-time-grid {
  display: grid;
  grid-template-columns: 72px repeat(var(--calendar-days), minmax(152px, 1fr));
  min-width: calc(72px + var(--calendar-days) * 152px);
}

.calendar-time-grid.day-mode {
  grid-template-columns: 72px minmax(420px, 1fr);
  min-width: 492px;
}

.calendar-time-corner,
.calendar-time-day-head,
.calendar-all-day-label,
.calendar-all-day-cell,
.calendar-hour-label,
.calendar-hour-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.calendar-time-corner,
.calendar-time-day-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel-soft);
}

.calendar-time-corner {
  left: 0;
  z-index: 4;
}

.calendar-time-day-head {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 58px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.calendar-time-day-head strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text);
  font-size: 15px;
  line-height: 1;
}

.calendar-time-day-head.today strong {
  background: var(--accent);
  color: #fff;
}

.calendar-all-day-label,
.calendar-hour-label {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

.calendar-all-day-label {
  min-height: 34px;
  padding: 9px 8px;
}

.calendar-all-day-cell {
  min-height: 34px;
  padding: 4px;
  background: #fff;
}

.calendar-hour-label {
  min-height: 52px;
  padding: 7px 8px 0 0;
}

.calendar-hour-cell {
  min-height: 52px;
  padding: 3px 4px;
  background:
    linear-gradient(to bottom, transparent 50%, rgba(217, 222, 231, 0.45) 50%, transparent calc(50% + 1px));
}

.calendar-time-appointment {
  display: grid;
  gap: 1px;
  width: 100%;
  min-height: 34px;
  border: 1px solid #c7d7ef;
  border-left: 5px solid #7ddf9a;
  border-radius: 6px;
  background: #eef5ff;
  color: #163b69;
  padding: 4px 6px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.calendar-time-appointment + .calendar-time-appointment {
  margin-top: 3px;
}

.calendar-time-appointment:hover,
.calendar-time-appointment.selected {
  border-color: var(--accent);
  background: #dbeafe;
}

.calendar-time-appointment.appt-status-normal {
  border-left-color: #7ddf9a;
}

.calendar-time-appointment.appt-status-pending {
  border-left-color: #ffbd73;
}

.calendar-time-appointment.appt-status-done {
  border-left-color: #9aa4b2;
}

.calendar-time-appointment.appt-status-issue {
  border-left-color: #f97066;
}

.calendar-time-appointment span,
.calendar-time-appointment strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-time-appointment span {
  color: #385b86;
  font-size: 10px;
  font-weight: 800;
}

.calendar-time-appointment strong {
  font-size: 12px;
  line-height: 1.1;
}

.calendar-time-appointment.trip-bound.status-planned {
  background: #bfdbfe;
  color: #0b3b85;
}

.calendar-time-appointment.trip-bound.status-scheduled,
.calendar-time-appointment.trip-bound.status-pending,
.calendar-time-appointment.trip-bound.status-loading {
  background: #fed7aa;
  color: #5a2a07;
}

.calendar-time-appointment.trip-bound.status-in-transit {
  background: #bbf7d0;
  color: #06452c;
}

.calendar-time-appointment.trip-bound.status-delivered,
.calendar-time-appointment.trip-bound.status-locked {
  background: #cbd5e1;
  color: #344054;
}

.calendar-time-appointment.trip-bound.status-cancelled {
  background: #e4e4e7;
  color: var(--muted);
}

.calendar-time-appointment.trip-bound.status-at-risk {
  background: #fecaca;
  color: var(--issue);
}

.calendar-time-appointment.trip-bound:hover,
.calendar-time-appointment.trip-bound.selected {
  border-color: var(--accent);
}

.calendar-time-appointment.trip-bound.appt-status-normal,
.calendar-time-appointment.selected.appt-status-normal {
  border-left-color: #7ddf9a;
}

.calendar-time-appointment.trip-bound.appt-status-pending,
.calendar-time-appointment.selected.appt-status-pending {
  border-left-color: #ffbd73;
}

.calendar-time-appointment.trip-bound.appt-status-done,
.calendar-time-appointment.selected.appt-status-done {
  border-left-color: #9aa4b2;
}

.calendar-time-appointment.trip-bound.appt-status-issue,
.calendar-time-appointment.selected.appt-status-issue {
  border-left-color: #f97066;
}

.timeline-view {
  max-height: calc(100vh - 225px);
  overflow: auto;
  padding: 14px 16px 16px;
}

.appointment-map-view {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.map-toolbar > div {
  display: grid;
  gap: 3px;
}

.map-toolbar strong {
  font-size: 15px;
}

.map-toolbar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.map-toolbar .button.subtle {
  width: auto;
  min-width: 152px;
}

.map-provider-message {
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 750;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: stretch;
}

.appointment-map-canvas {
  min-height: 560px;
  height: min(68vh, 760px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
}

.map-side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.map-summary,
.map-missing {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.map-summary h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map-summary h3 span {
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 3px 8px;
  font-size: 12px;
}

.map-summary p,
.map-missing p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.map-summary-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.map-summary-meta div {
  display: grid;
  gap: 3px;
}

.map-summary-meta dt,
.map-summary-meta dd {
  margin: 0;
  font-size: 12px;
}

.map-summary-meta dt {
  color: var(--muted);
  font-weight: 800;
}

.map-summary-meta dd {
  color: var(--text);
  overflow-wrap: anywhere;
}

.map-fc-records,
.map-missing-list {
  display: grid;
  gap: 6px;
}

.map-fc-records button {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.map-fc-records button:hover,
.map-fc-records button.selected {
  border-color: var(--accent);
  background: #eef5ff;
}

.map-fc-records strong,
.map-fc-records span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-fc-records strong {
  font-size: 12px;
}

.map-fc-records span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.map-missing-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  font-size: 12px;
}

.map-missing-list span {
  color: var(--muted);
  font-weight: 750;
}

.map-marker {
  --marker-scale: 1;
  display: grid;
  grid-template-columns: auto auto;
  gap: 5px;
  align-items: center;
  min-width: 58px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #1468d8;
  color: #fff;
  padding: 5px 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.34);
  cursor: pointer;
  transform: translateY(-4px) scale(var(--marker-scale));
  transform-origin: center bottom;
}

.map-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 12px;
  height: 12px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

.map-marker strong,
.map-marker span {
  position: relative;
  z-index: 1;
  line-height: 1;
}

.map-marker strong {
  font-size: 11px;
  font-weight: 900;
}

.map-marker span {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 900;
}

.map-marker.status-pending {
  background: #b54708;
}

.map-marker.status-issue {
  background: #b42318;
}

.map-marker.status-done {
  background: #667085;
}

.map-marker.selected,
.map-marker:hover {
  outline: 3px solid rgba(20, 104, 216, 0.28);
}

.timeline-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 248px);
  gap: 10px;
  align-items: start;
  width: max-content;
  min-width: 100%;
  padding-bottom: 10px;
}

.timeline-day {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}

.timeline-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.timeline-day-head strong {
  font-size: 13px;
}

.timeline-day-head span,
.timeline-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.timeline-axis {
  position: relative;
  height: 12px;
}

.timeline-axis::before {
  content: "";
  position: absolute;
  top: 5px;
  right: -14px;
  left: 0;
  height: 2px;
  background: #d7e1ef;
}

.timeline-axis::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 0;
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
}

.timeline-items {
  display: grid;
  gap: 5px;
  align-content: start;
}

.timeline-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 25px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--border);
  border-left: 5px solid #7ddf9a;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 9px;
  text-align: left;
  cursor: pointer;
}

.timeline-item.appt-status-normal {
  border-left-color: #7ddf9a;
}

.timeline-item.appt-status-pending {
  border-left-color: #ffbd73;
}

.timeline-item.appt-status-done {
  border-left-color: #9aa4b2;
}

.timeline-item.appt-status-issue {
  border-left-color: #f97066;
}

.timeline-item.trip-bound.status-planned {
  background: rgba(20, 104, 216, 0.12);
}

.timeline-item.trip-bound.status-scheduled,
.timeline-item.trip-bound.status-pending,
.timeline-item.trip-bound.status-loading {
  background: rgba(181, 71, 8, 0.14);
}

.timeline-item.trip-bound.status-in-transit {
  background: rgba(6, 118, 71, 0.12);
}

.timeline-item.trip-bound.status-delivered,
.timeline-item.trip-bound.status-locked {
  background: #eef2f7;
}

.timeline-item.trip-bound.status-cancelled {
  background: #f4f4f5;
}

.timeline-item.trip-bound.status-at-risk {
  background: #fff0ee;
}

.timeline-item:hover,
.timeline-item.selected {
  border-color: var(--accent);
  background: #eef5ff;
}

.timeline-item.appt-status-normal:hover,
.timeline-item.selected.appt-status-normal {
  border-left-color: #7ddf9a;
}

.timeline-item.appt-status-pending:hover,
.timeline-item.selected.appt-status-pending {
  border-left-color: #ffbd73;
}

.timeline-item.appt-status-done:hover,
.timeline-item.selected.appt-status-done {
  border-left-color: #9aa4b2;
}

.timeline-item.appt-status-issue:hover,
.timeline-item.selected.appt-status-issue {
  border-left-color: #f97066;
}

.timeline-item.trip-bound:hover,
.timeline-item.trip-bound.selected {
  border-color: var(--accent);
}

.timeline-item.trip-bound.appt-status-normal,
.timeline-item.selected.appt-status-normal {
  border-left-color: #7ddf9a;
}

.timeline-item.trip-bound.appt-status-pending,
.timeline-item.selected.appt-status-pending {
  border-left-color: #ffbd73;
}

.timeline-item.trip-bound.appt-status-done,
.timeline-item.selected.appt-status-done {
  border-left-color: #9aa4b2;
}

.timeline-item.trip-bound.appt-status-issue,
.timeline-item.selected.appt-status-issue {
  border-left-color: #f97066;
}

.timeline-item time,
.timeline-item strong,
.timeline-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timeline-item time {
  color: #667085;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.timeline-item strong {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

.timeline-item-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.timeline-item-main,
.timeline-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
  line-height: 1.22;
}

.timeline-item-meta .status-pill {
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.22;
}

.timeline-isa {
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
  overflow-wrap: anywhere;
  white-space: normal;
}

.timeline-load {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.timeline-load.load-type-floorload {
  color: #9a3412;
}

.timeline-load.load-type-palletized {
  color: #067647;
}

.timeline-load.load-type-unassigned {
  color: var(--muted);
}

.timeline-trip {
  display: inline-flex;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.timeline-trip.status-planned {
  background: rgba(20, 104, 216, 0.12);
  color: #0b3b85;
}

.timeline-trip.status-scheduled,
.timeline-trip.status-pending,
.timeline-trip.status-loading {
  background: rgba(181, 71, 8, 0.14);
  color: #5a2a07;
}

.timeline-trip.status-in-transit {
  background: rgba(6, 118, 71, 0.12);
  color: #06452c;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef5ff;
}



.status-pill.issue {
  background: #fff0ee;
  color: var(--issue);
}

.status-pill.done {
  background: #ecfdf3;
  color: var(--ok);
}

.status-pill.pending {
  background: #fff7ed;
  color: var(--warning);
}

.timeline-item .timeline-item-meta .status-pill {
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 10px;
  font-weight: 500;
}

.isa-text {
  display: block;
}

.trip-status-hint {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.15;
}

.trip-status-hint.status-planned,
.plan-status-dot.status-planned {
  color: var(--accent);
}

.trip-status-hint.status-scheduled,
.trip-status-hint.status-pending,
.trip-status-hint.status-loading,
.plan-status-dot.status-scheduled,
.plan-status-dot.status-pending,
.plan-status-dot.status-loading {
  color: var(--warning);
}

.trip-status-hint.status-in-transit,
.plan-status-dot.status-in-transit {
  color: var(--ok);
}

.trip-status-hint.status-delivered,
.trip-status-hint.status-locked,
.plan-status-dot.status-delivered,
.plan-status-dot.status-locked {
  color: #344054;
}

.trip-status-hint.status-cancelled,
.plan-status-dot.status-cancelled {
  color: var(--muted);
}

.trip-status-hint.status-at-risk,
.plan-status-dot.status-at-risk {
  color: var(--issue);
}

.load-type-select,
.load-type-field {
  --load-type-bg: #f1f5f9;
  --load-type-text: #334155;
  --load-type-border: #cbd5e1;
  width: 142px;
  min-height: 30px;
  border-color: var(--load-type-border);
  background-color: var(--load-type-bg);
  color: var(--load-type-text);
  font-size: 12px;
  font-weight: 750;
}

.load-type-field {
  width: 100%;
  min-height: 36px;
}

.load-type-select:focus,
.load-type-field:focus {
  border-color: var(--load-type-border);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--load-type-border) 26%, transparent);
}

.load-type-floorload {
  --load-type-bg: #fff7ed;
  --load-type-text: #9a3412;
  --load-type-border: #fdba74;
}

.load-type-palletized {
  --load-type-bg: #ecfdf3;
  --load-type-text: #067647;
  --load-type-border: #86efac;
}

.load-type-unassigned {
  --load-type-bg: #f1f5f9;
  --load-type-text: #475569;
  --load-type-border: #cbd5e1;
}

.empty-state {
  display: none;
  padding: 48px 20px;
  text-align: center;
}

.empty-state:not(.hidden) {
  display: block;
}

.detail-panel {
  min-height: 420px;
  padding: 16px;
  position: sticky;
  top: 69px;
}

.detail-empty {
  padding-top: 4px;
}

.detail-form {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none;
}

.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.detail-title h2 {
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.fc-badge {
  display: inline-flex;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.icon-button {
  min-height: 32px;
  padding: 6px 9px;
  color: var(--issue);
}

.meta {
  display: grid;
  gap: 10px;
  margin: 4px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.change-log {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.matched-plan {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.matched-plan.hidden {
  display: none;
}

.matched-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plan-status-dot {
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.matched-plan-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.matched-plan-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.matched-plan-meta div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
}

.matched-plan-meta dt,
.matched-plan-meta dd {
  margin: 0;
  font-size: 12px;
}

.matched-plan-meta dt {
  color: var(--muted);
  font-weight: 750;
}

.matched-plan-meta dd {
  color: var(--text);
  overflow-wrap: anywhere;
}

.change-log-list {
  max-height: 180px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
}

.meta div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
}

.meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.meta dd {
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    grid-column: 1 / -1;
    position: static;
  }

  .top-toolbar {
    align-items: stretch;
  }

  .top-toolbar .filter-group {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

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

  .actions,
  .button {
    width: 100%;
  }

  .actions {
    justify-content: stretch;
  }

  .table-header {
    flex-direction: column;
  }

  .view-controls {
    width: 100%;
  }

  .time-controls {
    width: 100%;
  }

  .view-button,
  .time-button {
    flex: 1;
  }

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

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

  .manual-fields {
    grid-template-columns: 1fr;
  }

  .filters,
  .detail-panel {
    position: static;
  }

  .filters {
    gap: 12px;
  }

  .top-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-toolbar .filter-search {
    min-width: 0;
  }

  .top-toolbar .filter-grid,
  .top-toolbar .date-filter-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-toolbar .filter-group {
    grid-template-columns: 1fr;
  }

  .top-toolbar .button {
    width: 100%;
  }

  .more-filters,
  .more-filters summary {
    width: 100%;
  }

  .more-filter-panel {
    position: static;
    width: 100%;
    grid-template-columns: 1fr;
    margin-top: 8px;
    box-shadow: none;
  }

  .table-wrap {
    max-height: none;
  }

  .calendar-toolbar {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .calendar-toolbar strong {
    text-align: left;
  }

  .calendar-subviews {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-self: stretch;
  }

  .calendar-subview-button {
    min-width: 0;
  }

  .timeline-view {
    max-height: 70vh;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .map-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .map-toolbar .button.subtle {
    width: 100%;
  }

  .appointment-map-canvas {
    min-height: 430px;
    height: 62vh;
  }

  .timeline-item {
    grid-template-columns: 58px minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 26px;
  }

  .app-shell {
    padding-inline: 12px;
  }

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

  .filters,
  .table-panel,
  .detail-panel,
  .manual-card {
    border-radius: 7px;
  }

  th,
  td {
    padding: 9px 10px;
  }
}
