:root {
  --ink: #18221e;
  --muted: #6d756f;
  --soft: #9ca49e;
  --paper: #faf7ef;
  --panel: #fffdf8;
  --panel-2: #fbf5e9;
  --line: #ded5c3;
  --line-soft: #eee6d8;
  --green: #0e614e;
  --green-2: #168066;
  --green-soft: #e7f2ee;
  --red: #d84c49;
  --red-soft: #fff0ed;
  --gold: #c9a564;
  --gold-soft: #fbf1dc;
  --blue: #2e6488;
  --shadow: 0 20px 48px rgba(54, 44, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(34, 48, 42, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 48, 42, 0.026) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.86), transparent 34%),
    var(--paper);
  background-size: 26px 26px, 26px 26px, auto, auto;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid rgba(14, 97, 78, 0.54);
  border-radius: 8px;
  padding: 0 15px;
  color: var(--green);
  background: #fffef9;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 8px 18px rgba(14, 97, 78, 0.1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.primary {
  color: #fffdf7;
  border-color: var(--green);
  background: linear-gradient(180deg, var(--green-2), var(--green));
  box-shadow: 0 12px 22px rgba(14, 97, 78, 0.18);
}

.primary:hover {
  color: #fffdf7;
  background: linear-gradient(180deg, #197b64, #0b5645);
}

.ghost {
  color: var(--green);
  border-color: rgba(14, 97, 78, 0.36);
}

.shell {
  width: calc(100% - 28px);
  max-width: 1780px;
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  min-height: 62px;
  margin-bottom: 14px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.86);
}

.tab-button {
  min-height: 38px;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.tab-button:hover {
  box-shadow: none;
}

.tab-button.active {
  color: #fffdf7;
  border-color: var(--green);
  background: var(--green);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
}

.tab-panel:not(.active) {
  display: none !important;
}

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

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

h1 {
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.08;
  font-weight: 900;
}

h2 {
  font-size: 20px;
  font-weight: 900;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.editor {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.ledger {
  min-width: 0;
  padding: 22px;
}

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

.subtle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid #e0d1b5;
  border-radius: 8px;
  color: #6d5d3b;
  background: #fff8e7;
}

.status.error {
  color: var(--red);
  border-color: rgba(216, 76, 73, 0.36);
  background: var(--red-soft);
}

label {
  display: grid;
  gap: 8px;
  color: #657169;
  font-size: 13px;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d9cdb9;
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fffef9;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d9cdb9;
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: #fffef9;
}

textarea {
  width: 100%;
  border: 1px solid #d9cdb9;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fffef9;
  resize: vertical;
  font: inherit;
  line-height: 1.55;
}

textarea:focus {
  outline: 3px solid rgba(201, 165, 100, 0.22);
  border-color: var(--gold);
}

input:focus {
  outline: 3px solid rgba(201, 165, 100, 0.22);
  border-color: var(--gold);
}

select:focus {
  outline: 3px solid rgba(201, 165, 100, 0.22);
  border-color: var(--gold);
}

input[readonly] {
  color: #59635d;
  background: #f6f2e9;
}

.two-col,
.search-row,
.actions,
.toolbar {
  display: flex;
  gap: 10px;
}

.two-col > * {
  flex: 1;
}

.search-row input {
  flex: 1;
}

.search-row button {
  min-width: 76px;
}

.candidates {
  display: grid;
  gap: 0;
  max-height: 286px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.candidates:empty {
  display: none;
}

.candidate {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 56px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  text-align: left;
  color: var(--ink);
  background: transparent;
}

.candidate:last-child {
  border-bottom: 0;
}

.candidate:hover {
  box-shadow: none;
  background: #f4fbf7;
}

.candidate i {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green-2);
  font-style: normal;
  font-size: 13px;
  line-height: 1;
}

.candidate strong,
.candidate span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate strong {
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 900;
}

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

.route-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid #dcccae;
  border-radius: 9px;
  background: linear-gradient(180deg, #fff9ec, #fffdf8);
}

.route-card-head {
  display: grid;
  gap: 11px;
}

.route-card span,
.summary-grid span,
.price-strip span,
.stops-list > span,
.segment-list > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.route-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.stop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.active-mode {
  color: #fffdf7;
  border-color: var(--blue);
  background: var(--blue);
}

.stops-list {
  position: relative;
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px dashed #cbb78e;
  border-radius: 9px;
  background: rgba(255, 253, 248, 0.74);
}

.stops-list::before {
  content: "";
  position: absolute;
  top: 50px;
  bottom: 42px;
  left: 31px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, rgba(14, 97, 78, 0.64), rgba(14, 97, 78, 0.64) 7px, transparent 7px, transparent 13px);
}

.stops-list p,
.route-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.route-hint {
  padding-left: 54px;
}

.stop-item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 46px;
  padding: 8px 9px;
  border: 1px solid rgba(222, 213, 195, 0.86);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
}

.stop-item.origin {
  background: var(--green-soft);
}

.stop-item.destination {
  border-color: rgba(216, 76, 73, 0.24);
  background: var(--red-soft);
}

.stop-item b {
  display: grid;
  width: 34px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(14, 97, 78, 0.36);
  border-radius: 7px;
  color: var(--green);
  background: #fffef9;
  font-size: 12px;
  font-weight: 900;
}

.stop-item.destination b {
  color: var(--red);
  border-color: rgba(216, 76, 73, 0.38);
}

.stop-item strong,
.stop-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-item strong {
  font-size: 13px;
  font-weight: 900;
}

.stop-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.stop-item button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--red);
  border-color: rgba(216, 76, 73, 0.38);
  background: #fffdfa;
}

