:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #fbfcfd;
  --text: #18202a;
  --muted: #697382;
  --border: #d9dee7;
  --border-strong: #c2cad6;
  --accent: #1468d8;
  --accent-dark: #0f55b3;
  --ok: #067647;
  --warning: #b54708;
  --issue: #b42318;
  --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;
}

.trip-shell {
  min-height: 100vh;
  padding: 24px;
  max-width: none;
  margin-inline: auto;
}

.trip-header,
.panel-head,
.stop-head,
.form-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

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

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
}

.trip-header p,
.form-title p,
.section-head p,
.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.cloud-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.cloud-pill.connected {
  border-color: rgba(6, 118, 71, 0.25);
  background: rgba(6, 118, 71, 0.08);
  color: var(--ok);
}

.cloud-pill.error {
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(180, 35, 24, 0.08);
  color: var(--issue);
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(340px, 3fr) minmax(0, 7fr);
  gap: 14px;
  align-items: start;
  margin-top: 18px;
}

.plan-form,
.calendar-panel,
.stop-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.plan-form {
  display: grid;
  gap: 12px;
  padding: 12px;
  position: sticky;
  top: 69px;
  max-height: calc(100vh - 92px);
  overflow: auto;
}

.form-grid,
.stop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stop-search-field,
.appointment-context {
  grid-column: 1 / -1;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
  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);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

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

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

.button.compact {
  min-height: 28px;
  padding: 4px 9px;
  color: var(--issue);
  font-size: 12px;
}

.button.compact.neutral {
  color: var(--text);
}

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

.stops-container {
  display: grid;
  gap: 10px;
}

.stop-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  box-shadow: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.appointment-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 9px;
}

.appointment-context.hidden {
  display: none;
}

.appointment-context span,
.appointment-context strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.appointment-context span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.appointment-context strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
}

.stop-card.drop-target {
  border-color: var(--accent);
  background: #f0f6ff;
  box-shadow: 0 0 0 3px rgba(20, 104, 216, 0.12);
}

.buffer-pill {
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.buffer-pill.ok {
  background: rgba(6, 118, 71, 0.1);
  color: var(--ok);
}

.buffer-pill.warning {
  background: rgba(181, 71, 8, 0.12);
  color: var(--warning);
}

.buffer-pill.issue {
  background: rgba(180, 35, 24, 0.1);
  color: var(--issue);
}

.calendar-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(120vh - 32px);
  min-height: 520px;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.calendar-nav {
  display: grid;
  grid-template-columns: 32px minmax(92px, 1fr) 32px;
  gap: 7px;
  align-items: center;
  min-width: 176px;
}

.calendar-nav strong {
  text-align: center;
  font-size: 13px;
}

.appointment-timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 248px);
  gap: 10px;
  align-items: start;
  min-width: 0;
  overflow: auto;
  padding: 14px;
}

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

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

.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: -10px;
  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;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  overflow: auto;
  border-left: 1px solid var(--border);
  flex: 1;
  min-height: 0;
  align-content: start;
}

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

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

.calendar-day.muted {
  background: #f8fafc;
}

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

.calendar-date {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

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

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

.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:active {
  cursor: grabbing;
}

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

.calendar-appointment.trip-bound {
  border-color: rgba(15, 23, 42, 0.12);
}

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

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

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

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

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

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

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

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

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

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

.calendar-appointment:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 104, 216, 0.12);
}

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

.calendar-appointment time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.calendar-appointment strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
}

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

.calendar-appointment small em {
  display: inline;
  color: #334155;
  font-style: normal;
  font-weight: 750;
}

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

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

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

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

.calendar-appointment .status-pill {
  background: transparent;
  color: var(--text);
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.22;
}

.calendar-appointment .timeline-load {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

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

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

.plans-list {
  display: grid;
}

.plan-row {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.plan-row:last-child {
  border-bottom: 0;
}

.plan-row.voided {
  background: #f7f8fa;
  opacity: 0.72;
}

.plan-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.plan-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.plan-status-select {
  width: auto;
  min-width: 118px;
  min-height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.plan-row h3 {
  overflow-wrap: anywhere;
}

.plan-meta,
.stop-line {
  color: var(--muted);
  font-size: 12px;
}

.stop-lines {
  display: grid;
  gap: 5px;
}

.stop-line strong {
  color: var(--text);
}

.empty {
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.36);
  padding: 18px;
}

.modal-panel {
  width: min(520px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 54px rgba(22, 34, 51, 0.2);
}

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

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.modal-body {
  display: grid;
  padding: 10px 16px 16px;
}

.detail-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
  border-bottom: 0;
}

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

.detail-row strong {
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  .planner-layout {
    grid-template-columns: 1fr;
  }

  .plan-form {
    position: static;
    max-height: none;
  }
}

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

  .trip-header,
  .form-actions,
  .panel-head {
    flex-direction: column;
  }

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

  .appointment-context {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .calendar-panel {
    min-height: 420px;
  }

  .appointment-timeline {
    grid-auto-columns: minmax(210px, 82vw);
  }
}

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

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

  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
