:root {
  --paper: #f7f4ec;
  --paper-strong: #fffdf7;
  --ink: #17211f;
  --muted: #63716c;
  --line: #d9d2c2;
  --green: #2f6b4f;
  --green-strong: #184d37;
  --mint: #dfeee0;
  --blue: #446f93;
  --rust: #a85e35;
  --yellow: #f0c865;
  --shadow: 0 24px 70px rgba(45, 56, 48, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(247, 244, 236, 0.94), rgba(247, 244, 236, 1)),
    radial-gradient(circle at 20% 0%, rgba(240, 200, 101, 0.22), transparent 30%),
    radial-gradient(circle at 90% 10%, rgba(68, 111, 147, 0.16), transparent 28%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar,
.command-strip,
.planner-panel,
.route-stage,
.checkout-panel,
.ops-board {
  border: 1px solid rgba(23, 33, 31, 0.1);
  background: rgba(255, 253, 247, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 14px 16px;
  border-radius: 8px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--green), #6e9c76 50%, var(--yellow) 51%),
    var(--green);
  position: relative;
  flex: 0 0 auto;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  bottom: 8px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--paper-strong);
  border-radius: 50%;
}

.brand-mark::before {
  left: 8px;
}

.brand-mark::after {
  right: 8px;
}

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

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.topnav a:hover {
  background: rgba(47, 107, 79, 0.08);
  color: var(--green-strong);
}

.ghost-button,
.primary-button,
.secondary-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 700;
}

.ghost-button {
  padding: 0 14px;
  color: var(--green-strong);
  background: rgba(47, 107, 79, 0.1);
}

.primary-button {
  width: 100%;
  color: #fff;
  background: var(--green-strong);
  box-shadow: 0 14px 30px rgba(24, 77, 55, 0.26);
}

.secondary-button {
  width: 100%;
  color: var(--green-strong);
  background: var(--mint);
}

.button-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
}

.grid-icon {
  border: 2px solid currentColor;
}

.grid-icon::before,
.grid-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
}

.grid-icon::before {
  width: 2px;
  height: 100%;
  left: 5px;
  top: 0;
}

.grid-icon::after {
  width: 100%;
  height: 2px;
  top: 5px;
  left: 0;
}

.route-icon {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.route-icon::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 12px;
  height: 2px;
  background: currentColor;
  transform: rotate(-30deg);
  transform-origin: left center;
}

.copy-icon {
  border: 2px solid currentColor;
  border-radius: 3px;
}

.copy-icon::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 3px;
  left: -5px;
  top: 4px;
  background: transparent;
}

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

.command-strip div {
  min-height: 82px;
  padding: 16px;
  background: rgba(255, 253, 247, 0.72);
}

.command-strip span,
.eyebrow,
.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.command-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 330px;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.planner-panel,
.route-stage,
.checkout-panel,
.ops-board {
  border-radius: 8px;
}

.planner-panel,
.checkout-panel {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.route-stage {
  min-height: 760px;
  padding: 18px;
}

.panel-head h1,
.panel-head h2,
.stage-head h2,
.section-title h2 {
  margin: 6px 0 0;
  line-height: 1.12;
  letter-spacing: 0;
}

.panel-head h1 {
  font-size: 31px;
}

.panel-head h2,
.stage-head h2,
.section-title h2 {
  font-size: 24px;
}

.compact h2 {
  font-size: 22px;
}

.control-group {
  margin-top: 22px;
}

.control-group > label,
.form-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(23, 33, 31, 0.09);
  border-radius: 8px;
  background: rgba(23, 33, 31, 0.04);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  color: #fff;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(47, 107, 79, 0.22);
}

.segmented.vertical {
  grid-template-columns: 1fr;
}

.segmented.vertical button {
  min-height: 64px;
  padding: 10px 12px;
  text-align: left;
}

.segmented.vertical span,
.segmented.vertical small {
  display: block;
}

.segmented.vertical small {
  margin-top: 4px;
  color: inherit;
  opacity: 0.72;
  font-size: 12px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(23, 33, 31, 0.14);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
}

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

