:root {
  --ink: #202c39;
  --paper: #f4f1de;
  --blue: #3d5a80;
  --coral: #e07a5f;
  --green: #6f8f72;
  --line: rgba(32, 44, 57, 0.16);
  --muted: rgba(32, 44, 57, 0.66);
  --white: #fffdf7;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(32, 44, 57, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 44, 57, 0.05) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 22px;
  color: var(--paper);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand strong,
h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-size: 22px;
}

.brand small {
  color: rgba(244, 241, 222, 0.72);
}

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

.tab {
  min-height: 42px;
  border: 1px solid rgba(244, 241, 222, 0.18);
  border-radius: 8px;
  color: rgba(244, 241, 222, 0.82);
  background: transparent;
  text-align: left;
  padding: 0 12px;
}

.tab.is-active,
.tab:hover {
  border-color: var(--coral);
  color: var(--paper);
  background: rgba(224, 122, 95, 0.16);
}

.field-phone {
  margin-top: auto;
  border: 1px solid rgba(244, 241, 222, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(244, 241, 222, 0.08);
}

.phone-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(244, 241, 222, 0.16);
  font-size: 13px;
}

.phone-map {
  position: relative;
  height: 154px;
  background:
    linear-gradient(135deg, transparent 34%, rgba(244, 241, 222, 0.18) 35%, transparent 37%),
    linear-gradient(20deg, transparent 48%, rgba(224, 122, 95, 0.3) 49%, transparent 51%),
    rgba(61, 90, 128, 0.38);
}

.pin {
  position: absolute;
  width: 15px;
  height: 15px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--coral);
}

.pin-a { left: 22%; top: 28%; }
.pin-b { right: 26%; top: 42%; }
.pin-c { left: 48%; bottom: 22%; }

.phone-list {
  display: grid;
  gap: 1px;
  background: rgba(244, 241, 222, 0.14);
}

.phone-list button,
.phone-list p {
  min-height: 54px;
  border: 0;
  color: var(--paper);
  background: var(--ink);
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  text-align: left;
}

.phone-list span {
  overflow-wrap: anywhere;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
}

h3 {
  margin-bottom: 7px;
}

.search {
  width: min(420px, 100%);
  height: 46px;
  display: grid;
  grid-template-columns: 1fr 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
}

.search input {
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0 14px;
  color: var(--ink);
}

.search button {
  border: 0;
  background: var(--coral);
  color: var(--ink);
  font-size: 22px;
}

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

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

.status-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 22px;
  align-items: start;
}

.dispatch,
.map-panel {
  min-width: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.section-head.compact {
  margin-bottom: 14px;
}

.metric {
  min-width: 132px;
  padding-top: 4px;
  text-align: right;
}

.metric span {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
  line-height: 0.9;
}

.metric small,
.muted {
  color: var(--muted);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(128px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.stop {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  color: var(--ink);
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 12px;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.stop:hover,
.stop.is-active {
  transform: translateY(-2px);
  border-color: var(--blue);
  background: var(--white);
}

.dot {
  width: 16px;
  height: 16px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 1px var(--line);
}

.stop small {
  color: var(--muted);
  line-height: 1.35;
}

.sample-table {
  display: grid;
  gap: 8px;
}

.sample-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 260px);
  gap: 14px;
  align-items: center;
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.82);
  transition: border-color 160ms ease, transform 160ms ease;
}

.sample-row:hover,
.sample-row.is-selected {
  border-color: var(--coral);
  transform: translateX(2px);
}

.sample-main p,
.sample-meta span {
  margin-bottom: 0;
  color: var(--muted);
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--white);
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.stage-care { background: var(--green); }
.stage-delivery { background: var(--coral); color: var(--ink); }
.stage-delivered { background: var(--ink); }

.sample-meta {
  display: grid;
  grid-template-columns: 1fr 58px;
  gap: 8px;
  align-items: center;
}

.sample-meta button {
  grid-column: 1 / -1;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
}

.nursery-map {
  position: relative;
  min-height: 318px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(32, 44, 57, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 44, 57, 0.08) 1px, transparent 1px),
    #e7e4cf;
  background-size: 36px 36px;
}

.zone {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 96px;
  height: 62px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

.zone-a { left: 18px; top: 36px; }
.zone-b { right: 24px; top: 120px; border-color: var(--blue); }
.zone-c { left: 92px; bottom: 34px; border-color: var(--coral); }

.route-line {
  position: absolute;
  left: 72px;
  top: 82px;
  width: 210px;
  height: 164px;
  border-top: 4px solid var(--blue);
  border-right: 4px solid var(--blue);
  transform: skewY(-18deg);
  opacity: 0.7;
}

.inspector {
  margin-top: 14px;
  padding: 16px;
  border-left: 5px solid var(--coral);
  background: rgba(255, 253, 247, 0.72);
}

dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

dl div {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.history-list,
.workflow-editor,
.team-grid {
  display: grid;
  gap: 10px;
}

.history-row,
.workflow-row,
.team-person {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.76);
  padding: 16px;
}

.history-row {
  display: grid;
  grid-template-columns: 160px 210px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.history-row span,
.history-row p,
.workflow-row span,
.team-person small,
.team-person p {
  color: var(--muted);
}

.history-row p {
  margin-bottom: 0;
}

.workflow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 64px;
  gap: 16px;
  align-items: center;
}

.workflow-row strong,
.workflow-row span {
  display: block;
}

.workflow-row input[type="number"] {
  width: 86px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: var(--white);
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 52px;
  height: 30px;
  border-radius: 30px;
  background: rgba(32, 44, 57, 0.2);
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--blue);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

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

.team-person {
  min-height: 170px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.team-person > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  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: 1080px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    min-height: 0;
  }

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

  .field-phone {
    display: none;
  }

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

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

@media (max-width: 680px) {
  .workspace,
  .rail {
    padding: 16px;
  }

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

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

  .timeline {
    grid-template-columns: repeat(5, 150px);
  }

  .sample-row,
  .sample-meta,
  .history-row,
  .workflow-row,
  .team-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    text-align: left;
  }

  .nursery-map {
    min-height: 260px;
  }
}

