:root {
  --ink: #202c39;
  --paper: #f4f1de;
  --blue: #3d5a80;
  --clay: #e07a5f;
  --leaf: #598b5b;
  --mist: #e9e4d0;
  --line: rgba(32, 44, 57, 0.16);
  --shadow: 0 22px 70px rgba(32, 44, 57, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(32, 44, 57, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 44, 57, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 38px 38px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px;
  color: var(--paper);
  background: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
}

.brand img {
  flex: 0 0 auto;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.icon-btn,
.advance-btn,
.stop,
.stage-pill {
  border: 0;
}

.nav-tab {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  color: rgba(244, 241, 222, 0.76);
  background: transparent;
  border-left: 3px solid transparent;
}

.nav-tab.is-active {
  color: var(--paper);
  background: rgba(244, 241, 222, 0.08);
  border-left-color: var(--clay);
}

.rail-note {
  margin-top: auto;
  display: grid;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(244, 241, 222, 0.72);
}

.rail-note strong {
  color: var(--paper);
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 44px) 44px;
}

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

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--blue);
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.96;
}

h2 {
  font-size: clamp(26px, 3vw, 40px);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.search {
  display: grid;
  gap: 6px;
  min-width: min(320px, 44vw);
  font-size: 12px;
  color: rgba(32, 44, 57, 0.72);
}

.search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  outline-color: var(--clay);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--blue);
  font-size: 22px;
}

.screen {
  display: none;
  animation: rise 180ms ease-out;
}

.screen.is-visible {
  display: block;
}

.command-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.field-phone {
  min-height: 680px;
  padding: 18px;
  border-radius: 34px;
  background: #111820;
  color: var(--paper);
  box-shadow: var(--shadow);
  position: sticky;
  top: 22px;
  overflow: hidden;
}

.phone-head {
  display: flex;
  justify-content: space-between;
  padding: 5px 7px 15px;
  font-size: 13px;
  color: rgba(244, 241, 222, 0.68);
}

.route-map {
  position: relative;
  height: 260px;
  overflow: hidden;
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(244, 241, 222, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(244, 241, 222, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #243341, #3d5a80 62%, #598b5b);
  background-size: 26px 26px, 26px 26px, auto;
}

.map-bed {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 38px;
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.bed-a {
  left: 26px;
  top: 42px;
}

.bed-b {
  right: 34px;
  top: 92px;
}

.bed-c {
  left: 84px;
  bottom: 42px;
}

.map-path {
  position: absolute;
  inset: 54px 62px 58px 56px;
  border: 3px dashed rgba(244, 241, 222, 0.74);
  border-left: 0;
  border-bottom: 0;
  transform: skewY(-14deg);
}

.stage-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 14px 0;
}

.stage-pill {
  min-width: 0;
  min-height: 58px;
  border-radius: 8px;
  color: var(--paper);
  background: rgba(244, 241, 222, 0.1);
}

.stage-pill span,
.stage-pill strong {
  display: block;
}

.stage-pill span {
  font-size: 12px;
}

.stage-pill strong {
  margin-top: 3px;
  font-size: 20px;
}

.mobile-focus {
  display: grid;
  gap: 8px;
  padding: 18px;
  min-height: 198px;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
}

.mobile-focus strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  line-height: 1;
}

.mobile-focus p,
.mobile-focus small {
  margin: 0;
  line-height: 1.35;
}

.mobile-zone {
  justify-self: start;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--paper);
  background: var(--clay);
  font-weight: 800;
}

.dispatch-console {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  padding: 18px;
  min-height: 116px;
  border-top: 4px solid var(--blue);
  background: rgba(255, 255, 255, 0.52);
}

.metric-care {
  border-top-color: var(--clay);
}

.metric-delivery {
  border-top-color: var(--leaf);
}

.metric span {
  display: block;
  margin-bottom: 14px;
  color: rgba(32, 44, 57, 0.68);
  font-size: 13px;
}

.metric strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--ink);
  overflow: hidden;
  border-radius: 8px;
}

.stop {
  min-width: 0;
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 16px;
  text-align: left;
  color: rgba(244, 241, 222, 0.72);
  background: transparent;
  border-right: 1px solid rgba(244, 241, 222, 0.16);
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.stop:hover,
.stop.is-active {
  color: var(--paper);
  background: rgba(224, 122, 95, 0.2);
}

.stop:hover {
  transform: translateY(-2px);
}

.stop strong,
.stop em {
  overflow-wrap: anywhere;
}

.stop strong {
  font-size: 18px;
}

.stop em,
.stop-index {
  font-style: normal;
  font-size: 12px;
}

.items-list,
.history-list,
.settings-grid,
.team-grid {
  display: grid;
  gap: 10px;
}

.item-row,
.history-row,
.setting-row,
.team-row {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.56);
  border-bottom: 1px solid var(--line);
}

.item-row {
  grid-template-columns: 62px minmax(0, 1fr) minmax(120px, auto);
}

.sample-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--blue);
  font-weight: 900;
}

.item-title {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.item-title strong {
  font-size: 18px;
}

.item-title span,
.item-meta,
.item-main p {
  color: rgba(32, 44, 57, 0.68);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 8px 0;
  font-size: 13px;
}

.item-meta span {
  padding-right: 9px;
  border-right: 1px solid var(--line);
}

.item-main p {
  margin: 0;
  line-height: 1.38;
}

.item-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.risk {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--mist);
}

.risk-high {
  color: #fff;
  background: var(--clay);
}

.risk-medium {
  background: #e9c46a;
}

.risk-low {
  color: #fff;
  background: var(--leaf);
}

.advance-btn {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--ink);
}

.done-label {
  font-weight: 800;
  color: var(--leaf);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.section-head span {
  max-width: 420px;
  color: rgba(32, 44, 57, 0.68);
  text-align: right;
}

.history-row {
  grid-template-columns: 170px minmax(0, 1fr);
}

.history-row time {
  color: var(--blue);
  font-weight: 800;
  font-size: 13px;
}

.history-row p,
.history-row span,
.setting-row p,
.team-row p {
  margin: 5px 0 0;
  color: rgba(32, 44, 57, 0.68);
}

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

.setting-row {
  align-content: start;
}

.setting-row span {
  color: var(--clay);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 12px;
}

.team-row {
  grid-template-columns: 44px minmax(0, 1fr) 120px 96px;
}

.avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--blue);
  font-weight: 900;
}

.team-row span,
.team-row em {
  overflow-wrap: anywhere;
  font-style: normal;
}

.team-row em {
  color: var(--clay);
  font-weight: 800;
}

.empty-state {
  padding: 28px;
  color: rgba(32, 44, 57, 0.72);
  background: rgba(255, 255, 255, 0.5);
}

.empty-state.error {
  color: #8d3020;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--ink);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-tab {
    padding: 10px 7px;
    text-align: center;
    font-size: 13px;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .nav-tab.is-active {
    border-bottom-color: var(--clay);
  }

  .rail-note {
    display: none;
  }

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

  .field-phone {
    position: relative;
    top: auto;
    min-height: 0;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 18px 12px 32px;
  }

  .topbar,
  .section-head {
    display: grid;
    align-items: start;
  }

  .section-head span {
    text-align: left;
  }

  .top-actions {
    width: 100%;
    align-items: end;
  }

  .search {
    min-width: 0;
    flex: 1;
  }

  .metric-row,
  .timeline,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .stop {
    min-height: 82px;
  }

  .item-row,
  .history-row,
  .team-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .item-side {
    justify-items: start;
  }

  .team-row {
    gap: 8px;
  }
}
