/* ===== Reset / base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: #111827;
  background: #f7f8fb;
}
h1,h2,h3,h4 { margin: 0; }

/* ===== Layout general ===== */
.container { 
  max-width: 1280px; 
  margin: 0 auto; 
  padding: 20px; 
}

/* ===== Nuevo layout universal ===== */
.layout {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.left {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.right {
  /* ELIMINADA COMO COLUMNA */
  display: none !important;
}

/* ==== BLOQUE MAPA + DISTANCIAS ABAJO ==== */
#map-dist {
  margin: 15px 0;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 22px;
  width: 100%;
}

@media (max-width: 1100px){
  #map-dist {
    grid-template-columns: 1fr;
  }
}

/* ===== Resultados también usan full width ===== */
.layout.results-full {
  display: block !important;
}

/* ===== Card ===== */
.card {
  background: #fff;
  border: 1px solid #e5eaf3;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(16,24,40,.02);
}
.card-head { 
  display:flex; 
  align-items:center; 
  justify-content: space-between; 
  margin-bottom: 10px; 
}
.card-head h3 { font-size: 19px; font-weight: 800; }
.card-head .bar {
  display:block; 
  height:4px; 
  width:38px; 
  background:#2f6ef6; 
  border-radius:999px; 
}

/* ===== Formularios ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label,
.full-line label { display:flex; flex-direction: column; gap:8px; font-size:14px; }
.form-grid input, .form-grid select, .field-row select, .field-row input[type="text"] {
  height: 46px; padding: 10px 12px; border:1px solid #e5e7eb; border-radius: 12px; background:#fff;
  font-size: 15px;
}
.form-grid input:focus, .form-grid select:focus, .field-row select:focus {
  outline: none; border-color:#2f6ef6; box-shadow: 0 0 0 3px rgba(47,110,246,.12);
}
@media (max-width: 720px){ .form-grid { grid-template-columns: 1fr; } }

/* Chips */
.field-row { 
  display:flex; 
  flex-wrap: wrap; 
  align-items:center; 
  gap:10px; 
  margin: 10px 0 6px; 
  font-size: 14px; 
}
.chip { 
  display:inline-flex; align-items:center; 
  gap:6px; 
  background:#f3f4f6; 
  border:1px solid #e5e7eb; 
  padding:7px 11px; 
  border-radius:999px; 
}

/* Puerto seco */
.full-line { grid-column: 1 / -1; }

/* ===== Mapa ===== */
#map { 
  width: 100%; 
  height: 480px; 
  border-radius: 14px; 
  overflow: hidden; 
}

/* ===== Distancias ===== */
#distanciasCard .dist-group { margin-top: 14px; }
#distanciasCard .dist-group h4 { margin: 12px 0 10px; font-size: 16px; font-weight: 800; }

#distanciasCard .dist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

#distanciasCard .dist-list li {
  display: grid;
  grid-template-columns: 1fr max-content;
  align-items: center;
  column-gap: 18px;
  padding: 16px 20px;
  border: 1px solid #e9edf3;
  border-radius: 16px;
  background: #fff;
}

#distanciasCard .dist-list .label { line-height: 1.35; font-size: 15px; color:#111827; }
#distanciasCard .dist-list .km {
  white-space: nowrap;
  text-align: right;
  font-weight: 800;
  color: #2f6ef6;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}
#distanciasCard .dist-list .km.km-roadonly { color:#e11d48; }

#distanciasCard .dist-list li.total {
  background: #f6f9ff;
  border-color: #dfe8ff;
}
#distanciasCard .dist-list li.total .label { font-weight: 800; }

@media (max-width: 560px) {
  #distanciasCard .dist-list li { padding: 14px 16px; }
}

