:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #18202a;
  background: #edf1f4;
  font-synthesis: none;
  --red: #d71920;
  --red-dark: #aa1016;
  --ink: #18202a;
  --muted: #6f7a86;
  --line: #dfe5e9;
  --panel: #ffffff;
  --green: #19a463;
  --yellow: #e7a516;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; min-width: 320px; min-height: 100%; }

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { height: 100vh; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

.topbar {
  height: 76px;
  padding: 12px 22px;
  background: #151a20;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 18px rgb(0 0 0 / 16%);
  z-index: 20;
  flex: 0 0 auto;
}

.topbar h1, .dialog-heading h2 { margin: 2px 0 0; font-size: 22px; letter-spacing: .02em; }
.eyebrow { margin: 0; color: #f06a6f; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.live-status { min-width: 170px; text-align: right; }
.live-status strong { display: block; color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.live-status span { display: block; margin-top: 2px; color: #9da7b0; font-size: 10px; }

.traffic-switch {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #d8dde1;
  font-size: 13px;
  cursor: pointer;
}
.traffic-switch input { accent-color: var(--red); }

.button {
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, opacity .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .58; transform: none; }
.button-primary { background: var(--red); color: #fff; }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { color: #fff; background: #303841; border: 1px solid #434d57; }
.button-ghost { background: transparent; color: var(--muted); }

.workspace { min-height: 0; overflow: hidden; flex: 1; display: grid; grid-template-columns: 420px 1fr; }
.sidebar { min-height: 0; height: 100%; overflow: hidden; background: #f5f7f8; border-right: 1px solid var(--line); display: flex; flex-direction: column; }

.origin-card { padding: 18px 20px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.origin-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.origin-settings-button { border: 0; background: transparent; color: var(--red); font-size: 11px; font-weight: 800; cursor: pointer; }
.section-label { color: #8b959f; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.origin-row { margin-top: 10px; display: flex; align-items: flex-start; gap: 11px; }
.origin-row strong { font-size: 15px; }
.origin-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.origin-dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--red); border: 3px solid #ffd6d7; box-shadow: 0 0 0 2px var(--red); flex: 0 0 auto; }

.summary-grid { padding: 12px 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-bottom: 1px solid var(--line); }
.summary-card, .summary-grid article { background: #fff; border: 1px solid #e7ebee; border-radius: 8px; padding: 9px 11px; text-align: left; }
.summary-grid span { display: block; color: var(--muted); font-size: 10px; }
.summary-grid strong { display: block; margin-top: 3px; font-size: 18px; font-variant-numeric: tabular-nums; }
#updatedAt { font-size: 10px; line-height: 1.35; white-space: nowrap; }
.summary-card-button { font: inherit; cursor: pointer; transition: border-color .16s, background .16s, transform .16s; }
.summary-card-button:hover { border-color: #eea5a8; transform: translateY(-1px); }
.summary-card-button.is-active { border-color: var(--red); background: #fff1f1; box-shadow: inset 0 0 0 1px rgb(215 25 32 / 12%); }
.summary-card-button.is-active span::after { content: " · 已置顶"; color: var(--red); }
.danger-text { color: var(--red); }

.route-section { min-height: 0; overflow: hidden; flex: 1; padding: 14px 12px 12px 20px; display: flex; flex-direction: column; }
.route-management { margin: 0 8px 8px 0; display: flex; justify-content: flex-end; }
.button-danger-outline { padding: 7px 12px; border: 1px solid #e9a0a3; background: #fff; color: #b7191f; }
.button-danger-outline:hover, .button-danger-outline.is-active { border-color: var(--red); background: #fff1f1; }
.branch-search { margin: 0 8px 12px 0; padding: 11px; border: 1px solid #e0e5e8; border-radius: 10px; background: #fff; position: relative; }
.branch-search > label { display: block; margin-bottom: 7px; color: #59636d; font-size: 11px; font-weight: 800; }
.branch-search-row { display: flex; gap: 7px; }
.branch-search-row input { min-width: 0; flex: 1; border: 1px solid #d8dee2; border-radius: 7px; padding: 8px 9px; outline: none; font-size: 11px; }
.branch-search-row input:focus { border-color: #e25e62; box-shadow: 0 0 0 3px rgb(215 25 32 / 8%); }
.branch-search-row .button { padding: 8px 12px; }
.branch-search-results { position: absolute; top: calc(100% - 5px); left: 10px; right: 10px; z-index: 80; max-height: 260px; overflow: auto; border: 1px solid #dce2e6; border-radius: 9px; background: #fff; box-shadow: 0 12px 28px rgb(20 28 35 / 18%); }
.branch-search-result { width: 100%; padding: 10px 11px; border: 0; border-bottom: 1px solid #edf0f2; background: #fff; text-align: left; cursor: pointer; }
.branch-search-result:last-child { border-bottom: 0; }
.branch-search-result:hover { background: #fff5f5; }
.branch-search-result strong { display: block; color: #222b34; font-size: 12px; }
.branch-search-result span { display: block; margin-top: 3px; color: #7a858f; font-size: 10px; line-height: 1.4; }
.branch-search-message { padding: 13px; color: #747f89; font-size: 11px; text-align: center; }
.route-heading { padding: 0 8px 10px 0; display: flex; align-items: flex-end; justify-content: space-between; }
.route-heading h2 { margin: 3px 0 0; font-size: 17px; }
.route-heading-status { max-width: 185px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.progress-text { color: var(--muted); font-size: 11px; }
.truck-warning-summary { max-width: 185px; overflow: hidden; padding: 3px 7px; border-radius: 999px; background: #eef1f3; color: #6f7983; font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.truck-warning-summary.has-warning { background: #ffe1e2; color: #b7191f; }
.route-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; padding-right: 8px; display: flex; flex-direction: column; gap: 8px; }

.route-card { flex: 0 0 auto; background: #fff; border: 1px solid #e2e7ea; border-radius: 10px; overflow: hidden; transition: border .18s, box-shadow .18s; }
.route-card:hover, .route-card.is-selected { border-color: #f09da0; box-shadow: 0 5px 18px rgb(42 50 58 / 9%); }
.route-card.is-selected { box-shadow: inset 3px 0 0 var(--red), 0 5px 18px rgb(42 50 58 / 9%); }
.route-card.is-congested-priority { border-color: #e9696d; }
.route-card.has-truck-risk { border-color: #db7b28; box-shadow: inset 3px 0 0 #db7b28; }
.route-card-main { width: 100%; border: 0; background: transparent; text-align: left; padding: 12px; display: flex; gap: 11px; cursor: pointer; }
.route-index { width: 27px; height: 27px; border-radius: 7px; background: #f3f5f6; color: #6c7680; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: 0 0 auto; }
.route-copy { min-width: 0; flex: 1; }
.route-title-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.route-title { font-size: 14px; }
.status-pill { padding: 3px 7px; border-radius: 999px; background: #eef1f3; color: #7f8993; font-size: 10px; font-style: normal; font-weight: 800; white-space: nowrap; }
.status-pill.is-clear { color: #087d47; background: #dff7eb; }
.status-pill.is-slow { color: #966300; background: #fff2cb; }
.status-pill.is-congested { color: #b7191f; background: #ffe1e2; }
.status-pill.is-error { color: #69727c; background: #eceff1; }
.route-poi { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.route-truck-warning { display: block; overflow: hidden; margin-top: 5px; color: #b04b00; font-size: 10px; font-weight: 800; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.route-truck-warning[hidden] { display: none; }
.route-congestion-insight { display: block; margin-top: 5px; padding: 6px 7px; border-radius: 6px; background: #fff2e2; color: #9a3d00; font-size: 10px; font-weight: 700; line-height: 1.4; }
.route-congestion-insight[hidden] { display: none; }
.route-metrics { margin-top: 8px; display: flex; gap: 12px; color: #424b54; font-size: 11px; font-weight: 700; }
.route-options { display: none; margin: 0 12px 10px; padding: 10px; border: 1px solid #f0d6a2; border-radius: 9px; background: #fffbef; }
.route-card.is-selected .route-options:not([hidden]) { display: block; }
.route-options-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.route-options-heading strong { color: #533f13; font-size: 12px; }
.route-options-heading span { color: #8a7441; font-size: 9px; }
.route-option-list { display: grid; gap: 6px; }
.route-option { width: 100%; display: grid; grid-template-columns: minmax(70px, auto) 1fr; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid #e4e0d7; border-radius: 7px; background: #fff; color: #31383f; text-align: left; cursor: pointer; }
.route-option:hover { border-color: #e25e62; }
.route-option.is-selected { border-color: var(--red); box-shadow: inset 3px 0 0 var(--red); }
.route-option-label { font-size: 11px; font-weight: 900; }
.route-option.is-recommended .route-option-label { color: var(--red); }
.route-option-detail { color: #68727c; font-size: 10px; line-height: 1.45; }
.route-option-empty { color: #7d6b42; font-size: 10px; line-height: 1.5; }
.route-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 7px 12px; border-top: 1px solid #edf0f2; background: #fafbfb; }
.detail-button, .remove-button, .nav-link { border: 0; background: transparent; padding: 2px 0; color: #68727d; font-size: 11px; font-weight: 700; cursor: pointer; text-decoration: none; }
.remove-button { margin-right: auto; color: #9a5b5e; }
.nav-link { color: var(--red); }
.nav-link.is-disabled { color: #afb6bd; pointer-events: none; }

.map-wrap { min-width: 0; min-height: 0; height: 100%; overflow: hidden; position: relative; background: #dde3e7; }
.map { position: absolute; inset: 0; }
.empty-map { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px; background: radial-gradient(circle at 50% 43%, #f9fbfc 0, #e8edf0 46%, #dce3e7 100%); z-index: 5; }
.empty-map[hidden] { display: none; }
.empty-map-icon { width: 58px; height: 58px; border-radius: 18px; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 900; box-shadow: 0 12px 30px rgb(215 25 32 / 24%); }
.empty-map h2 { margin: 18px 0 4px; font-size: 20px; }
.empty-map p { margin: 0 0 17px; color: var(--muted); font-size: 13px; }
.legend { position: absolute; right: 16px; bottom: 18px; z-index: 10; padding: 9px 12px; border-radius: 8px; background: rgb(255 255 255 / 92%); box-shadow: 0 4px 14px rgb(21 29 36 / 14%); display: flex; gap: 12px; font-size: 10px; color: #59636d; }
.legend span { display: flex; align-items: center; gap: 4px; }
.legend i { width: 15px; height: 4px; border-radius: 4px; }
.legend-green { background: #22c55e; }
.legend-yellow { background: #f59e0b; }
.legend-red { background: #ef4444; }
.legend-darkred { background: #7f1d1d; }
.map-notice { position: absolute; top: 15px; left: 50%; transform: translateX(-50%); z-index: 30; max-width: min(600px, 85%); padding: 10px 14px; border-radius: 8px; color: #fff; background: rgb(24 32 42 / 88%); font-size: 12px; box-shadow: 0 7px 22px rgb(0 0 0 / 18%); }

.settings-dialog { width: min(520px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 24px 70px rgb(0 0 0 / 28%); }
.settings-dialog::backdrop { background: rgb(12 16 20 / 58%); backdrop-filter: blur(3px); }
.settings-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { color: var(--ink); }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #f0f2f4; color: #66707a; font-size: 24px; line-height: 1; cursor: pointer; }
.dialog-description { color: var(--muted); font-size: 12px; line-height: 1.65; }
.managed-credential-notice { margin-top: 13px; padding: 10px 12px; border-radius: 8px; background: #e9f7ef; color: #167445; font-size: 11px; font-weight: 700; line-height: 1.5; }
.settings-dialog label { display: block; margin-top: 13px; }
.settings-dialog label span { display: block; margin-bottom: 6px; color: #4f5964; font-size: 12px; font-weight: 700; }
.field-help { display: block; margin-top: 5px; color: #8a949e; font-size: 10px; line-height: 1.45; }
.settings-dialog input { width: 100%; border: 1px solid #d8dee2; border-radius: 8px; padding: 10px 11px; outline: none; }
.settings-dialog input:focus { border-color: #e25e62; box-shadow: 0 0 0 3px rgb(215 25 32 / 9%); }
.dialog-tip { margin-top: 15px; padding: 10px 12px; background: #fff5df; border-radius: 8px; color: #7e6222; font-size: 11px; line-height: 1.55; }
.dialog-actions { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; }

.amap-marker-label { border: 0 !important; background: transparent !important; }
.map-marker { min-width: 28px; height: 28px; padding: 0 8px; border: 2px solid #20262d; border-radius: 14px; background: #fff; color: #000; display: grid; place-items: center; font-size: 10px; font-weight: 900; text-shadow: none; box-shadow: 0 3px 10px rgb(0 0 0 / 30%); }
.map-marker.origin { border-color: #fff; background: var(--red); color: #fff; }
.map-marker.selected { border-color: #1769aa; background: #fff4b8; color: #000; transform: scale(1.12); box-shadow: 0 4px 14px rgb(0 0 0 / 38%); }
.congestion-map-marker { max-width: 110px; overflow: hidden; padding: 5px 8px; border: 1px solid #fff; border-radius: 12px; background: #d71920; color: #fff; font-size: 10px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 3px 10px rgb(0 0 0 / 35%); cursor: pointer; }
.traffic-info-window { min-width: 210px; max-width: 310px; padding: 3px 2px; color: #26313b; font-size: 12px; line-height: 1.5; }
.traffic-info-window strong { display: block; color: #b7191f; font-size: 14px; }
.traffic-info-window p { margin: 5px 0 0; }
.traffic-info-window small { display: block; margin-top: 7px; color: #77818a; }

@media (max-width: 900px) {
  .topbar { height: auto; align-items: flex-start; }
  .traffic-switch { display: none; }
  .workspace { grid-template-columns: 360px 1fr; }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 14px; }
  .topbar { flex-wrap: wrap; }
  .topbar h1 { font-size: 17px; }
  .topbar-actions { gap: 6px; }
  .live-status { order: 3; width: 100%; min-width: 0; margin-top: 5px; text-align: left; }
  .topbar .button { padding: 8px 9px; font-size: 11px; }
  .workspace { display: flex; flex-direction: column-reverse; overflow: hidden; }
  .map-wrap { flex: 0 0 46%; min-height: 0; }
  .sidebar { min-height: 0; flex: 1; overflow: hidden; }
  .route-list { overflow-y: auto; }
  .legend { max-width: calc(100% - 24px); right: 12px; bottom: 12px; gap: 7px; }
}