.route-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.route-metrics > div {
  min-height: 66px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
}

.route-metrics strong {
  font-size: 20px;
}

.segment-list {
  display: grid;
  gap: 7px;
}

.segment-list:empty {
  display: none;
}

.segment-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fffef9;
}

.segment-item b {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #fffdf7;
  background: var(--green);
  font-size: 12px;
}

.segment-item span {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment-item strong {
  color: var(--blue);
  white-space: nowrap;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}

.summary-grid > div {
  min-height: 84px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, #fffdf9, #fcf6eb);
}

.summary-grid strong {
  font-size: 24px;
  line-height: 1.2;
}

.table-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--panel);
}

th,
td {
  padding: 10px 8px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #143f35;
  background: #f3ead8;
  font-size: 12px;
  font-weight: 900;
}

td {
  color: #39423d;
  font-size: 12px;
  line-height: 1.42;
}

.excel-title {
  position: static;
  padding: 18px 8px;
  color: var(--ink);
  background: #fffdf8;
  font-size: 20px;
  text-align: center;
}

tr:last-child td {
  border-bottom: 0;
}

.delete-btn {
  min-height: 30px;
  padding: 0 9px;
  color: var(--red);
  border-color: rgba(216, 76, 73, 0.38);
}

.total-row td {
  color: var(--ink);
  font-weight: 900;
  background: #f8efd9;
}

.empty-row td {
  height: 110px;
  color: var(--muted);
  text-align: center;
}

.screen-only {
  text-align: center;
}

.excel-preview th:nth-child(1),
.excel-preview td:nth-child(1) {
  width: 42px;
  text-align: center;
}

.excel-preview th:nth-child(2),
.excel-preview td:nth-child(2) {
  width: 82px;
}

.excel-preview th:nth-child(3),
.excel-preview td:nth-child(3) {
  width: 150px;
}

.excel-preview th:nth-child(4),
.excel-preview td:nth-child(4) {
  width: auto;
}

.excel-preview th:nth-child(5),
.excel-preview td:nth-child(5),
.excel-preview th:nth-child(6),
.excel-preview td:nth-child(6),
.excel-preview th:nth-child(7),
.excel-preview td:nth-child(7),
.excel-preview th:nth-child(8),
.excel-preview td:nth-child(8),
.excel-preview th:nth-child(9),
.excel-preview td:nth-child(9) {
  width: 76px;
  text-align: center;
}

.excel-preview th:nth-child(10),
.excel-preview td:nth-child(10) {
  width: 58px;
}

.price-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.price-pill {
  min-width: 156px;
  padding: 9px 11px;
  border: 1px solid #dbc99d;
  border-radius: 8px;
  background: #fff7e2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 38, 34, 0.34);
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  display: grid;
  gap: 16px;
  width: min(920px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(24, 34, 30, 0.28);
}

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

.auto-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.check-line input {
  width: auto;
  min-height: 0;
}

.auto-result {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #dcccae;
  border-radius: 8px;
  color: #6d5d3b;
  background: #fff8e7;
  white-space: pre-wrap;
}

.modal-actions {
  justify-content: flex-end;
}

.compact-title {
  align-items: end;
}

.compact-title h2 {
  font-size: 17px;
}

.pool-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
}

.pool-candidates,
.destination-pool-list {
  display: grid;
  gap: 8px;
}

.pool-candidates:empty {
  display: none;
}

.pool-candidate,
.pool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fffef9;
}

.pool-candidate strong,
.pool-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.pool-candidate span,
.pool-row span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-row.disabled {
  opacity: 0.58;
}

.pool-row-actions {
  display: flex;
  gap: 6px;
}

.pool-row-actions button,
.pool-candidate button {
  min-height: 32px;
  padding: 0 10px;
}

.fuel-panel {
  gap: 14px;
  padding: 22px;
}

.fuel-summary {
  margin: 0;
}

.fuel-actions {
  display: flex;
  justify-content: flex-start;
}

.fuel-status {
  min-height: 40px;
  padding: 10px 13px;
  border: 1px solid #d8e0cf;
  border-radius: 8px;
  color: var(--green);
  background: #f5f9ef;
  font-size: 13px;
}

.fuel-status.error {
  color: var(--red);
  border-color: rgba(216, 76, 73, 0.36);
  background: var(--red-soft);
}

.fuel-table-wrap {
  overflow-x: hidden;
}

.fuel-detail-table {
  table-layout: fixed;
}

.fuel-detail-table th:nth-child(1),
.fuel-detail-table td:nth-child(1) {
  width: 54px;
  text-align: center;
}

.fuel-detail-table th:nth-child(2),
.fuel-detail-table td:nth-child(2) {
  width: 150px;
}

.fuel-detail-table th:nth-child(3),
.fuel-detail-table td:nth-child(3),
.fuel-detail-table th:nth-child(4),
.fuel-detail-table td:nth-child(4) {
  width: 180px;
}

.fuel-detail-table th:nth-child(5),
.fuel-detail-table td:nth-child(5),
.fuel-detail-table th:nth-child(6),
.fuel-detail-table td:nth-child(6),
.fuel-detail-table th:nth-child(7),
.fuel-detail-table td:nth-child(7) {
  width: 130px;
}

.fuel-detail-table th:nth-child(8),
.fuel-detail-table td:nth-child(8) {
  width: 88px;
  text-align: center;
}

.fuel-detail-table input {
  min-height: 36px;
  padding: 7px 9px;
}

@media (max-width: 1100px) {
  .shell {
    width: min(100% - 24px, 860px);
    padding: 18px 0;
  }

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

  .section-title {
    align-items: start;
    flex-direction: column;
  }
}
