:root {
  --ink: #17202a;
  --paper: #f7f3e8;
  --paper-2: #fffaf0;
  --green: #2f8f83;
  --amber: #f2b544;
  --blue: #5b8def;
  --red: #d96c75;
  --muted: #66717d;
  --line: rgba(23, 32, 42, 0.14);
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 42, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 64px 64px, 64px 64px, auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 243, 232, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand img {
  flex: 0 0 38px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.18);
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand small {
  display: block;
  max-width: 260px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.2;
}

.mode-tabs {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover {
  background: rgba(23, 32, 42, 0.06);
  color: var(--ink);
}

.tab.is-active {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  min-height: calc(100vh - 75px);
}

.planner-panel {
  min-width: 0;
  padding: 24px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.filters {
  display: grid;
  grid-template-columns: 150px minmax(190px, 250px);
  gap: 10px;
}

.filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.filters input,
.filters select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--paper-2);
  color: var(--ink);
  outline: none;
}

.filters input:focus,
.filters select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 143, 131, 0.16);
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metric {
  min-height: 82px;
  padding: 14px;
  background: rgba(255, 250, 240, 0.82);
}

.metric span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 1.55rem;
  line-height: 1;
}

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

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

.lane-ruler {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin: 0 0 8px 188px;
  color: var(--muted);
  font-size: 0.72rem;
}

.resource-lanes {
  display: grid;
  gap: 10px;
}

.lane {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
  overflow: hidden;
}

.lane-meta {
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(23, 32, 42, 0.035);
}

.lane-meta .callsign {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  font-weight: 900;
}

.signal-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--driver-color, var(--green));
}

.lane-meta p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.lane-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  padding: 10px;
  min-width: 0;
}

.lane-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(16.66% - 1px), rgba(23, 32, 42, 0.08) calc(16.66% - 1px), rgba(23, 32, 42, 0.08) 16.66%);
  pointer-events: none;
}

.route-card {
  position: relative;
  z-index: 1;
  grid-column: span 2;
  align-self: stretch;
  min-width: 0;
  margin: 0 6px 0 0;
  border: 1px solid rgba(23, 32, 42, 0.2);
  border-left: 5px solid var(--route-color, var(--green));
  border-radius: 7px;
  padding: 11px;
  background: var(--paper-2);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 22px rgba(23, 32, 42, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.route-card:hover,
.route-card.is-selected {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(23, 32, 42, 0.42);
}

.route-card strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.25;
}

.route-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.25;
}

.route-card .progress {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(23, 32, 42, 0.1);
}

.route-card .progress i {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--route-color, var(--green));
}

.unassigned {
  border-style: dashed;
}

.inspector {
  border-left: 1px solid var(--line);
  background: #17202a;
  color: var(--paper);
  min-width: 0;
}

.inspector-content {
  position: sticky;
  top: 76px;
  padding: 24px;
}

.inspector .eyebrow {
  color: var(--amber);
}

.inspector .muted {
  color: rgba(247, 243, 232, 0.68);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(247, 243, 232, 0.12);
  color: var(--paper);
  font-size: 0.76rem;
  font-weight: 800;
}

.inspector-actions,
.driver-picker {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.driver-picker select,
.inspector-actions button,
.primary-action {
  min-height: 42px;
  border: 1px solid rgba(247, 243, 232, 0.22);
  border-radius: 6px;
  padding: 9px 11px;
}

.driver-picker select {
  width: 100%;
  background: rgba(247, 243, 232, 0.08);
  color: var(--paper);
}

.driver-picker option {
  color: var(--ink);
}

.inspector-actions button,
.primary-action {
  background: var(--amber);
  color: var(--ink);
  font-weight: 900;
  transition: transform 160ms ease, filter 160ms ease;
}

.inspector-actions button:hover,
.primary-action:hover {
  transform: translateY(-1px);
  filter: brightness(0.97);
}

.inspector-actions button.secondary {
  background: rgba(247, 243, 232, 0.1);
  color: var(--paper);
}

.stop-list,
.proof-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.stop-list li,
.proof-list li {
  padding: 10px;
  border: 1px solid rgba(247, 243, 232, 0.14);
  border-radius: 6px;
  background: rgba(247, 243, 232, 0.06);
}

.stop-list strong,
.proof-list strong {
  display: block;
  font-size: 0.86rem;
}

.stop-list span,
.proof-list span {
  display: block;
  margin-top: 4px;
  color: rgba(247, 243, 232, 0.66);
  font-size: 0.76rem;
  line-height: 1.35;
}

.analytics-layout {
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(0, 1fr);
  gap: 18px;
}

.chart-block,
.status-bars,
.import-panel,
.public-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  padding: 18px;
}

.chart-block {
  display: flex;
  align-items: center;
  gap: 18px;
}

.donut {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--value, 0%), rgba(23, 32, 42, 0.1) 0);
  box-shadow: inset 0 0 0 18px var(--paper-2);
}

.status-bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 34px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(23, 32, 42, 0.1);
}

.bar-track i {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  background: var(--green);
}

.import-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

.import-panel pre {
  grid-column: 1 / -1;
  min-height: 96px;
  margin: 0;
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
  background: var(--ink);
  color: var(--paper);
  white-space: pre-wrap;
}

.public-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.public-ticket {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--paper-2);
}

.public-ticket strong {
  display: block;
}

.public-ticket span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.notice {
  border: 1px solid rgba(217, 108, 117, 0.4);
  border-radius: 8px;
  padding: 12px;
  background: rgba(217, 108, 117, 0.08);
  color: #8b2630;
}

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

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .inspector {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .inspector-content {
    position: relative;
    top: auto;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .mode-tabs {
    justify-content: flex-start;
  }

  .planner-panel {
    padding: 16px;
  }

  .planner-head,
  .import-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .filters,
  .metrics-strip,
  .analytics-layout {
    grid-template-columns: 1fr;
  }

  .lane-ruler {
    display: none;
  }

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

  .lane-meta {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .lane-grid::before {
    display: none;
  }

  .route-card {
    grid-column: auto;
    margin: 0 0 8px;
  }
}
