:root {
  --adm-blue: #003087;
  --adm-blue-2: #0057b8;
  --adm-green: #00843d;
  --ink: #14213d;
  --muted: #65738b;
  --line: #dbe3ee;
  --surface: #ffffff;
  --soft: #f4f7fb;
  --danger: #b42318;
  font-family: "Open Sans", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #f5f7fa; color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.state-screen {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--adm-blue);
  font-family: Montserrat, sans-serif;
}
.state-screen p { margin: 0; color: var(--muted); }
.state-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #dce6f5;
  border-top-color: var(--adm-blue);
  border-radius: 50%;
  animation: route-spin .8s linear infinite;
}
.state-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fee4e2;
  color: var(--danger);
  font: 900 22px Montserrat, sans-serif;
}
@keyframes route-spin { to { transform: rotate(360deg); } }

.route-app {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
}
.route-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.route-form-card, .map-card, .result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 36, 70, .07);
}
.route-form-card { padding: 22px; }
.card-heading, .map-toolbar, .results-heading, .panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--adm-green);
  font: 800 10px Montserrat, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}
h2, h3 { margin: 0; font-family: Montserrat, sans-serif; color: var(--adm-blue); }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
.card-heading { margin-bottom: 20px; }
.free-badge, .subtle-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 99px;
  padding: 0 10px;
  background: #eaf8f0;
  color: var(--adm-green);
  font: 800 10px Montserrat, sans-serif;
  white-space: nowrap;
}
.subtle-badge { background: #edf3fb; color: var(--adm-blue); }

.field-group, .route-form-card label { display: grid; gap: 6px; }
.field-group > label, .destinations-head > label, .route-form-card label > span {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}
.location-field { position: relative; }
.location-field input, .route-form-card select, .route-form-card input[type="number"], .cost-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd9e7;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  transition: border-color .16s, box-shadow .16s;
}
.location-field input { padding: 0 38px 0 34px; }
.location-field input:focus, .route-form-card select:focus, .route-form-card input[type="number"]:focus, .cost-row input:focus {
  border-color: #5a8fd8;
  box-shadow: 0 0 0 3px rgba(0, 87, 184, .1);
}
.location-dot {
  position: absolute;
  left: 13px;
  top: 17px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--adm-blue);
  border-radius: 50%;
  z-index: 2;
}
.location-dot.origin { border-color: var(--adm-green); background: #fff; }
.location-dot.destination { border-color: var(--adm-blue); }
.clear-location {
  position: absolute;
  right: 8px;
  top: 7px;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: #8b98aa;
  font-size: 20px;
}
.location-suggestions {
  display: none;
  position: absolute;
  z-index: 1000;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 250px;
  overflow: auto;
  background: #fff;
  border: 1px solid #cfd9e7;
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(16, 36, 70, .18);
}
.location-suggestions.open { display: block; }
.suggestion-item {
  width: 100%;
  display: grid;
  gap: 2px;
  border: 0;
  border-bottom: 1px solid #edf1f6;
  background: #fff;
  padding: 10px 12px;
  text-align: left;
  color: var(--ink);
}
.suggestion-item:hover { background: #f1f6fd; }
.suggestion-item strong { font-size: 12px; }
.suggestion-item small { color: var(--muted); font-size: 10px; }
.suggestion-empty { padding: 12px; color: var(--muted); font-size: 11px; }

.destinations-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}
.text-action {
  border: 0;
  background: transparent;
  color: var(--adm-blue-2);
  padding: 3px;
  font-size: 11px;
  font-weight: 800;
}
.text-action:hover { text-decoration: underline; }
.field-help { margin: 3px 0 9px; color: var(--muted); font-size: 10px; }
.destinations-list { display: grid; gap: 8px; }
.destination-row {
  display: grid;
  grid-template-columns: 23px minmax(0, 1fr) 50px;
  align-items: center;
  gap: 7px;
}
.destination-import-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid #b9cae3;
  border-radius: 7px;
  background: #edf3fb;
  color: var(--adm-blue);
  cursor: pointer;
}
.destination-import-button:hover { background: #dfeafb; }
.destination-import-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.origin-field-row { display:grid; grid-template-columns:minmax(0,1fr) 36px; gap:7px; align-items:center; }
.destination-handle {
  border: 0;
  padding: 0;
  background: transparent;
  color: #8a96a8;
  font-size: 16px;
  cursor: grab;
}
.destination-row.dragging { opacity: .48; }
.destination-order-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.destination-order-actions button {
  width: 23px;
  height: 23px;
  border: 1px solid #d7e0eb;
  border-radius: 4px;
  background: #f8fafc;
  color: var(--adm-blue);
  line-height: 1;
}
.destination-order-actions .remove-destination {
  grid-column: 1 / 3;
  width: 48px;
  color: var(--danger);
}
.form-divider { height: 1px; background: #e7ecf3; margin: 20px 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.route-form-card select, .route-form-card input[type="number"] { padding: 0 10px; font-size: 12px; }
.input-suffix { position: relative; }
.input-suffix input { padding: 0 36px 0 10px !important; }
.input-suffix b { position: absolute; right: 12px; top: 12px; color: var(--muted); font-size: 12px; }
.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #f8fafc;
}
.switch-row span { display: grid; gap: 2px; }
.switch-row b { font-size: 12px; }
.switch-row small { color: var(--muted); font-size: 9px; font-weight: 600; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 22px;
  border-radius: 99px;
  background: #aeb8c7;
  transition: background .18s;
}
.switch-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform .18s;
}
.switch-row input:checked + i { background: var(--adm-green); }
.switch-row input:checked + i::after { transform: translateX(18px); }
.route-actions { display: grid; grid-template-columns: 1fr 90px; gap: 8px; margin-top: 18px; }
.primary-action, .secondary-action {
  min-height: 43px;
  border-radius: 7px;
  font-family: Montserrat, sans-serif;
  font-size: 12px;
  font-weight: 900;
}
.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--adm-blue);
  background: var(--adm-blue);
  color: #fff;
  box-shadow: 0 8px 16px rgba(0,48,135,.18);
}
.primary-action:hover { background: #00266d; }
.primary-action:disabled { cursor: wait; opacity: .65; }
.secondary-action { border: 1px solid #cbd6e5; background: #fff; color: var(--adm-blue); }
.search-icon { font-size: 19px; line-height: 1; }
.route-status { min-height: 18px; margin-top: 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.route-status.error { color: var(--danger); }
.route-status.success { color: var(--adm-green); }

.map-card { overflow: hidden; }
.map-toolbar { min-height: 74px; align-items: center; padding: 15px 18px; }
.map-legend { display: flex; gap: 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.map-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--adm-blue); }
.legend-dot.origin { background: var(--adm-green); }
#routeMap { width: 100%; height: 690px; background: #e8eef5; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.map-note { min-height: 34px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 15px; color: var(--muted); font-size: 9px; }
.leaflet-control-attribution { font-size: 8px !important; }
.route-number-marker {
  width: 28px !important;
  height: 28px !important;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--adm-blue);
  color: #fff;
  font: 900 11px Montserrat, sans-serif;
  box-shadow: 0 3px 9px rgba(0,0,0,.28);
}
.route-number-marker.origin { background: var(--adm-green); }

.route-results { margin-top: 24px; }
.results-heading { align-items: flex-end; margin-bottom: 14px; }
.results-heading p, .panel-title-row p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.result-time { color: var(--muted); font-size: 10px; }
.result-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.result-kpi {
  min-width: 0;
  min-height: 116px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid #9fb5d4;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(16, 36, 70, .05);
}
.result-kpi span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.result-kpi strong { color: var(--adm-blue); font: 900 20px Montserrat, sans-serif; white-space: nowrap; }
.result-kpi small { color: var(--muted); font-size: 9px; }
.result-kpi.featured { border-top-color: var(--adm-blue); background: #f4f8fe; }
.result-kpi.green { border-top-color: var(--adm-green); background: #f0faf5; }
.result-kpi.green strong { color: var(--adm-green); }
.result-columns { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; margin-top: 14px; }
.result-panel { padding: 18px; margin-top: 14px; }
.result-columns .result-panel { margin-top: 0; }
.itinerary-list { display: grid; gap: 0; margin: 18px 0 0; padding: 0; list-style: none; }
.itinerary-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
}
.itinerary-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 15px;
  top: 39px;
  bottom: -8px;
  width: 2px;
  background: #d9e2ef;
}
.itinerary-index {
  position: relative;
  z-index: 1;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--adm-blue);
  color: #fff;
  font: 900 11px Montserrat, sans-serif;
}
.itinerary-item:first-child .itinerary-index { background: var(--adm-green); }
.itinerary-label { min-width: 0; }
.itinerary-label b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.itinerary-label small, .itinerary-leg { color: var(--muted); font-size: 9px; }
.itinerary-leg { text-align: right; }
.antt-memory { display: grid; gap: 9px; margin-top: 16px; }
.memory-row { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 8px; border-bottom: 1px solid #edf1f5; font-size: 11px; }
.memory-row span { color: var(--muted); }
.memory-row b { text-align: right; color: var(--ink); }
.memory-formula { padding: 10px; border-radius: 6px; background: #f1f5fa; color: var(--adm-blue); font: 800 11px Montserrat, sans-serif; text-align: center; }
.memory-warning { padding: 12px; border-radius: 6px; background: #fff4e5; color: #8a4b08; font-size: 11px; font-weight: 700; }

.table-wrap { overflow-x: auto; margin-top: 15px; }
.toll-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.toll-table th { padding: 9px 10px; background: #f4f7fb; color: #526079; font-size: 9px; text-align: left; text-transform: uppercase; }
.toll-table td { padding: 11px 10px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
.toll-table .number { text-align: right; }
.toll-empty { color: var(--muted); text-align: center; padding: 20px !important; }
.tariff-missing { color: #9a6700; font-weight: 800; }
.additional-costs { display: grid; gap: 8px; margin-top: 13px; }
.cost-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 32px; gap: 8px; }
.cost-row input { min-height: 38px; padding: 0 10px; font-size: 11px; }
.remove-cost { border: 0; border-radius: 6px; background: #fff0ef; color: var(--danger); font-size: 18px; }
.cost-empty { color: var(--muted); font-size: 11px; }
.route-disclaimer { margin-top: 18px; padding: 13px 15px; border-left: 3px solid var(--adm-green); background: #eef4f9; color: #56647a; font-size: 10px; line-height: 1.6; }

@media (max-width: 1180px) {
  .route-workspace { grid-template-columns: 390px minmax(0, 1fr); }
  .result-kpis { grid-template-columns: repeat(3, 1fr); }
  #routeMap { height: 720px; }
}
@media (max-width: 900px) {
  .route-app { width: min(100% - 24px, 760px); padding-top: 16px; }
  .route-workspace, .result-columns { grid-template-columns: 1fr; }
  #routeMap { height: 480px; }
}
@media (max-width: 620px) {
  .route-app { width: min(100% - 16px, 560px); }
  .route-form-card { padding: 16px; }
  .field-grid, .result-kpis { grid-template-columns: 1fr 1fr; }
  .map-toolbar, .results-heading, .panel-title-row { flex-direction: column; align-items: flex-start; }
  .map-legend { flex-wrap: wrap; }
  #routeMap { height: 390px; }
  .result-kpi strong { font-size: 17px; }
  .cost-row { grid-template-columns: 1fr 110px 30px; }
}
@media (max-width: 430px) {
  .field-grid, .result-kpis { grid-template-columns: 1fr; }
  .route-actions { grid-template-columns: 1fr; }
  .destination-row { grid-template-columns: 18px minmax(0, 1fr) 48px; }
}


.route-modal { position:fixed; inset:0; z-index:5000; display:grid; place-items:start center; align-content:start; overflow:auto; padding:clamp(12px,3vh,28px) 24px 24px; }
.route-modal[hidden], .route-import-step[hidden], #routeImportEntry[hidden] { display:none; }
.route-modal-backdrop { position:absolute; inset:0; background:rgba(10,25,50,.62); backdrop-filter:blur(2px); }
.route-modal-card { position:relative; width:min(1180px,100%); max-height:min(760px,calc(100vh - 48px)); overflow:auto; background:#fff; border-radius:14px; box-shadow:0 28px 70px rgba(0,0,0,.3); padding:24px; }
.route-modal-header,.route-modal-footer,.route-import-toolbar { display:flex; align-items:center; justify-content:space-between; gap:14px; }
.route-modal-header { border-bottom:1px solid var(--line); padding-bottom:14px; }
.route-import-step { padding-top:2px; }
.modal-close { border:0; background:#edf3fb; color:var(--adm-blue); width:36px; height:36px; border-radius:50%; font-size:24px; }
.route-modal-help { color:var(--muted); font-size:13px; }
.route-import-text { width:100%; min-height:186px; resize:vertical; border:1px solid #cfd9e7; border-radius:9px; padding:12px; font:12px/1.5 Consolas,monospace; }
.route-import-toolbar { min-height:38px; margin:10px 0; }
.route-import-status { color:var(--muted); font-size:12px; }
.route-import-status.success { color:var(--success); }
.route-import-status.error { color:var(--danger); }
.import-table-wrap { overflow:auto; max-height:390px; border:1px solid var(--line); border-radius:9px; }
.paste-table-wrap { margin-top:4px; }
.import-table { width:100%; border-collapse:collapse; min-width:940px; font-size:11px; }
.import-table th { position:sticky; top:0; background:#edf3fb; color:var(--adm-blue); text-align:left; padding:9px; z-index:1; }
.import-table td { border-top:1px solid #e7edf5; padding:7px; vertical-align:middle; }
.import-table input:not([type="checkbox"]) { min-height:36px; border:1px solid #cfd9e7; border-radius:6px; padding:0 8px; width:100%; background:#fff; }
.paste-import-table th:nth-child(1) { width:42px; }
.paste-import-table th:nth-child(2) { width:130px; }
.paste-import-table th:nth-child(4) { width:150px; }
.paste-import-table th:nth-child(5) { width:70px; }
.paste-import-table th:nth-child(7) { width:110px; }
.paste-import-table th:nth-child(8) { width:44px; }
.import-state-input { text-transform:uppercase; }
.import-table .remove-import-row { border:0; background:#fee4e2; color:var(--danger); border-radius:6px; width:28px; height:28px; }
.review-summary-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin:18px 0 14px; }
.review-summary-card { min-height:66px; display:grid; align-content:center; gap:6px; padding:12px; border:1px solid var(--line); border-radius:9px; background:#f7f9fc; }
.review-summary-card span { color:var(--muted); font-size:9px; font-weight:800; text-transform:uppercase; }
.review-summary-card strong { color:var(--adm-blue); font-size:14px; }
.review-import-table { min-width:820px; }
.review-import-table th:nth-child(1) { width:42px; }
.review-import-table th:nth-child(2) { width:220px; }
.review-import-table th:nth-child(4) { width:90px; }
.review-import-table th:nth-child(5) { width:70px; text-align:center; }
.review-import-table td:last-child { text-align:center; }
.review-import-table td strong,.review-import-table td small { display:block; }
.review-import-table td small { color:var(--muted); margin-top:3px; }
.import-use-checkbox { width:18px; height:18px; accent-color:#039855; cursor:pointer; }
.review-help { margin:12px 0 0; }
.route-modal-footer { border-top:1px solid var(--line); margin-top:16px; padding-top:16px; justify-content:flex-end; }
.primary-button,.secondary-button { border-radius:7px; min-height:38px; padding:0 15px; font-weight:800; border:1px solid var(--adm-blue); }
.primary-button { background:var(--adm-blue); color:#fff; }
.primary-button:disabled { opacity:.5; cursor:not-allowed; }
.secondary-button { background:#fff; color:var(--adm-blue); }
@media (max-width:700px){
  .route-modal{padding:8px}
  .route-modal-card{max-height:calc(100vh - 16px);padding:15px}
  .review-summary-grid{grid-template-columns:1fr 1fr}
  .destination-row{grid-template-columns:18px minmax(0,1fr) 50px}
  .origin-field-row{grid-template-columns:minmax(0,1fr) 34px}
  .destination-import-button{width:34px;height:34px}
}
