:root {
  --ink: #202c39;
  --paper: #f4f1de;
  --blue: #3d5a80;
  --coral: #e07a5f;
  --leaf: #2f7d64;
  --mist: #eef2ed;
  --line: rgba(32, 44, 57, 0.16);
  --shadow: 0 22px 70px rgba(32, 44, 57, 0.16);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(61, 90, 128, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #fbf8eb 0%, #f4f1de 45%, #e8eee7 100%);
  background-size: 54px 54px, auto;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 320px);
  gap: 16px;
  align-items: center;
  padding: 10px 0 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(32, 44, 57, 0.2);
}

.brand strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: rgba(32, 44, 57, 0.68);
  line-height: 1.25;
}

.view-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
  border-radius: 999px;
  overflow-x: auto;
}

.tab-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 9px 13px;
  cursor: pointer;
  color: rgba(32, 44, 57, 0.74);
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab-button:hover {
  transform: translateY(-1px);
}

.tab-button.active {
  background: var(--ink);
  color: var(--paper);
}

.search-box {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.search-box span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0;
  color: rgba(32, 44, 57, 0.58);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  outline: none;
}

.search-box input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(61, 90, 128, 0.12);
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 18px;
  align-items: stretch;
}

.dispatch-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 239, 0.86);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 30px);
  overflow: hidden;
}

.section-kicker {
  color: var(--coral);
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.dispatch-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 20px;
}

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

h1 {
  max-width: 800px;
  font-size: clamp(2rem, 5vw, 4.9rem);
  line-height: 0.94;
}

.dispatch-heading p {
  max-width: 720px;
  margin: 12px 0 0;
  color: rgba(32, 44, 57, 0.7);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.55;
}

.sync-status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  background: #fff;
  font-size: 0.86rem;
}

.sync-status[data-mode="busy"] {
  color: var(--blue);
}

.sync-status[data-mode="ok"] {
  color: var(--leaf);
}

.sync-status[data-mode="error"] {
  color: #b1432d;
}

.view {
  display: none;
}

.active-view {
  display: block;
  animation: viewIn 220ms ease both;
}

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

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

.metric {
  min-width: 0;
  padding: 14px;
  border-top: 3px solid var(--coral);
  background: rgba(255, 255, 255, 0.62);
}

.metric span {
  display: block;
  color: rgba(32, 44, 57, 0.62);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.15rem, 2.2vw, 1.75rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.route-board {
  display: grid;
  grid-template-columns: minmax(240px, 0.82fr) minmax(280px, 1.18fr);
  gap: 16px;
  margin: 18px 0;
  align-items: stretch;
}

.route-map {
  position: relative;
  min-height: 260px;
  border: 1px solid rgba(32, 44, 57, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 125, 100, 0.15), transparent 42%),
    linear-gradient(45deg, rgba(224, 122, 95, 0.1), transparent 52%),
    #f7f5e8;
  overflow: hidden;
}

.map-line {
  position: absolute;
  inset: 38px 42px;
  border: 2px dashed rgba(32, 44, 57, 0.42);
  border-radius: 44% 52% 48% 50%;
  transform: rotate(-6deg);
}

.map-zone {
  position: absolute;
  display: grid;
  place-items: center;
  width: 82px;
  min-height: 58px;
  border: 1px solid rgba(32, 44, 57, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
}

.zone-a {
  left: 28px;
  top: 36px;
}

.zone-b {
  right: 30px;
  top: 58px;
}

.zone-c {
  left: 42px;
  bottom: 38px;
}

.zone-d {
  right: 42px;
  bottom: 44px;
}

.stage-track {
  display: grid;
  gap: 10px;
}

.stage-stop {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 10px 14px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--stage-color);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.stage-stop:hover {
  transform: translateX(4px);
  background: #fff;
}

.stage-stop strong,
.stage-stop small {
  min-width: 0;
}

.stop-index {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-weight: 900;
}

.stage-stop small {
  color: rgba(32, 44, 57, 0.62);
}

.stage-stop em {
  grid-column: 3;
  grid-row: 1 / span 2;
  font-style: normal;
  font-weight: 900;
  color: var(--stage-color);
}

.work-split {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(310px, 1.05fr);
  gap: 14px;
}

.proposal-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.proposal-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 12px;
  cursor: pointer;
  text-align: left;
}

.proposal-row.active {
  border-color: var(--ink);
  background: #fff;
}

.row-main,
.row-side {
  min-width: 0;
}

.row-main strong,
.row-main small,
.row-side b,
.row-side small {
  display: block;
  overflow-wrap: anywhere;
}

.row-main small,
.row-side small {
  margin-top: 6px;
  color: rgba(32, 44, 57, 0.62);
}

.row-side {
  text-align: right;
}

.proposal-inspector {
  min-width: 0;
  border: 1px solid rgba(32, 44, 57, 0.22);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  padding: 16px;
}

.inspector-head span {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--coral);
  font-weight: 900;
}

.inspector-head strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.6vw, 2.1rem);
  line-height: 1.08;
}

.inspector-head small {
  display: block;
  margin-top: 10px;
  color: rgba(244, 241, 222, 0.76);
  line-height: 1.45;
}

.inspector-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.inspector-stats div {
  min-width: 0;
  border-top: 1px solid rgba(244, 241, 222, 0.24);
  padding-top: 10px;
}

