:root {
  color-scheme: light;
  --ink: #17202a;
  --paper: #f7f3e8;
  --paper-strong: #fffaf0;
  --green: #2f8f83;
  --amber: #f2b544;
  --red: #d85f4c;
  --blue: #6f7bd9;
  --muted: #6c6f69;
  --line: rgba(23, 32, 42, 0.14);
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(47, 143, 131, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(23, 32, 42, 0.055) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: 36px 36px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  color: var(--paper);
  background: var(--ink);
}

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

.brand img {
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.24));
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand small,
.rail-note {
  color: rgba(247, 243, 232, 0.7);
}

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

.tab,
.ghost-action,
.primary-action {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab {
  width: 100%;
  padding: 11px 12px;
  color: rgba(247, 243, 232, 0.76);
  text-align: left;
  background: transparent;
}

.tab:hover,
.tab.is-active {
  color: var(--paper);
  background: rgba(247, 243, 232, 0.1);
}

.tab.is-active {
  box-shadow: inset 3px 0 0 var(--amber);
}

.rail-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(247, 243, 232, 0.13);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.signal-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(242, 181, 68, 0.16);
}

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

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

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 700px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 0.96;
}

h2 {
  font-size: 20px;
  line-height: 1.1;
}

.status-strip {
  min-width: 230px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
}

.status-strip span,
.status-strip strong {
  display: block;
}

.status-strip span {
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  margin-top: 3px;
  color: var(--green);
}

.metric-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.metric-band > div {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.metric-band > div:last-child {
  border-right: 0;
}

.metric-band span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-band strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: liftIn 220ms ease both;
}

.operations-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(420px, 1.25fr) 330px;
  gap: 16px;
  align-items: start;
}

.portfolio,
.board,
.inspector,
.analysis-panel,
.import-console,
.public-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
}

.portfolio,
.board,
.analysis-panel,
.import-console,
.public-status {
  padding: 16px;
}

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

.section-head.compact {
  align-items: center;
}

.search-box {
  display: grid;
  gap: 5px;
  min-width: 180px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.search-box input,
.driver-select select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fffdf7;
  outline: none;
}

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

.route-grid {
  display: grid;
  gap: 10px;
}

.route-card {
  width: 100%;
  min-height: 138px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: #fffdf7;
}

.route-card:hover,
.route-card.is-active {
  transform: translateY(-2px);
  border-color: rgba(47, 143, 131, 0.55);
  box-shadow: 0 14px 30px rgba(23, 32, 42, 0.1);
}

.route-code {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.route-card strong,
.route-card small {
  display: block;
}

.route-card strong {
  min-height: 42px;
  font-size: 17px;
  line-height: 1.2;
}

.route-card small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.3;
}

.route-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--paper);
  background: var(--green);
}

.status-pill.new_order,
.status-pill.assigned {
  color: var(--ink);
  background: var(--amber);
}

.status-pill.risk {
  background: var(--red);
}

.status-pill.confirmed {
  background: var(--ink);
}

.progress-line {
  overflow: hidden;
  height: 7px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.11);
}

.progress-line i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.calendar-head,
.lane-row {
  display: grid;
  grid-template-columns: 126px repeat(var(--days, 2), minmax(138px, 1fr));
}

.calendar-head {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(255, 250, 240, 0.95);
}

.calendar-head span {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.lane-label {
  color: var(--ink);
}

.lane-grid {
  overflow: auto;
  max-height: 650px;
}

.lane-row {
  min-height: 142px;
  border-bottom: 1px solid var(--line);
}

.lane-row:last-child {
  border-bottom: 0;
}

.driver-label {
  position: sticky;
  left: 0;
  z-index: 1;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px 10px 12px 15px;
  border-right: 1px solid var(--line);
  background: #fffdf7;
}

.driver-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 4px;
  border-radius: 999px;
  background: var(--driver);
}

.driver-label b {
  font-size: 13px;
  line-height: 1.2;
}

