:root {
  --ink: #202c39;
  --paper: #f4f1de;
  --blue: #3d5a80;
  --coral: #e07a5f;
  --mint: #7aa095;
  --line: rgba(32, 44, 57, 0.16);
  --line-dark: rgba(244, 241, 222, 0.22);
  --shadow: 0 18px 44px rgba(32, 44, 57, 0.16);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.mobile-field {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 24px;
  color: var(--paper);
  background:
    linear-gradient(145deg, rgba(61, 90, 128, 0.6), transparent 42%),
    var(--ink);
  border-right: 1px solid rgba(244, 241, 222, 0.18);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
}

.eyebrow,
.label {
  margin: 0 0 5px;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.72;
}

h1,
h2,
h3,
h4,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 0.95;
}

h2 {
  font-size: 42px;
  line-height: 1.02;
}

h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.nav-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab-button,
.stage-button,
.icon-button,
.primary-action,
.ghost-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.tab-button {
  color: var(--paper);
  background: rgba(244, 241, 222, 0.08);
  border-color: rgba(244, 241, 222, 0.12);
}

.tab-button:hover,
.tab-button.active {
  transform: translateY(-1px);
  background: var(--coral);
  color: var(--ink);
}

.field-brief {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-brief > div {
  padding: 14px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: rgba(244, 241, 222, 0.07);
}

.field-brief strong {
  display: block;
  font-family: var(--serif);
  font-size: 31px;
  line-height: 1;
}

.route-map {
  position: relative;
  min-height: 390px;
  margin-top: auto;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background:
    radial-gradient(circle at 35% 22%, rgba(224, 122, 95, 0.24), transparent 18%),
    linear-gradient(135deg, rgba(244, 241, 222, 0.09) 25%, transparent 25%, transparent 50%, rgba(244, 241, 222, 0.09) 50%, rgba(244, 241, 222, 0.09) 75%, transparent 75%),
    rgba(244, 241, 222, 0.045);
  background-size: auto, 38px 38px, auto;
  overflow: hidden;
}

.map-line {
  position: absolute;
  inset: 48px 54px 58px 72px;
  border-left: 3px solid var(--coral);
  border-bottom: 3px solid var(--coral);
  transform: skewY(-18deg);
  opacity: 0.9;
}

.map-stop {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 34px;
  padding: 6px 10px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--coral);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.stop-a { left: 34px; top: 46px; }
.stop-b { right: 38px; top: 130px; }
.stop-c { left: 48px; bottom: 118px; }
.stop-d { right: 30px; bottom: 42px; }

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

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 46vw);
}

input[type="search"] {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.16);
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
  color: var(--paper);
  background: var(--blue);
}

.screen {
  display: none;
  animation: enter 240ms ease both;
}

.screen.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.metric {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
}

.metric p,
.metric span,
.section-heading p,
.item-row p,
.brief-summary,
.timeline-item p,
.setting-row p,
.team-member p,
.certificate-line {
  margin: 0;
  color: rgba(32, 44, 57, 0.72);
  line-height: 1.45;
}

.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.pipeline,
.brief-panel {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-heading p {
  max-width: 620px;
  font-size: 14px;
}

.stage-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stage-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--line);
}

.stage-button strong {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 8px;
  font-size: 12px;
}

.stage-button.active {
  background: var(--coral);
  border-color: var(--coral);
}

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

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(122px, 0.28fr);
  gap: 16px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.item-row:hover,
.item-row.active {
  transform: translateY(-1px);
  background: #fffaf0;
  border-color: rgba(224, 122, 95, 0.55);
}

.item-title-line,
.team-top,
.brief-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.item-main {
  min-width: 0;
}

.item-row p {
  margin-top: 6px;
  font-size: 13px;
}

.item-side {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: center;
  text-align: right;
  font-size: 13px;
}

.item-side strong {
  font-size: 14px;
}

.priority,
.stage-chip,
.status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.priority-urgent { background: rgba(224, 122, 95, 0.24); color: #8f2e17; }
.priority-high { background: rgba(61, 90, 128, 0.18); color: var(--blue); }
.priority-normal { background: rgba(122, 160, 149, 0.24); color: #315c54; }
.priority-low { background: rgba(32, 44, 57, 0.11); color: var(--ink); }

.stage-chip {
  color: var(--paper);
  background: var(--ink);
}

.brief-panel {
  position: sticky;
  top: 28px;
  padding: 18px;
  border: 1px solid rgba(32, 44, 57, 0.2);
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.selected-brief {
  display: grid;
  gap: 14px;
}

.brief-topline span,
.timeline-item span,
.team-member span,
.setting-row span {
  color: rgba(32, 44, 57, 0.62);
  font-size: 13px;
}

.brief-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.brief-facts div {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.brief-facts dt {
  margin: 0 0 4px;
  color: rgba(32, 44, 57, 0.58);
  font-size: 12px;
}

.brief-facts dd {
  margin: 0;
  font-weight: 800;
}

.brief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.ghost-action {
  padding: 0 14px;
  font-weight: 800;
}

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

.primary-action:disabled {
  cursor: default;
  opacity: 0.55;
}

.ghost-action {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.timeline-item,
.setting-row,
.team-member {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
}

.timeline-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 14px;
}

.timeline-item time {
  color: var(--coral);
  font-weight: 900;
}

.timeline-item p {
  margin: 5px 0;
}

.setting-row {
  display: grid;
  grid-template-columns: 170px 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.setting-row strong {
  color: var(--blue);
}

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

.team-member {
  display: grid;
  gap: 8px;
}

.status-dot {
  background: rgba(122, 160, 149, 0.24);
  color: #315c54;
}

.status-field { background: rgba(224, 122, 95, 0.22); color: #8f2e17; }
.status-review { background: rgba(61, 90, 128, 0.18); color: var(--blue); }
.status-offline { background: rgba(32, 44, 57, 0.12); color: var(--ink); }

.loadbar {
  height: 7px;
  overflow: hidden;
  background: rgba(32, 44, 57, 0.12);
  border-radius: 8px;
}

.loadbar i {
  display: block;
  height: 100%;
  background: var(--coral);
  border-radius: 8px;
}

.loading-line,
.empty-state {
  padding: 18px;
  color: rgba(32, 44, 57, 0.7);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.38);
}

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

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

  .mobile-field {
    position: relative;
    height: auto;
    min-height: auto;
  }

  .route-map {
    min-height: 190px;
  }

  .map-line {
    inset: 48px 48px 50px 48px;
  }

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

  .brief-panel {
    position: relative;
    top: auto;
  }

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

@media (max-width: 760px) {
  .dispatch-console,
  .mobile-field {
    padding: 18px;
  }

  .console-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  h2 {
    font-size: 32px;
  }

  .metrics-grid,
  .team-grid,
  .field-brief {
    grid-template-columns: 1fr 1fr;
  }

  .item-row,
  .setting-row {
    grid-template-columns: 1fr;
  }

  .item-side {
    justify-items: start;
    text-align: left;
  }

  .brief-facts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .nav-tabs,
  .metrics-grid,
  .team-grid,
  .field-brief {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }

  .stage-filter {
    justify-content: stretch;
  }

  .stage-button {
    flex: 1 1 140px;
  }

  .brand-block {
    align-items: flex-start;
  }
}
