:root {
  --color-primary: #16947f;
  --color-primary-light: #06ba8f;
  --color-secondary: #4388c8;
  --color-error: #eb5757;
  --color-warning: #f2994a;
  --color-info: #939da4;
  --color-text-primary: #000;
  --color-text-secondary: #828282;
  --color-divider: #d6d6d6; /* MUI theme.palette.divider */
  --color-bg: #fafafa; /* used for specimen card backgrounds */
  --color-bg-paper: #fff;
  --font: 'Open Sans', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg-paper);
  color: var(--color-text-primary);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header — matches MUI AppBar + Toolbar ── */
.header {
  background: #fff; /* MuiAppBar-root background-color:#fff */
  border-bottom: 1px solid #d6d6d6;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
  padding: 12px 8px 8px 16px; /* theme.spacing(1.5, 1, 1, 2) */
  min-height: 64px; /* MUI Toolbar default desktop height */
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

/* logo — matches logoContainer: { height: 40, maxHeight: 40, maxWidth: 200 } */
.header svg,
.header img {
  height: 40px;
  width: auto;
  max-width: 200px;
  max-height: 40px;
  flex-shrink: 0;
  object-fit: contain;
}

.header .divider {
  width: 1px;
  height: 20px;
  background: var(--color-divider);
  flex-shrink: 0;
}

.header .subtitle {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Loading cover ── */
.loading-cover {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

/* ── Main two-column layout ── */
.workspace {
  flex: 1;
  overflow: hidden;
  display: flex;
}

/* ── Left panel — matches OrderView "dashboard" style ── */
.left-panel {
  width: 50%;
  overflow-y: auto;
  padding: 18px 24px 48px 24px;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

/* Order heading — extracted from css-1le48k9 on <h2>: 1.5rem/600/margin-top:16px */
.order-id {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.375em;
  margin-top: 16px;
}

/* Subheader — css-14yy325-MuiTypography-root: 0.875rem/400, mt:8px, pb:8px */
.order-meta {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.375em;
  color: var(--color-text-primary);
  margin-top: 8px;
  padding-bottom: 8px;
}

/* Stops table — TableContainer: div with border + overflow:hidden clips rounded corners */
.stops-section {
  border: 1px solid #d6d6d6;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 24px;
  margin-bottom: 24px;
}

.stops-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg-paper);
}

/* thead — matches MuiTableHead override: height 45px, 12px/600/grey */
.stops-table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: left;
  padding: 13px 16px;
  height: 45px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--color-bg-paper);
}

/* tbody rows — matches MuiTableRow action.hover / action.selected */
.stops-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.stops-table tbody tr:hover {
  background: rgba(67, 136, 200, 0.05); /* action.hover */
}

.stops-table tbody tr.active {
  background: rgba(0, 0, 0, 0.04); /* action.selected */
}

/* tbody cells — matches MuiTableCell + MuiTableBody overrides */
.stops-table tbody td {
  font-size: 0.875rem;
  padding: 6px 16px;
  height: 51px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  vertical-align: middle;
  line-height: 1.375em;
}

.stops-table tbody tr:last-child td {
  border-bottom: none;
}

.stop-location {
  font-size: 0.875rem;
}

/* ── Right panel — matches OrderView "details" style ── */
.right-panel {
  width: 50%;
  overflow-y: auto;
  background: var(--color-bg-paper);
  display: flex;
  flex-direction: column;
}

.right-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  gap: 12px;
  padding: 40px;
  text-align: center;
}

.right-placeholder .icon {
  font-size: 40px;
  opacity: 0.4;
}

.right-placeholder p {
  font-size: 14px;
}

/* Stop detail panel */
.stop-detail {
  flex: 1;
}