.addons label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(23, 33, 31, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.addons strong {
  color: var(--rust);
}

.primary-button {
  margin-top: 22px;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.risk-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--green-strong);
  background: var(--mint);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.map-shell {
  position: relative;
  margin-top: 16px;
  height: 420px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-radius: 8px;
  background: #d7e6d7;
}

.map-asset,
#routeMap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-asset {
  object-fit: cover;
}

.route-line {
  fill: none;
  stroke: #163d2d;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-stop {
  fill: #fffdf7;
  stroke: #163d2d;
  stroke-width: 4;
}

.route-stop-label {
  fill: #17211f;
  font-size: 13px;
  font-weight: 800;
  paint-order: stroke;
  stroke: rgba(255, 253, 247, 0.86);
  stroke-width: 6px;
}

.map-status {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  color: #fff;
  background: rgba(23, 33, 31, 0.72);
}

.map-status span {
  color: rgba(255, 255, 255, 0.78);
}

.route-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.route-stats div,
.route-card,
.vehicle-card,
.price-box,
.assurance-list,
.ops-grid article {
  border: 1px solid rgba(23, 33, 31, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.route-stats div {
  min-height: 76px;
  padding: 13px;
}

.route-stats span,
.price-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.route-stats strong {
  display: block;
  margin-top: 8px;
  font-size: 23px;
}

.route-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.route-card {
  min-height: 214px;
  padding: 14px;
  text-align: left;
  border-color: rgba(23, 33, 31, 0.1);
}

.route-card.active {
  border-color: rgba(47, 107, 79, 0.72);
  box-shadow: 0 16px 34px rgba(47, 107, 79, 0.16);
}

.route-card button {
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.route-card h3 {
  margin: 9px 0 8px;
  font-size: 18px;
}

.route-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.card-tags span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--green-strong);
  background: rgba(47, 107, 79, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.vehicle-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 12px;
}

.vehicle-card h3,
.vehicle-card p {
  margin: 5px 0 0;
}

.vehicle-card p {
  color: var(--muted);
  line-height: 1.45;
}

.vehicle-visual {
  position: relative;
  height: 74px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(47, 107, 79, 0.13), rgba(168, 94, 53, 0.13));
}

.wheel {
  position: absolute;
  bottom: 12px;
  width: 24px;
  height: 24px;
  border: 3px solid var(--ink);
  border-radius: 50%;
}

.rear {
  left: 16px;
}

.front {
  right: 14px;
}

.bike-frame {
  position: absolute;
  left: 31px;
  right: 29px;
  bottom: 28px;
  height: 3px;
  background: var(--ink);
  transform: skewY(-18deg);
}

.bike-frame::before,
.bike-frame::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 3px;
  background: var(--ink);
  transform-origin: left center;
}

.bike-frame::before {
  left: 10px;
  top: -12px;
  transform: rotate(48deg);
}

.bike-frame::after {
  right: 0;
  top: -10px;
  transform: rotate(-54deg);
}

.price-box {
  display: grid;
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  background: rgba(23, 33, 31, 0.08);
}

.price-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.68);
}

.price-box strong {
  font-size: 18px;
}

.price-box .total {
  background: var(--green-strong);
  color: #fff;
}

.price-box .total span {
  color: rgba(255, 255, 255, 0.72);
}

.assurance-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
}

.assurance-list div {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.assurance-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--rust);
}

.secondary-button {
  margin-top: 14px;
}

.plan-status {
  min-height: 42px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.ops-board {
  margin-top: 16px;
  padding: 22px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.section-title h2 {
  max-width: 720px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.ops-grid article {
  min-height: 160px;
  padding: 16px;
}

.ops-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 31px;
}

.ops-grid p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

body.supplier-view .checkout-panel {
  border-color: rgba(168, 94, 53, 0.36);
}

body.supplier-view .risk-pill {
  color: #fff;
  background: var(--rust);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

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

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

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 760px);
    padding-top: 10px;
  }

  .topbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .topnav a {
    justify-content: center;
  }

  .command-strip,
  .workspace,
  .route-stats,
  .route-list,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .planner-panel,
  .route-stage {
    position: static;
  }

  .panel-head h1 {
    font-size: 28px;
  }

  .map-shell {
    height: 330px;
  }

  .map-status {
    align-items: start;
    flex-direction: column;
  }

  .form-grid,
  .vehicle-card {
    grid-template-columns: 1fr;
  }
}