/* ===== Breadcrumb ===== */
.wizard-bc {
  display: flex; 
  align-items: center; 
  gap: 8px;
  margin: 8px 0 16px;
  flex-wrap: wrap;
}
.wizard-bc .bc-item {
  border: 1px solid #e3e8f3;
  background: #fff;
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.wizard-bc .bc-item:hover { border-color:#cfd7ec; }
.wizard-bc .bc-item.done { background: #f6f9ff; border-color: #dfe8ff; color:#2f6ef6; }
.wizard-bc .bc-item.current { background: #2f6ef6; color:#fff; border-color:#2f6ef6; }
.wizard-bc .bc-item:disabled { opacity: .6; cursor: not-allowed; }
.wizard-bc .bc-sep { color:#9aa5b1; }

/* ===== Wizard: pager ===== */
.wizard-pager {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.wizard-pager .pager-btn {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #e3e8f3;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}
.wizard-pager .pager-btn.next {
  background: #2f6ef6;
  color: #fff;
  border-color: #2f6ef6;
}
.wizard-pager .pager-btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 560px){
  .wizard-pager { flex-direction: column-reverse; }
  .wizard-pager .pager-btn { width: 100%; }
}

/* ===== Resultados ===== */
.results-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.results-toolbar .spacer { flex: 1 1 auto; }
.tabs { display:flex; gap:8px; }
.tab-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #e3e8f3;
  background:#f3f4f6;
  font-weight: 700;
  cursor: pointer;
}
.tab-btn.active { background:#2f6ef6; color:#fff; border-color:#2f6ef6; }

#resultsPanels .panel { display:none !important; }
#resultsPanels .panel.active { display:block !important; }

/* ===== Gráficos / tablas ===== */
.card-sub {
  border: 1px solid #eef2f7;
  border-radius: 16px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(16,24,40,.02);
}

.card-sub h4 { font-size: 16px; font-weight: 800; margin: 0 0 10px 0; }
.card-sub canvas {
  width: 100% !important;
  height: 380px !important;
  display: block;
}

@media (max-width: 900px){
  .card-sub canvas { height: 320px !important; }
}
@media (max-width: 560px){
  .card-sub canvas { height: 280px !important; }
}

/* ===== KPI Blocks ===== */
.kpi-block {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-block-2 {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  flex-direction: row;
  justify-content: center;
}

.kpi-block-2 .kpi-row {
  flex: 1;
  max-width: 600px;
}

.kpi-row {
  display: grid;
  background: #ffffff;
  border: 1px solid #e5eaf3;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 1px 0 rgba(16,24,40,0.03);
}

.kpi-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #111827;
}

.kpi-cols {
  display: grid;
  gap: 16px;
  align-items: center;
}

.kpi-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-col-label {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
}

.kpi-col-value {
  font-size: 20px;
  font-weight: 800;
  color: #2f6ef6;
}

.kpi-col-value-red {
  font-size: 20px;
  font-weight: 800;
  color: red;
}

/* Fuerza el color REAL de cada ruta */

path.leaflet-interactive.road-red {
  stroke: #ff4d4d !important;
}

path.leaflet-interactive.t1 {
  stroke: #40eb95 !important;
}

path.leaflet-interactive.sea {
  stroke: #2aa8ff !important;
}

path.leaflet-interactive.t3 {
  stroke: #40eb95 !important;
}

/* ===== OCULTAR MAPA Y DISTANCIAS EN RESULTADOS ===== */
.layout.results-full #map,
.layout.results-full #distanciasCard {
    display: none !important;
}

/* ===== Tablas bonitas (ESTILO ORIGINAL RESTAURADO) ===== */

table.pretty {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #e5eaf3;
}

table.pretty thead th {
  text-align: left;
  background: #f6f9ff;
  border-bottom: 1px solid #dfe8ff;
  padding: 12px 14px;
  font-weight: 800;
  color: #111827;
}

table.pretty tbody tr:nth-child(even) {
  background: #fafbff;
}

table.pretty tbody tr:nth-child(odd) {
  background: #ffffff;
}

table.pretty tbody th,
table.pretty tbody td {
  border-bottom: 1px solid #eef2f7;
  padding: 12px 14px;
  color: #111827;
}

table.pretty tbody tr:last-child th,
table.pretty tbody tr:last-child td {
  border-bottom: 0;
}

table.pretty td:last-child,
table.pretty th:last-child {
  text-align: right;
  font-weight: 700;
}

table.pretty .positivo {
  color: #16a34a !important; /* verde */
  font-weight: 800;
}

table.pretty .negativo {
  color: #dc2626 !important; /* rojo */
  font-weight: 800;
}

.label-with-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.label-title {
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.info-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  background: #eef2ff;
  color: #3b82f6;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.info-text {
  display: none;
  position: absolute;
  top: 120%;
  left: 0;
  background: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  border: 1px solid #e5e7eb;
  width: 260px;
  font-size: 13px;
  line-height: 1.35;
  z-index: 999;
}

.label-title:hover .info-text,
.info-icon:hover + .info-text {
  display: block;
}