/* Status strip — extracted: padding:24px */
.stop-detail-top {
  padding: 24px 24px 0 24px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hero */
.stop-detail-hero {
  padding: 24px 24px 0 24px;
}

.stop-detail-hero .stop-name {
  font-size: 1.25rem; /* fix #6: was 1.125rem — matches h3 */
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 4px;
  /* fix #5: removed text-transform: uppercase */
}

.stop-detail-hero .stop-address {
  font-size: 0.875rem;
  color: #000;
}

.eta-box {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-divider);
  border-radius: 4px;
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.eta-box .eta-label {
  color: var(--color-text-secondary);
}

.eta-box .eta-value {
  font-weight: 600;
  text-align: right;
}

/* ── Detail sections content area — fix #9: 24px outer padding (jobstopDetails content p:3) */
.stop-detail-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Flight route map — sits inside the "Flight Route" detail-section card */
.flight-map {
  width: 100%;
  height: 280px;
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
  background: var(--color-divider);
}

/* fix #8/#11: each section is a card — border all 4 sides, 4px radius, 16px padding */
.detail-section {
  border: 1px solid var(--color-divider); /* fix #8: was border-bottom only */
  border-radius: 4px; /* DEFAULT_BORDER_RADIUS */
  padding: 16px; /* p:2 */
}

/* fix #12: 24px gap between section cards (mb:3) */
.detail-section:not(:last-child) {
  margin-bottom: 24px;
}

/* section title */
.detail-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25em;
  margin: -16px -16px 16px -16px;
  padding: 16px 16px 0 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  font-size: 0.875rem;
}

.detail-row .label {
  color: var(--color-text-secondary);
}

.detail-row .value {
  font-weight: 600;
  text-align: right;
}

/* Specimen categories */
.specimens-total {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.specimen-category {
  padding: 16px;
  border-top: 1px solid var(--color-divider);
  margin-left: -16px;
}

.detail-section-title + .specimen-category,
.specimens-total + .specimen-category {
  border-top: none;
  padding-top: 0;
}

.specimen-category:last-child {
  padding-bottom: 0;
}

.specimen-category-name {
  font-size: 18px;
  font-weight: 400;
  margin-bottom: 8px;
}

.specimen-category-count {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ── Badges — table chips with colored backgrounds ── */
.badge {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
}

.badge--completed {
  background: rgba(22, 148, 127, 0.12);
  color: var(--color-primary);
}
.badge--new {
  background: rgba(147, 157, 164, 0.12);
  color: var(--color-info);
}
.badge--inprogress,
.badge--dispatched {
  background: rgba(67, 136, 200, 0.12);
  color: var(--color-secondary);
}
.badge--scheduled {
  background: rgba(242, 153, 74, 0.12);
  color: var(--color-warning);
}
.badge--delayed {
  background: rgba(198, 40, 40, 0.1);
  color: #c62828;
}
.badge--incomplete {
  background: rgba(147, 157, 164, 0.2);
  color: var(--color-info);
}

/* Right panel status — plain colored text, no pill, no uppercase */
.stop-detail-top .badge {
  background: none;
  padding: 0;
  height: auto;
  font-size: 14px;
  font-weight: 600;
  text-transform: none;
}

/* Error state */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 16px;
  text-align: center;
  padding: 40px;
}

.error-state .icon {
  font-size: 48px;
  color: var(--color-text-secondary);
}

.error-state p {
  font-size: 16px;
  color: var(--color-text-secondary);
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-divider);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Footer ── */
.footer {
  padding: 12px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-secondary);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  background: var(--color-bg-paper);
}

.flight-section {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--color-bg);
  border-radius: 8px;
  border: 1px solid var(--color-divider);
}

.flight-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.flight-info {
  font-size: 13px;
}

.flight-time {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.btn-view-flight {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 700px) {
  body {
    overflow: auto;
  }

  .workspace {
    flex-direction: column;
    overflow: auto;
  }

  .left-panel,
  .right-panel {
    width: 100%;
    overflow: visible;
    padding-left: 24px;
  }

  .right-panel {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }
}