.driver-label span {
  color: var(--muted);
  font-size: 12px;
}

.lane-cell {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
}

.stop-chip {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 72px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: #fffdf7;
}

.stop-chip:hover,
.stop-chip.is-selected {
  transform: translateY(-1px);
  border-color: var(--green);
  box-shadow: 0 10px 22px rgba(23, 32, 42, 0.09);
}

.stop-chip.watch {
  border-left: 4px solid var(--amber);
}

.stop-chip.late {
  border-left: 4px solid var(--red);
}

.stop-chip span {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.stop-chip strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.2;
}

.stop-chip small {
  color: var(--muted);
}

.inspector {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.inspector > p {
  color: var(--muted);
  line-height: 1.45;
}

.inspector-route {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--ink);
}

.inspector-route span {
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.inspector-route small {
  color: rgba(247, 243, 232, 0.72);
}

.facts {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.facts div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
}

.facts dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.driver-select {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.checklist li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: var(--muted);
  line-height: 1.3;
}

.checklist li span {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-radius: 50%;
}

.checklist li.is-done {
  color: var(--ink);
}

.checklist li.is-done span {
  border-color: var(--green);
  background: radial-gradient(circle at center, var(--green) 0 42%, transparent 46%);
}

.inspector-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

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

.primary-action {
  color: var(--paper);
  background: var(--green);
  box-shadow: 0 10px 24px rgba(47, 143, 131, 0.22);
}

.primary-action:hover,
.ghost-action:hover {
  transform: translateY(-1px);
}

.ghost-action {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fffdf7;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr) minmax(260px, 0.78fr);
  gap: 16px;
}

.chart {
  display: flex;
  align-items: end;
  gap: 12px;
  min-height: 280px;
  padding-top: 18px;
}

.bar-row {
  display: grid;
  grid-template-rows: 18px 1fr 18px;
  gap: 8px;
  align-items: end;
  width: 100%;
  min-width: 42px;
  height: 250px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.bar-row i {
  position: relative;
  display: block;
  align-self: end;
  min-height: 12px;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--amber), var(--green));
}

.bar-row b {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  color: var(--ink);
  font-style: normal;
}

.proof-list,
.payment-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.proof-item,
.payment-row,
.public-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.proof-item span,
.public-card span {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.proof-item strong,
.proof-item p,
.public-card strong,
.public-card small,
.public-card b {
  display: block;
}

.proof-item strong {
  margin-top: 4px;
}

.proof-item p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.payment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
}

.payment-row span {
  color: var(--muted);
  text-transform: uppercase;
}

.payment-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

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

.import-console p,
.public-status p {
  max-width: 720px;
  color: var(--muted);
  line-height: 1.5;
}

.import-console pre {
  grid-column: 1 / -1;
  overflow: auto;
  min-height: 220px;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--ink);
}

.public-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.public-card strong {
  margin-top: 8px;
  line-height: 1.2;
}

.public-card small {
  margin-top: 5px;
  color: var(--muted);
}

.public-card b {
  margin-top: 9px;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--paper);
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

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

@media (max-width: 1380px) {
  .operations-layout {
    grid-template-columns: minmax(280px, 0.9fr) minmax(440px, 1.2fr);
  }

  .inspector {
    position: static;
    grid-column: 1 / -1;
  }

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

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

  .rail {
    position: static;
    height: auto;
    padding: 16px;
  }

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

  .tab {
    text-align: center;
  }

  .rail-note {
    margin-top: 0;
  }

  .workspace {
    padding: 16px;
  }

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

  .status-strip,
  .search-box {
    min-width: 0;
    width: 100%;
  }

  .metric-band,
  .operations-layout,
  .split,
  .public-grid {
    grid-template-columns: 1fr;
  }

  .metric-band > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-band > div:last-child {
    border-bottom: 0;
  }

  .board {
    overflow-x: auto;
  }

  .calendar-head,
  .lane-row {
    min-width: 560px;
  }

  .tabs {
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 32px;
  }

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

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

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