.inspector-stats span,
.inspector-stats b {
  display: block;
  overflow-wrap: anywhere;
}

.inspector-stats span {
  color: rgba(244, 241, 222, 0.62);
  font-size: 0.8rem;
}

.line-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.line-list li {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid rgba(244, 241, 222, 0.16);
}

.line-list span,
.line-list small {
  color: rgba(244, 241, 222, 0.72);
}

.line-list em {
  font-style: normal;
  color: #fff;
}

.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.primary-action,
.ghost-action,
.phone-action {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  background: var(--coral);
  color: var(--ink);
}

.primary-action.done {
  background: rgba(244, 241, 222, 0.18);
  color: rgba(244, 241, 222, 0.78);
  cursor: default;
}

.ghost-action {
  background: rgba(244, 241, 222, 0.12);
  color: var(--paper);
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin: 10px 0 16px;
}

.history-toolbar h2 {
  font-size: clamp(1.7rem, 4vw, 3.2rem);
}

.history-toolbar span {
  color: rgba(32, 44, 57, 0.62);
}

.action-feed {
  display: grid;
  gap: 10px;
}

.action-item {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.action-item time {
  color: var(--blue);
  font-weight: 800;
}

.action-item p {
  margin: 6px 0;
  line-height: 1.5;
}

.action-item span {
  color: rgba(32, 44, 57, 0.62);
}

.workflow-grid,
.team-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.workflow-stage,
.team-member {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  padding: 16px;
}

.workflow-stage {
  border-top: 5px solid var(--stage-color);
}

.workflow-stage span {
  color: var(--stage-color);
  font-weight: 900;
}

.workflow-stage strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
}

.workflow-stage p {
  margin: 8px 0 14px;
  color: rgba(32, 44, 57, 0.68);
  line-height: 1.45;
}

.sla-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(32, 44, 57, 0.1);
}

.sla-bar i {
  display: block;
  height: 100%;
  background: var(--stage-color);
}

.settings-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.settings-strip div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

.settings-strip span,
.settings-strip strong {
  display: block;
  overflow-wrap: anywhere;
}

.settings-strip span {
  color: rgba(32, 44, 57, 0.58);
  font-size: 0.78rem;
}

.team-member {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 84px 42px;
  gap: 12px;
  align-items: center;
}

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

.team-member strong,
.team-member span,
.team-member small {
  display: block;
  overflow-wrap: anywhere;
}

.team-member span,
.team-member small {
  color: rgba(32, 44, 57, 0.65);
}

meter {
  width: 100%;
  height: 10px;
}

.field-mirror {
  min-width: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  padding: 18px;
  box-shadow: var(--shadow);
}

.phone-frame {
  position: sticky;
  top: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: min(780px, calc(100svh - 54px));
  border: 1px solid rgba(244, 241, 222, 0.24);
  border-radius: 28px;
  background: #101923;
  padding: 14px;
}

.phone-bar {
  display: flex;
  justify-content: space-between;
  color: rgba(244, 241, 222, 0.7);
  padding: 6px 8px 14px;
}

.phone-screen {
  display: grid;
  align-content: start;
  gap: 12px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(244, 241, 222, 0.08), transparent),
    #f4f1de;
  color: var(--ink);
  padding: 16px;
  overflow: hidden;
}

.phone-route span,
.phone-stop small {
  display: block;
  color: rgba(32, 44, 57, 0.58);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.phone-route strong {
  display: block;
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  line-height: 1;
}

.phone-route p {
  margin: 10px 0 0;
  line-height: 1.4;
}

.phone-stop,
.phone-lines {
  border-top: 1px solid rgba(32, 44, 57, 0.16);
  padding-top: 12px;
}

.phone-stop b,
.phone-stop em {
  display: block;
}

.phone-stop b {
  margin: 6px 0;
  font-size: 1.35rem;
}

.phone-stop em {
  color: rgba(32, 44, 57, 0.65);
  font-style: normal;
  line-height: 1.35;
}

.phone-lines {
  display: grid;
  gap: 8px;
}

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

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

.phone-action {
  width: 100%;
  margin-top: 4px;
  background: var(--ink);
  color: var(--paper);
}

.empty-state,
.phone-empty {
  padding: 16px;
  border: 1px dashed rgba(32, 44, 57, 0.28);
  border-radius: 8px;
  color: rgba(32, 44, 57, 0.68);
}

@media (max-width: 1120px) {
  .topbar,
  .console-grid,
  .route-board,
  .work-split {
    grid-template-columns: 1fr;
  }

  .view-tabs {
    justify-self: start;
    max-width: 100%;
  }

  .field-mirror {
    order: -1;
  }

  .phone-frame {
    position: static;
    min-height: auto;
  }
}

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

  .dispatch-pane,
  .field-mirror {
    padding: 14px;
  }

  .dispatch-heading,
  .history-toolbar {
    display: grid;
  }

  .metric-row,
  .workflow-grid,
  .team-grid,
  .settings-strip {
    grid-template-columns: 1fr;
  }

  .proposal-row,
  .stage-stop,
  .action-item,
  .team-member {
    grid-template-columns: 1fr;
  }

  .row-side {
    text-align: left;
  }

  .stage-stop em {
    grid-column: auto;
    grid-row: auto;
  }

  .stop-index {
    grid-row: auto;
  }

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