:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --primary: #0f4c81;
  --primary-dark: #0b365b;
  --accent: #1ea672;
  --accent-soft: #e7f8f0;
  --warning: #b45309;
  --warning-soft: #fff4e5;
  --danger: #b42318;
  --danger-soft: #fdecec;
  --text: #122033;
  --muted: #5b6778;
  --border: #dce4ee;
  --shadow: 0 10px 30px rgba(15, 76, 129, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #eef4fb 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
}
button, select, input, textarea {
  min-height: 46px;
}
img { max-width: 100%; display: block; }

.app-shell {
  width: min(100%, 640px);
  margin: 0 auto;
  padding: 16px 16px 104px;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card,
.page-card,
.route-card,
.doc-card,
.product-card,
.summary-card,
.message-card,
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 440px);
  padding: 24px;
}

.login-hero {
  text-align: center;
  margin-bottom: 18px;
}

.login-logo {
  width: 180px;
  margin: 0 auto 14px;
}

.login-truck {
  width: 110px;
  margin: 0 auto 8px;
  opacity: 0.92;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e9f1fb;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -16px -16px 16px;
  padding: 16px;
  background: rgba(244, 247, 251, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(220, 228, 238, 0.9);
}

.header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand {
  min-width: 0;
  flex: 1;
}

.header-brand h1 {
  font-size: 1.15rem;
  margin: 0;
}

.header-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.brand-logo {
  width: 110px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #1768aa 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 76, 129, 0.22);
}
.btn-secondary {
  background: #eef4fb;
  color: var(--primary);
  border: 1px solid #d1e0ef;
}
.btn-success {
  background: linear-gradient(135deg, #169a69 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(30, 166, 114, 0.20);
}
.btn-danger {
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #f5c7c4;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 10px 12px; font-size: 0.92rem; }

.field,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}
.field:focus,
.select:focus,
.textarea:focus {
  border-color: #7bb2dd;
  box-shadow: 0 0 0 4px rgba(23, 104, 170, 0.12);
}
.field[disabled], .textarea[disabled], .field.readonly {
  background: #f7f9fc;
  color: #334155;
}
.textarea {
  resize: vertical;
  min-height: 84px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }

.summary-card {
  padding: 14px;
}
.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}
.summary-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.route-card,
.doc-card,
.product-card,
.page-card,
.search-panel,
.message-card {
  padding: 16px;
}

.route-card-top,
.doc-card-top,
.product-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.route-title,
.doc-title,
.product-title {
  margin: 0;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.86rem;
}

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

.stat-item {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.stat-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}
.stat-item strong {
  font-size: 0.98rem;
}

.badge,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}
.badge-primary { background: #e9f1fb; color: var(--primary); }
.badge-danger { background: #fff0ef; color: var(--danger); }
.badge-success { background: var(--accent-soft); color: #0b7a52; }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: #eef2f6; color: #445366; }

.status-chip.delivered {
  background: var(--accent-soft);
  color: #0b7a52;
}

.status-chip.partial {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-chip.pending {
  background: #e9f1fb;
  color: var(--primary);
}

.status-chip.towards {
  background: #dceeff;
  color: #0b5fa5;
}

.status-chip.at-client {
  background: #dff6f3;
  color: #0f766e;
}

.status-chip.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-chip.neutral {
  background: #eef2f6;
  color: #445366;
}

.alert {
  display: none;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 700;
}
.alert.show { display: block; }
.alert-danger { background: #fff1f0; color: var(--danger); border-color: #f3cac8; }
.alert-info { background: #eff6ff; color: var(--primary); border-color: #d5e7fb; }

.search-panel {
  margin-bottom: 14px;
}
.search-row {
  display: flex;
  gap: 10px;
}
.search-row .field { flex: 1; }

.doc-card {
  border-left: 5px solid transparent;
}
.doc-card.editable { border-left-color: var(--accent); }
.doc-card.readonly { border-left-color: #d0dae5; }
.doc-card.pending-review { border-left-color: var(--warning); }

.doc-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin-top: 12px;
}

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

.section-title {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inline-note {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 28px 18px;
  color: var(--muted);
}
.empty-state strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
}

.sticky-action-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 620px);
  z-index: 30;
  display: none;
}
.sticky-action-bar.show { display: block; }
.sticky-action-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 32, 51, 0.94);
  color: #fff;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 18px 34px rgba(18, 32, 51, 0.3);
}
.sticky-action-meta {
  min-width: 0;
  flex: 1;
}
.sticky-action-meta strong {
  display: block;
  font-size: 0.95rem;
}
.sticky-action-meta span {
  display: block;
  color: rgba(255,255,255,0.78);
  font-size: 0.82rem;
  margin-top: 2px;
}

.loader-wrap {
  display: none;
  justify-content: center;
  padding: 24px 0;
}
.loader-wrap.show { display: flex; }
.loader {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #d8e4f0;
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden-inputs { display: none; }
.hidden { display: none !important; }
.center { text-align: center; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }

.login-footnote,
.page-footnote {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 14px;
}

@media (min-width: 700px) {
  .app-shell { padding-left: 20px; padding-right: 20px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 520px) {
  .summary-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .stat-list, .doc-actions { grid-template-columns: 1fr; }
  .search-row, .header-top { flex-direction: column; align-items: stretch; }
  .header-actions { justify-content: space-between; }
  .sticky-action-inner { flex-direction: column; align-items: stretch; }
  .brand-logo { width: 92px; }
}

.dashboard-shell {
  width: min(1800px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 22px 26px;
  background: #fff;
  border: 1px solid #dbe4ee;
  border-radius: 18px;
}

.dashboard-header h1 {
  margin: 4px 0;
  color: #17263a;
}

.dashboard-header p {
  margin: 0;
  color: #68768a;
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dashboard-logo {
  width: 112px;
  height: 60px;
  object-fit: contain;
  margin-left: 12px;
}

.dashboard-summary {
  display: grid;
  grid-template-columns:
    repeat(8, minmax(105px, 1fr))
    minmax(145px, 1.15fr)
    minmax(145px, 1.15fr);
  gap: 12px;
  margin-bottom: 20px;
}

.metric-card {
  padding: 18px;
  background: #fff;
  border: 1px solid #dbe4ee;
  border-radius: 14px;
}

.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: #68768a;
  font-size: 0.8rem;
}

.metric-card strong {
  color: #17263a;
  font-size: 1.6rem;
}

.metric-card.success {
  border-left: 4px solid #1f9d68;
}

.metric-card.danger {
  border-left: 4px solid #dc3545;
}

.metric-card.efficiency {
  border-left: 4px solid #1967a3;
}

.metric-card.efficiency small {
  display: block;
  margin-top: 7px;
  color: #68768a;
  font-size: 0.68rem;
  line-height: 1.25;
}

.metric-card.efficiency strong {
  white-space: nowrap;
}

.metric-card.freight-total {
  border-left: 4px solid #6f42c1;
}

.metric-card.freight-total small {
  display: block;
  margin-top: 7px;
  color: #68768a;
  font-size: 0.68rem;
}

.metric-card.freight-total strong {
  white-space: nowrap;
}

.metric-card {
  min-width: 0;
}

.metric-card strong {
  overflow-wrap: anywhere;
}

.metric-card.freight-total strong,
.metric-card.efficiency strong {
  font-size: clamp(1.25rem, 1.45vw, 1.6rem);
  overflow-wrap: normal;
}

.dashboard-alerts {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.dashboard-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 14px 18px;
  border-radius: 12px;
}

.dashboard-warning strong {
  font-size: 1.5rem;
}

.dashboard-warning.danger {
  color: #842029;
  background: #f8d7da;
}

.dashboard-warning.warning {
  color: #664d03;
  background: #fff3cd;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: minmax(280px, 0.65fr) minmax(520px, 1.35fr);
  gap: 16px;
  margin-bottom: 16px;
}

.dashboard-panel {
  padding: 22px;
  background: #fff;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  color: #17263a;
}

.panel-count {
  padding: 7px 11px;
  color: #0f4c81;
  background: #eaf3fb;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.chart-container {
  position: relative;
  height: 320px;
}

.chart-container.doughnut {
  max-width: 380px;
  margin: 0 auto;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.dashboard-table th {
  padding: 12px 10px;
  color: #5c6b7f;
  background: #f5f8fb;
  text-align: left;
  white-space: nowrap;
}

.dashboard-table td {
  padding: 14px 10px;
  border-bottom: 1px solid #e6edf4;
  vertical-align: top;
}

.dashboard-table td strong,
.dashboard-table td small {
  display: block;
}

.dashboard-table td small {
  margin-top: 4px;
  color: #6b7889;
}

.dashboard-table tr.row-danger {
  background: #fff3f3;
}

.destination-cell {
  min-width: 230px;
}

.additional-route {
  color: #9a6200 !important;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

.status-badge.warning {
  color: #664d03;
  background: #fff3cd;
}

.load-cell {
  min-width: 145px;
}

.load-value {
  font-size: 1rem;
  font-weight: 800;
}

.load-value.normal {
  color: #1f7a55;
}

.load-value.advertencia {
  color: #a86900;
}

.load-value.sobrecarga {
  color: #c62828;
}

.load-track {
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  background: #e4eaf0;
  border-radius: 999px;
}

.load-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.load-bar.normal {
  background: #1f9d68;
}

.load-bar.advertencia {
  background: #f0a000;
}

.load-bar.sobrecarga {
  background: #dc3545;
}

.text-danger {
  color: #c62828 !important;
}

.text-success {
  color: #1f7a55 !important;
}

@media (max-width: 1200px) {
  .dashboard-summary {
    grid-template-columns:
  repeat(
    auto-fit,
    minmax(100px, 1fr)
  );
  }
}

@media (max-width: 900px) {
  .dashboard-header,
  .dashboard-header-actions,
  .dashboard-alerts {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-charts {
    grid-template-columns: 1fr;
  }

  .dashboard-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-logo {
    margin-left: 0;
  }
}

.mobile-shell {
  width: min(760px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 42px;
}

.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: #fff;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
}

.mobile-header h1 {
  margin: 4px 0;
  color: #17263a;
  font-size: 1.45rem;
}

.mobile-header p {
  margin: 0;
  color: #68768a;
}

.mobile-header img {
  width: 90px;
  height: 58px;
  object-fit: contain;
}

.mobile-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 12px 0;
}

.mobile-toolbar form {
  margin: 0;
}

.mobile-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
  background: #eaf3fb;
  border-radius: 12px;
}

.mobile-summary strong {
  color: #0f4c81;
  font-size: 1.5rem;
}

.mobile-route-list,
.mobile-document-list {
  display: grid;
  gap: 14px;
}

.mobile-route-card,
.mobile-document-card {
  padding: 18px;
  background: #fff;
  border: 1px solid #dbe4ee;
  border-radius: 16px;
}

.mobile-route-heading,
.mobile-document-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.mobile-route-heading h2,
.mobile-document-heading h2 {
  margin: 8px 0 3px;
  color: #17263a;
  font-size: 1.15rem;
}

.mobile-route-heading p {
  margin: 0;
  color: #68768a;
}

.plate {
  padding: 8px 10px;
  color: #17263a;
  background: #f2f5f8;
  border: 1px solid #ccd6e0;
  border-radius: 8px;
  white-space: nowrap;
}

.mobile-warning {
  margin-top: 12px;
  padding: 10px;
  color: #664d03;
  background: #fff3cd;
  border-radius: 9px;
  font-size: 0.82rem;
}

.mobile-route-destination,
.document-client,
.document-comment,
.mobile-load {
  margin-top: 14px;
  padding: 13px;
  background: #f7f9fb;
  border-radius: 10px;
}

.mobile-route-destination span,
.mobile-route-destination strong,
.mobile-route-destination small,
.document-client strong,
.document-client span,
.document-client small,
.document-comment strong,
.document-comment span {
  display: block;
}

.mobile-route-destination span,
.document-client small {
  color: #68768a;
  font-size: 0.78rem;
}

.mobile-route-destination strong,
.document-client strong {
  margin-top: 4px;
  color: #17263a;
}

.mobile-route-destination small {
  margin-top: 7px;
  color: #9a6200;
}

.document-client span {
  margin-top: 5px;
}

.document-comment {
  color: #664d03;
  background: #fff8df;
}

.document-comment span {
  margin-top: 5px;
}

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

.mobile-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.mobile-route-stats div,
.mobile-summary-grid article {
  padding: 10px;
  background: #f5f8fb;
  border-radius: 9px;
}

.mobile-route-stats span,
.mobile-summary-grid span {
  display: block;
  color: #68768a;
  font-size: 0.72rem;
}

.mobile-route-stats strong,
.mobile-summary-grid strong {
  display: block;
  margin-top: 4px;
  color: #17263a;
}

.mobile-load > div:first-child {
  display: flex;
  justify-content: space-between;
}

.mobile-load p {
  margin: 5px 0;
  color: #68768a;
  font-size: 0.82rem;
}

@media (max-width: 560px) {
  .mobile-route-stats,
  .mobile-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mobile-route-heading,
  .mobile-document-heading {
    flex-direction: column;
  }
}

.mobile-route-card .mobile-route-stats {
  grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 560px) {
  .mobile-route-card .mobile-route-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.mobile-carrier-name {
  display: block;
  margin-top: 5px;
  color: #0f4c81;
  font-size: 0.85rem;
}

.mobile-route-card .mobile-route-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.mobile-route-card .mobile-route-stats div {
  min-width: 0;
}

.mobile-route-card .mobile-route-stats strong {
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .mobile-route-card .mobile-route-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .mobile-route-card .mobile-route-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.document-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.document-actions .btn {
  flex: 1;
  text-align: center;
}

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

.product-list {
  display: grid;
  gap: 12px;
}

.product-card {
  padding: 16px;
  background: #fff;
  border: 1px solid #dbe4ee;
  border-radius: 14px;
}

.product-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.product-card-heading small {
  color: #68768a;
}

.product-card h2 {
  margin: 12px 0;
  color: #17263a;
  font-size: 1rem;
}

.product-values {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.product-values div {
  padding: 10px;
  background: #f5f8fb;
  border-radius: 9px;
}

.product-values span,
.product-values strong {
  display: block;
}

.product-values span {
  color: #68768a;
  font-size: 0.75rem;
}

.product-values strong {
  margin-top: 4px;
  color: #17263a;
}

@media (max-width: 420px) {
  .document-actions {
    flex-direction: column;
  }
}

.delivery-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  background: #f5f8fb;
  border: 1px solid #e0e7ef;
  border-radius: 11px;
}

.delivery-form.changed {
  border-color: #1967a3;
  box-shadow: 0 0 0 2px rgba(25, 103, 163, 0.08);
}

.delivery-field {
  min-width: 0;
}

.delivery-field.full {
  grid-column: 1 / -1;
}

.delivery-field label {
  display: block;
  margin-bottom: 6px;
  color: #526177;
  font-size: 0.76rem;
  font-weight: 700;
}

.readonly-delivery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.readonly-delivery div {
  padding: 10px;
  background: #f5f8fb;
  border-radius: 9px;
}

.readonly-delivery span,
.readonly-delivery strong {
  display: block;
}

.readonly-delivery span {
  color: #68768a;
  font-size: 0.72rem;
}

.readonly-delivery strong {
  margin-top: 4px;
  color: #17263a;
}

.delivery-save-bar {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #cad8e6;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(23, 38, 58, 0.18);
}

.delivery-save-bar strong,
.delivery-save-bar span {
  display: block;
}

.delivery-save-bar span {
  margin-top: 3px;
  color: #68768a;
  font-size: 0.75rem;
}

@media (max-width: 520px) {
  .delivery-form {
    grid-template-columns: 1fr;
  }

  .delivery-field.full {
    grid-column: auto;
  }

  .delivery-save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .delivery-save-bar .btn {
    width: 100%;
  }
}

.photo-field {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid #dce4ee;
}

.photo-field-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.photo-field-heading label {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.photo-field-heading small,
.photo-help {
  color: #5b6778;
  font-size: 0.78rem;
}

.photo-counter {
  flex: 0 0 auto;
  padding: 5px 9px;
  color: #0f4c81;
  background: #e9f1fb;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.photo-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.photo-button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.photo-preview-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.photo-preview-grid:empty {
  display: none;
}

.photo-preview-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 12px;
}

.photo-preview-item img {
  width: 76px;
  height: 64px;
  object-fit: cover;
  background: #eef2f6;
  border-radius: 9px;
}

.photo-preview-information {
  min-width: 0;
}

.photo-preview-information strong,
.photo-preview-information span {
  display: block;
}

.photo-preview-information strong {
  margin-bottom: 4px;
  color: #122033;
  font-size: 0.85rem;
}

.photo-preview-information span {
  color: #5b6778;
  font-size: 0.72rem;
}

.photo-remove-button {
  min-height: 38px;
  padding: 8px 10px;
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #f5c7c4;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.photo-help {
  margin: 10px 0 0;
  line-height: 1.4;
}

@media (max-width: 430px) {
  .photo-preview-item {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .photo-preview-item img {
    width: 68px;
    height: 58px;
  }

  .photo-remove-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

.saved-photo-section {
  margin-top: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #dce4ee;
  border-radius: 14px;
}

.saved-photo-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.saved-photo-heading strong,
.saved-photo-heading span {
  display: block;
}

.saved-photo-heading strong {
  color: #122033;
  font-size: 0.9rem;
}

.saved-photo-heading div > span {
  margin-top: 3px;
  color: #5b6778;
  font-size: 0.75rem;
}

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

.saved-photo-link {
  position: relative;
  display: block;
  overflow: hidden;
  background: #e8eef5;
  border: 1px solid #d2dce7;
  border-radius: 11px;
  aspect-ratio: 4 / 3;
}

.saved-photo-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.saved-photo-link:hover img {
  transform: scale(1.03);
  opacity: 0.94;
}

.saved-photo-link > span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 4px 7px;
  color: #ffffff;
  background: rgba(18, 32, 51, 0.82);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

@media (max-width: 380px) {
  .saved-photo-grid {
    grid-template-columns: repeat(
      2,
      minmax(0, 1fr)
    );
  }
}

.freight-value-cell {
  min-width: 125px;
  white-space: nowrap;
}

.freight-value-cell strong,
.freight-value-cell small {
  display: block;
}

.freight-value-cell strong {
  color: #0f4c81;
  font-size: 0.95rem;
}

.freight-value-cell small {
  margin-top: 5px;
  color: #5b6778;
  font-weight: 700;
}

.sequence-detail-button {
  display: block;
  min-height: 0;
  padding: 0;
  color: #0f4c81;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.sequence-detail-button span,
.sequence-detail-button small {
  display: block;
}

.sequence-detail-button span {
  font-weight: 800;
}

.sequence-detail-button small {
  margin-top: 3px;
  color: #1768aa;
  text-decoration: underline;
}

.sequence-detail-button:hover span {
  color: #1768aa;
}

body.modal-open {
  overflow: hidden;
}

.traffic-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.traffic-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 28, 43, 0.7);
  backdrop-filter: blur(3px);
}

.traffic-modal-panel {
  position: relative;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  background: #f4f7fb;
  border: 1px solid #d8e2ec;
  border-radius: 20px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.32);
}

.traffic-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid #dce4ee;
}

.traffic-modal-topbar h2 {
  margin: 5px 0 0;
  font-size: 1.2rem;
}

.traffic-modal-content {
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 18px;
}

.traffic-modal-loading,
.traffic-modal-error {
  padding: 40px 20px;
  text-align: center;
  font-weight: 700;
}

.traffic-modal-loading {
  color: #5b6778;
}

.traffic-modal-error {
  color: #b42318;
  background: #fdecec;
  border-radius: 14px;
}

.traffic-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 16px;
}

.traffic-detail-header h2 {
  margin: 8px 0 4px;
}

.traffic-detail-header p {
  margin: 0;
  color: #5b6778;
}

.traffic-route-destination {
  margin-bottom: 14px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 14px;
}

.traffic-route-destination span,
.traffic-route-destination strong,
.traffic-route-destination small {
  display: block;
}

.traffic-route-destination span {
  margin-bottom: 5px;
  color: #5b6778;
  font-size: 0.78rem;
}

.traffic-route-destination small {
  margin-top: 5px;
  color: #b45309;
  font-weight: 700;
}

.traffic-detail-summary {
  display: grid;
  grid-template-columns:
    repeat(7, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.traffic-detail-summary article {
  padding: 12px;
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 12px;
}

.traffic-detail-summary article.success {
  border-left: 4px solid #1ea672;
}

.traffic-detail-summary article.danger {
  border-left: 4px solid #dc3545;
}

.traffic-detail-summary span,
.traffic-detail-summary strong {
  display: block;
}

.traffic-detail-summary span {
  margin-bottom: 5px;
  color: #5b6778;
  font-size: 0.75rem;
}

.traffic-document-list {
  display: grid;
  gap: 12px;
}

.traffic-document-card {
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 16px;
}

.traffic-document-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.traffic-document-heading h3 {
  margin: 8px 0 0;
  font-size: 1rem;
}

.traffic-client-detail {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 12px;
}

.traffic-client-detail strong,
.traffic-client-detail span,
.traffic-client-detail small {
  display: block;
}

.traffic-client-detail span {
  margin-top: 4px;
}

.traffic-client-detail small {
  margin-top: 3px;
  color: #5b6778;
}

.traffic-document-comment {
  margin-top: 10px;
  padding: 10px 12px;
  color: #7a4b00;
  background: #fff4e5;
  border-radius: 10px;
}

.traffic-document-comment span,
.traffic-document-comment strong {
  display: block;
}

.traffic-document-comment span {
  margin-bottom: 4px;
  font-size: 0.75rem;
}

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

.traffic-document-data > div {
  padding: 10px;
  background: #f4f7fb;
  border-radius: 10px;
}

.traffic-document-data span,
.traffic-document-data strong {
  display: block;
}

.traffic-document-data span {
  margin-bottom: 4px;
  color: #5b6778;
  font-size: 0.72rem;
}

.traffic-photo-section {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #dce4ee;
  border-radius: 12px;
}

.traffic-photo-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.traffic-photo-heading span {
  color: #5b6778;
  font-size: 0.76rem;
}

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

.traffic-photo-grid a {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #e8eef5;
  border-radius: 10px;
}

.traffic-photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.traffic-photo-grid a > span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 4px 7px;
  color: #ffffff;
  background: rgba(18, 32, 51, 0.82);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

.traffic-document-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

@media (max-width: 1000px) {
  .traffic-detail-summary {
    grid-template-columns:
      repeat(4, minmax(110px, 1fr));
  }
}

@media (max-width: 700px) {
  .traffic-modal {
    padding: 0;
  }

  .traffic-modal-panel {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .traffic-modal-content {
    max-height: calc(100vh - 88px);
    padding: 12px;
  }

  .traffic-detail-summary {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .traffic-document-data {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .traffic-detail-header {
    flex-direction: column;
  }

  .traffic-document-query-card-header {
    flex-wrap: wrap;
  }

  .traffic-document-query-seller {
    text-align: left;
  }
}

/* Detalle de ruta de Tráfico en formato tabla */

.traffic-modal-panel {
  width: min(1450px, 100%);
}

.traffic-detail-header {
  margin-bottom: 12px;
}

.traffic-detail-table-panel {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #dce4ee;
  border-radius: 15px;
}

.traffic-detail-table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid #dce4ee;
}

.traffic-detail-table-heading h3 {
  margin: 5px 0 0;
  font-size: 1.05rem;
}

.traffic-detail-table-responsive {
  width: 100%;
  overflow-x: auto;
}

.traffic-detail-table {
  width: 100%;
  min-width: 1250px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.traffic-detail-table th {
  padding: 10px;
  color: #536176;
  background: #f3f7fb;
  border-bottom: 1px solid #dce4ee;
  text-align: left;
  white-space: nowrap;
}

.traffic-detail-table td {
  padding: 10px;
  border-bottom: 1px solid #e3eaf2;
  vertical-align: top;
}

.traffic-detail-table tbody tr:last-child td {
  border-bottom: 0;
}

.traffic-detail-table tbody tr:hover {
  background: #f8fbff;
}

.traffic-detail-table tr.traffic-row-delivered {
  background: #f3fbf7;
}

.traffic-detail-table tr.traffic-row-delivered:hover {
  background: #eaf7f0;
}

.traffic-detail-table tr.traffic-row-incident {
  background: #fff7f6;
}

.traffic-detail-table tr.traffic-row-incident:hover {
  background: #feefed;
}

.traffic-document-number {
  width: 105px;
  white-space: nowrap;
}

.traffic-document-number strong {
  display: block;
  margin-top: 7px;
  color: #122033;
  font-size: 0.9rem;
}

.traffic-customer-cell {
  min-width: 250px;
  max-width: 320px;
}

.traffic-customer-cell strong,
.traffic-customer-cell span,
.traffic-customer-cell small {
  display: block;
}

.traffic-customer-cell strong {
  color: #122033;
}

.traffic-customer-cell span {
  margin-top: 4px;
}

.traffic-customer-cell small {
  margin-top: 3px;
  color: #5b6778;
}

.traffic-status-cell {
  width: 150px;
}

.traffic-status-cell .status-chip {
  min-height: 28px;
  white-space: normal;
}

.traffic-payment-cell {
  min-width: 120px;
}

.traffic-payment-cell strong,
.traffic-payment-cell small {
  display: block;
}

.traffic-payment-cell small {
  margin-top: 5px;
  color: #5b6778;
}

.traffic-observation-cell {
  min-width: 180px;
  max-width: 240px;
}

.traffic-observation-cell strong,
.traffic-observation-cell span {
  display: block;
}

.traffic-observation-cell span {
  margin-top: 5px;
}

.traffic-comment-cell {
  min-width: 170px;
  max-width: 230px;
  color: #7a4b00;
}

.traffic-empty-value {
  color: #8a96a6 !important;
  font-weight: 400 !important;
}

.traffic-photo-cell {
  min-width: 155px;
}

.traffic-photo-thumbnails {
  display: flex;
  align-items: center;
  gap: 5px;
}

.traffic-photo-thumbnails a {
  display: block;
  width: 42px;
  height: 42px;
  overflow: hidden;
  background: #e8eef5;
  border: 1px solid #cad6e2;
  border-radius: 8px;
}

.traffic-photo-thumbnails img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s ease;
}

.traffic-photo-thumbnails a:hover img {
  transform: scale(1.08);
}

.traffic-photo-cell > small {
  display: block;
  margin-top: 5px;
  color: #5b6778;
}

.traffic-no-photo {
  display: inline-block;
  padding: 5px 8px;
  color: #697689;
  background: #eef2f6;
  border-radius: 999px;
  white-space: nowrap;
}

.traffic-location-cell {
  width: 80px;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .traffic-detail-table {
    min-width: 1150px;
  }
}

/* Estado final de una ruta */

.dashboard-table tr.row-completed {
  background: #eef9f3;
}

.dashboard-table tr.row-completed:hover {
  background: #e3f5eb;
}

.route-completed-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 7px;
  color: #08734d;
  background: #dff5e9;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.traffic-route-completed {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  color: #086747;
  background: #e7f8f0;
  border: 1px solid #bce8d3;
  border-left: 5px solid #1ea672;
  border-radius: 12px;
}

.traffic-route-completed strong {
  flex: 0 0 auto;
}

.traffic-route-completed span {
  color: #276c55;
  font-size: 0.82rem;
}

/*
 * La clase antigua puede permanecer en CSS, pero ya no se
 * asigna a las filas por una sobrecarga.
 */

 /* Filtro rápido por transportista */

.carrier-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 16px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.carrier-filter-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  color: #405169;
  background: #f2f6fa;
  border: 1px solid #d6e0ea;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.carrier-filter-button:hover {
  color: #0f4c81;
  background: #eaf3fb;
  border-color: #a9c9e3;
}

.carrier-filter-button.active {
  color: #ffffff;
  background: #0f4c81;
  border-color: #0f4c81;
  box-shadow:
    0 6px 14px rgba(15, 76, 129, 0.2);
}

.carrier-filter-button > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  min-height: 23px;
  padding: 2px 7px;
  color: #405169;
  background: #ffffff;
  border-radius: 999px;
  font-size: 0.7rem;
}

.carrier-filter-button.active > span {
  color: #0f4c81;
}

.dashboard-table tr.carrier-row-hidden {
  display: none;
}

.traffic-map-button {
  margin-left: auto;
  border-color: #1967a3;
  color: #1967a3;
}

.traffic-map-button:hover,
.traffic-map-button:focus-visible {
  background: #1967a3;
  color: #fff;
}

.traffic-modal-open {
  overflow: hidden;
}

.traffic-map-modal-panel {
  width: min(1500px, calc(100vw - 40px));
  max-width: none;
  height: min(900px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.traffic-map-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #d6e0ea;
  background: #f7f9fc;
  color: #4e6178;
}

.traffic-map-summary span:first-child {
  color: #10243e;
  font-weight: 700;
}

.traffic-map-canvas {
  flex: 1;
  min-height: 520px;
  background: #eef3f8;
}

.traffic-map-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 40px;
  color: #5d7088;
  text-align: center;
}

.traffic-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 16px;
  border-top: 1px solid #d6e0ea;
  background: #fff;
}

.traffic-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #42566f;
  font-size: 0.88rem;
}

.traffic-map-dot {
  width: 11px;
  height: 11px;
  display: inline-block;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #9baabc;
}

.traffic-map-dot.delivered {
  background: #1f9d68;
}

.traffic-map-dot.in-route {
  background: #1967a3;
}

.traffic-map-dot.incident {
  background: #dc3545;
}

.traffic-map-dot.towards-client {
  background: #4da3df;
}

.traffic-map-dot.at-client {
  background: #17a2b8;
}

.traffic-map-unlocated {
  max-height: 190px;
  overflow: auto;
  border-top: 1px solid #d6e0ea;
  background: #fff9ec;
}

.traffic-map-unlocated summary {
  padding: 10px 16px;
  color: #805500;
  font-weight: 700;
  cursor: pointer;
}

.traffic-map-unlocated-row {
  display: grid;
  gap: 2px;
  padding: 9px 16px;
  border-top: 1px solid #f0dfb5;
}

.traffic-map-unlocated-row span,
.traffic-map-unlocated-row small {
  color: #596b80;
}

.traffic-map-info {
  max-width: 390px;
  color: #10243e;
}

.traffic-map-info-documents {
  max-height: 260px;
  margin-top: 8px;
  overflow: auto;
}

.traffic-map-info-document {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-top: 1px solid #dce4ed;
}

.traffic-map-info-document span {
  color: #52667d;
  font-size: 0.82rem;
}

@media (max-width: 760px) {
  .traffic-map-button {
    margin-left: 0;
  }

  .traffic-map-modal-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }

  .traffic-map-summary {
    flex-direction: column;
    gap: 4px;
  }

  .traffic-map-canvas {
    min-height: 400px;
  }
}

/* Seguimiento GPS de rutas */

.tracking-route-controls {
  display: grid;
  gap: 8px;
  margin: 16px 0 10px;
}

.tracking-route-button {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.tracking-route-button.tracking-active {
  background: #b42318;
  border-color: #b42318;
}

.tracking-route-button.tracking-active:hover,
.tracking-route-button.tracking-active:focus-visible {
  background: #912018;
  border-color: #912018;
}

.tracking-route-status {
  display: block;
  padding: 9px 11px;
  border: 1px solid #d8e1eb;
  border-radius: 9px;
  background: #f4f7fa;
  color: #596b80;
  font-size: 0.78rem;
  line-height: 1.35;
}

.tracking-route-status[data-state="starting"] {
  border-color: #a9c8e5;
  background: #edf6ff;
  color: #15558a;
}

.tracking-route-status[data-state="online"] {
  border-color: #9bd8bd;
  background: #eaf8f1;
  color: #13734d;
}

.tracking-route-status[data-state="error"] {
  border-color: #efb2b2;
  background: #fff0f0;
  color: #a32626;
}

.tracking-status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #d8e1eb;
  border-left: 5px solid #7b8da1;
  border-radius: 12px;
  background: #f4f7fa;
}

.tracking-status-panel > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.tracking-status-panel strong {
  color: #17283d;
  font-size: 0.92rem;
}

.tracking-status-panel span {
  color: #596b80;
  font-size: 0.8rem;
  line-height: 1.35;
}

.tracking-status-panel[data-state="starting"] {
  border-color: #a9c8e5;
  border-left-color: #1967a3;
  background: #edf6ff;
}

.tracking-status-panel[data-state="starting"] span {
  color: #15558a;
}

.tracking-status-panel[data-state="online"] {
  border-color: #9bd8bd;
  border-left-color: #1f9d68;
  background: #eaf8f1;
}

.tracking-status-panel[data-state="online"] span {
  color: #13734d;
}

.tracking-status-panel[data-state="error"] {
  border-color: #efb2b2;
  border-left-color: #dc3545;
  background: #fff0f0;
}

.tracking-status-panel[data-state="error"] span {
  color: #a32626;
}

#saveDeliveriesButton:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 640px) {
  .tracking-status-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .tracking-status-panel .btn {
    width: 100%;
  }
}

/* Vehículos en tiempo real */

.traffic-map-summary-results {
  display: grid;
  gap: 3px;
  text-align: right;
}

#trafficMapVehicleStatus {
  color: #1967a3;
  font-size: 0.78rem;
  font-weight: 700;
}

.traffic-map-truck {
  position: relative;
  display: inline-block;
  width: 19px;
  height: 11px;
  margin-right: 2px;
  border-radius: 3px 2px 2px 3px;
  background: #1967a3;
}

.traffic-map-truck::before {
  position: absolute;
  top: 3px;
  right: -5px;
  width: 7px;
  height: 8px;
  border-radius: 1px 3px 2px 1px;
  background: inherit;
  content: "";
}

.traffic-map-truck::after {
  position: absolute;
  right: -3px;
  bottom: -4px;
  width: 5px;
  height: 5px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #26384c;
  box-shadow: -13px 0 0 #26384c;
  content: "";
}

.traffic-map-truck.stale {
  background: #e09a00;
}

@media (max-width: 700px) {
  .traffic-map-summary-results {
    text-align: left;
  }
}

.tracking-stop-action {
  background: #b42318;
  border-color: #b42318;
  color: #ffffff;
}

.tracking-stop-action:hover,
.tracking-stop-action:focus-visible {
  background: #912018;
  border-color: #912018;
  color: #ffffff;
}

.tracking-status-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .tracking-status-actions {
    display: grid;
    width: 100%;
  }

  .tracking-status-actions .btn {
    width: 100%;
  }
}

.fletero-map-modal-panel {
  width: min(1100px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}

.fletero-map-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid #d8e1eb;
  background: #f5f8fb;
  color: #50647c;
}

.fletero-map-summary strong {
  color: #17283d;
}

.fletero-map-canvas {
  min-height: 520px;
}

@media (max-width: 700px) {
  .fletero-map-modal-panel {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .fletero-map-summary {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 14px;
  }

  .fletero-map-canvas {
    min-height: 0;
    flex: 1;
  }
}

.fletero-map-canvas {
  display: block;
  width: 100%;
  height: 60vh;
  min-height: 420px;
  background: #eef2f6;
}

@media (max-width: 720px) {
  .fletero-map-modal-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .fletero-map-summary {
    flex: 0 0 auto;
  }

  .fletero-map-canvas {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 55vh;
  }
}

.delivery-communes {
  color: #49647f;
  font-weight: 600;
  line-height: 1.35;
}

.freight-cost-detail {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  outline: none;
  cursor: help;
}

.freight-cost-detail:focus-visible {
  border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(25, 103, 163, 0.2);
}

.return-freight-value {
  margin-top: 4px;
  color: #8a5700 !important;
  font-weight: 700 !important;
}

.freight-cost-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 50;
  display: none;
  width: 245px;
  padding: 12px;
  color: #23364a;
  background: #ffffff;
  border: 1px solid #cad6e2;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(24, 45, 68, 0.2);
}

.freight-cost-popover::after {
  position: absolute;
  bottom: -7px;
  left: 24px;
  width: 12px;
  height: 12px;
  content: "";
  background: #ffffff;
  border-right: 1px solid #cad6e2;
  border-bottom: 1px solid #cad6e2;
  transform: rotate(45deg);
}

.freight-cost-detail:hover .freight-cost-popover,
.freight-cost-detail:focus .freight-cost-popover,
.freight-cost-detail:focus-within .freight-cost-popover {
  display: grid;
  gap: 7px;
}

.freight-cost-popover > strong {
  margin-bottom: 2px;
  color: #173f67;
  font-size: 0.85rem;
}

.freight-cost-popover span {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: #52677c;
  font-size: 0.78rem;
}

.freight-cost-popover em {
  font-style: normal;
  font-weight: 500;
}

.freight-cost-popover b {
  color: #24384d;
  font-weight: 700;
  white-space: nowrap;
}

.freight-cost-popover .freight-cost-total {
  margin-top: 3px;
  padding-top: 7px;
  border-top: 1px solid #dce4ec;
  color: #173f67;
}

.traffic-detail-summary article.return-value {
  background: #fff5df;
  border-color: #e7bd66;
}

.traffic-detail-summary article.return-value span,
.traffic-detail-summary article.return-value strong {
  color: #815000;
}

@media (max-width: 720px) {
  .freight-cost-popover {
    right: 0;
    left: auto;
    width: min(245px, calc(100vw - 40px));
  }

  .freight-cost-popover::after {
    right: 24px;
    left: auto;
  }
}

.freight-value-cell:first-child {
  position: relative;
}

tbody tr:first-child .freight-cost-popover {
  top: calc(100% + 10px);
  bottom: auto;
}

tbody tr:first-child .freight-cost-popover::after {
  top: -7px;
  bottom: auto;
  border: 0;
  border-top: 1px solid #cad6e2;
  border-left: 1px solid #cad6e2;
}

.dashboard-charts .chart-container {
  height: 190px;
}

.dashboard-charts .chart-container.doughnut {
  max-width: 220px;
  margin: 0 auto;
}

.route-performance-panel {
  overflow: hidden;
  margin-bottom: 20px;
}

.route-performance-panel .panel-heading {
  margin-bottom: 8px;
}

.route-performance-description {
  margin: 0 0 14px;
  color: #68768a;
  font-size: 0.82rem;
  line-height: 1.4;
}

.route-performance-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

.route-performance-chart {
  width: max(100%, 960px);
  height: 310px;
}

@media (max-width: 720px) {
  .dashboard-charts .chart-container {
    height: 240px;
  }

  .dashboard-charts .chart-container.doughnut {
    max-width: 260px;
  }

  .route-performance-panel {
    padding-right: 14px;
    padding-left: 14px;
  }

  .route-performance-panel .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .route-performance-chart {
    width: 960px;
    height: 290px;
  }
}

/* Consulta histórica de tráfico */

.historical-date-control {
  position: relative;
}

.historical-date-control > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.historical-date-control > summary::-webkit-details-marker {
  display: none;
}

.historical-date-control[open] > summary {
  color: #fff;
  background: #9a6700;
  border-color: #9a6700;
}

.historical-date-form {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  width: 310px;
  gap: 12px;
  padding: 18px;
  color: #17263a;
  background: #fff;
  border: 1px solid #d6b864;
  border-radius: 14px;
  box-shadow:
    0 18px 42px
    rgba(23, 38, 58, 0.22);
}

.historical-date-form::before {
  position: absolute;
  top: -7px;
  right: 28px;
  width: 12px;
  height: 12px;
  content: "";
  background: #fff;
  border-top: 1px solid #d6b864;
  border-left: 1px solid #d6b864;
  transform: rotate(45deg);
}

.historical-date-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #46566c;
}

.historical-date-form input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  color: #17263a;
  font: inherit;
  background: #fff;
  border: 1px solid #c8d4e1;
  border-radius: 9px;
}

.historical-date-form input[type="date"]:focus {
  border-color: #9a6700;
  outline: 3px solid
    rgba(154, 103, 0, 0.15);
}

.historical-date-form .btn {
  width: 100%;
}

.historical-dashboard {
  background:
    linear-gradient(
      180deg,
      #f5f0df 0,
      #edf3f8 360px
    );
}

.historical-dashboard .dashboard-header {
  border-color: #d9bd6b;
  box-shadow:
    inset 5px 0 0 #b77a00;
}

.historical-dashboard .dashboard-header .eyebrow {
  color: #704d00;
  background: #fff1bd;
}

.historical-dashboard .dashboard-header p strong {
  color: #704d00;
}

.historical-dashboard-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 15px 18px;
  color: #5f4300;
  background: #fff4cc;
  border: 1px solid #dfc36d;
  border-left: 5px solid #b77a00;
  border-radius: 14px;
}

.historical-dashboard-notice > div {
  display: grid;
  gap: 3px;
}

.historical-dashboard-notice strong,
.historical-dashboard-notice span {
  display: block;
}

.historical-dashboard-notice strong {
  color: #493400;
  font-size: 0.94rem;
}

.historical-dashboard-notice span {
  font-size: 0.84rem;
}

.historical-readonly-badge {
  flex: 0 0 auto;
  padding: 7px 11px;
  color: #704d00;
  font-size: 0.75rem !important;
  font-weight: 700;
  background: #ffe69a;
  border: 1px solid #d6b864;
  border-radius: 999px;
  white-space: nowrap;
}

.historical-dashboard .dashboard-panel {
  border-color: #ddd3b7;
}

.historical-dashboard .metric-card {
  border-color: #ddd3b7;
}

@media (max-width: 1200px) {
  .dashboard-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 900px) {
  .historical-date-control,
  .historical-date-control > summary,
  .dashboard-header-actions > a,
  .dashboard-header-actions > form,
  .dashboard-header-actions > form .btn {
    width: 100%;
  }

  .historical-date-control > summary {
    display: block;
    text-align: center;
  }

  .historical-date-form {
    position: static;
    width: 100%;
    margin-top: 10px;
    box-shadow: none;
  }

  .historical-date-form::before {
    display: none;
  }

  .historical-dashboard-notice {
    align-items: flex-start;
    flex-direction: column;
  }
}

.historical-notice-description {
  flex: 1 1 auto;
}

.historical-date-highlight {
  display: grid;
  flex: 0 0 auto;
  gap: 2px;
  min-width: 190px;
  padding: 9px 22px;
  text-align: center;
  background: #fff;
  border: 2px solid #b77a00;
  border-radius: 12px;
  box-shadow:
    0 5px 14px
    rgba(112, 77, 0, 0.14);
}

.historical-date-highlight span {
  margin: 0;
  color: #755100;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.historical-date-highlight strong {
  color: #493400;
  font-size: 1.45rem;
  line-height: 1.1;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .historical-date-highlight {
    width: 100%;
  }
}

.traffic-document-number {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.traffic-document-type {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
  line-height: 1.1;
}

.traffic-document-code {
  font-size: 0.9rem;
  line-height: 1.2;
  color: #111827;
}

.traffic-document-detail-button {
  margin-top: 2px;
}

.dashboard-summary-efficiency {
  margin-top: 12px;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.dashboard-summary-efficiency .metric-card {
  min-height: 96px;
}

.dashboard-summary-efficiency .metric-card strong,
.dashboard-summary-efficiency .metric-card small {
  display: block;
}

.dashboard-summary-efficiency .metric-card small {
  margin-top: 6px;
}

.traffic-theoretical-route {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #d7e1ec;
  border-radius: 12px;
  background: #fff;
}

.traffic-theoretical-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.traffic-theoretical-summary article {
  padding: 10px 12px;
  border: 1px solid #d7e1ec;
  border-radius: 9px;
  background: #f8fafc;
}

.traffic-theoretical-summary span,
.traffic-theoretical-summary strong {
  display: block;
}

.traffic-theoretical-summary span {
  margin-bottom: 4px;
  font-size: 0.78rem;
  color: #62748a;
}

.traffic-theoretical-summary strong {
  color: #10243e;
}

.traffic-theoretical-note {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef7f2;
  font-size: 0.8rem;
  color: #26734d;
}

.traffic-theoretical-note.warning {
  background: #fff4d9;
  color: #9a6400;
}

.traffic-theoretical-details {
  margin-top: 12px;
  border-top: 1px solid #d7e1ec;
  padding-top: 10px;
}

.traffic-theoretical-details > summary {
  cursor: pointer;
  font-weight: 700;
  color: #0c568f;
}

.traffic-theoretical-origin {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px;
  border-radius: 9px;
  background: #eef5fb;
}

.traffic-theoretical-origin div {
  display: flex;
  flex-direction: column;
}

.traffic-theoretical-origin span:not(.traffic-route-order) {
  margin-top: 2px;
  font-size: 0.78rem;
  color: #65768a;
}

.traffic-route-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0c568f;
  color: #fff;
  font-weight: 700;
}

.traffic-route-order.origin {
  background: #26384c;
  font-size: 0.72rem;
}

.traffic-theoretical-stops {
  margin-top: 4px;
}

.traffic-theoretical-stop {
  position: relative;
  padding-left: 16px;
}

.traffic-theoretical-leg {
  display: flex;
  gap: 10px;
  margin-left: 15px;
  padding: 8px 0 8px 28px;
  border-left: 2px solid #9cb8d0;
  font-size: 0.76rem;
  color: #52677d;
}

.traffic-theoretical-leg span {
  padding: 3px 7px;
  border-radius: 6px;
  background: #eef5fb;
}

.traffic-theoretical-stop-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.traffic-theoretical-stop-info {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid #d7e1ec;
  border-radius: 8px;
}

.traffic-theoretical-stop-info > strong {
  display: block;
  margin-bottom: 6px;
}

.traffic-theoretical-documents {
  display: grid;
  gap: 5px;
}

.traffic-theoretical-documents > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  font-size: 0.78rem;
}

.traffic-theoretical-documents small {
  color: #65768a;
}

@media (max-width: 900px) {
  .traffic-theoretical-summary {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

.traffic-theoretical-map-block {
  margin-top: 14px;
}

.traffic-theoretical-map {
  width: 100%;
  min-height: 420px;
  margin-top: 10px;
  border: 1px solid #d7e1ec;
  border-radius: 10px;
  overflow: hidden;
  background: #eef2f6;
}

.traffic-map-popup {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 180px;
  max-width: 280px;
}

.traffic-map-popup > strong {
  color: #10243e;
}

.traffic-map-popup > span {
  font-size: 0.82rem;
  color: #52677d;
}

.traffic-map-popup-document {
  display: flex;
  flex-direction: column;
  padding-top: 5px;
  margin-top: 4px;
  border-top: 1px solid #e0e6ed;
  font-size: 0.78rem;
}

@media (max-width: 900px) {
  .traffic-theoretical-map {
    min-height: 340px;
  }
}

.mobile-route-plan {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #d7e1ec;
  border-radius: 12px;
  background: #fff;
}

.mobile-route-plan-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mobile-route-plan-heading h2 {
  margin: 4px 0 0;
}

.mobile-route-plan-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.mobile-route-plan-summary article {
  padding: 9px;
  border-radius: 9px;
  background: #f4f8fc;
  border: 1px solid #d7e1ec;
}

.mobile-route-plan-summary span,
.mobile-route-plan-summary strong {
  display: block;
}

.mobile-route-plan-summary span {
  font-size: 0.72rem;
  color: #65768a;
}

.mobile-route-plan-summary strong {
  margin-top: 3px;
}

.mobile-route-plan-warning {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff4d9;
  color: #8a5a00;
  font-size: 0.78rem;
}

.mobile-route-plan-details {
  margin-top: 12px;
  border-top: 1px solid #d7e1ec;
  padding-top: 10px;
}

.mobile-route-plan-details > summary {
  cursor: pointer;
  font-weight: 700;
  color: #0c568f;
}

.mobile-route-origin,
.mobile-route-stop {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.mobile-route-origin {
  margin-top: 12px;
  padding: 10px;
  border-radius: 9px;
  background: #eef5fb;
}

.mobile-route-origin div,
.mobile-route-stop div {
  display: flex;
  flex-direction: column;
}

.mobile-route-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #0c568f;
  color: #fff;
  font-weight: 700;
}

.mobile-route-number.origin {
  background: #26384c;
  font-size: 0.7rem;
}

.mobile-route-leg {
  display: flex;
  gap: 8px;
  margin-left: 14px;
  padding: 7px 0 7px 26px;
  border-left: 2px solid #a9bfd3;
}

.mobile-route-leg span {
  padding: 3px 6px;
  border-radius: 6px;
  background: #eef5fb;
  font-size: 0.7rem;
  color: #52677d;
}

.mobile-route-stop {
  padding: 7px 0;
}

.mobile-route-stop small {
  margin-top: 2px;
  color: #65768a;
}

@media (max-width: 520px) {
  .mobile-route-plan-summary {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .mobile-route-plan-summary strong {
    font-size: 0.9rem;
  }
}

.mobile-document-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-document-title-row h3 {
  margin: 0;
}

.mobile-document-stop-number {
  flex: 0 0 30px;
}

.mobile-document-accordion {
  padding: 0;
  overflow: hidden;
}

.mobile-document-accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.mobile-document-accordion-summary::-webkit-details-marker {
  display: none;
}

.mobile-document-accordion-summary::marker {
  display: none;
}

.mobile-document-accordion-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mobile-document-accordion-main .mobile-document-title-row {
  margin: 0;
}

.mobile-document-accordion-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.mobile-document-accordion-action {
  min-width: 44px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #eef5fb;
  color: #0c568f;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.mobile-document-accordion-content {
  padding: 0 14px 14px;
  border-top: 1px solid #e2e8f0;
}

.mobile-document-accordion-content .document-client {
  margin-top: 12px;
}

.mobile-document-accordion[open]
  .mobile-document-accordion-summary {
  background: #f8fafc;
}

@media (max-width: 600px) {
  .mobile-document-accordion-summary {
    align-items: flex-start;
  }

  .mobile-document-accordion-main {
    flex-wrap: wrap;
  }

  .mobile-document-accordion-status {
    margin-left: auto;
  }
}

.route-stop-action {
  margin-left: 8px;
  white-space: nowrap;
}

.mobile-document-card.route-stop-active {
  border: 2px solid #0d6efd;
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.08);
}

.mobile-document-card.route-stop-arrived {
  border: 2px solid #198754;
}

.route-stop-action[data-route-stop-state="active"] {
  background: #0d6efd;
  color: #fff;
}

.route-stop-action[data-route-stop-state="arrived"] {
  background: #198754;
  color: #fff;
}

.route-stop-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .route-stop-action {
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
  }
}
.delivery-form-locked {
  position: relative;
}

.delivery-form-locked
select,
.delivery-form-locked
textarea {
  opacity: 0.6;
  cursor: not-allowed;
}

.delivery-form-locked
.photo-button {
  opacity: 0.55;
  pointer-events: none;
}

.delivery-arrival-required {
  grid-column: 1 / -1;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  background: #fff8e6;
  color: #7a5200;
  font-size: 0.82rem;
  font-weight: 600;
}

.traffic-document-query-panel {
  width: min(760px, 100%);
}

.traffic-document-query-form {
  display: grid;
  gap: 16px;
}

.traffic-document-query-fields {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 2fr);
  gap: 14px;
}

.traffic-document-query-fields label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.traffic-document-query-fields input,
.traffic-document-query-fields select {
  width: 100%;
}

.traffic-document-query-actions {
  display: flex;
  justify-content: flex-end;
}

.traffic-document-query-release-button {
  margin-top: 12px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: #c62828;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.traffic-document-query-release-button:hover {
  background: #a91f1f;
}

.traffic-document-query-release-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.traffic-document-query-result {
  margin-top: 18px;
}

.traffic-document-query-card {
  border:
    1px solid
    #d5e1ec;
  border-radius: 14px;
  padding: 18px;
  background: #ffffff;
}

.traffic-document-query-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.traffic-document-query-card-header h3 {
  margin: 4px 0 0;
}

.traffic-document-query-seller {
  text-align: center;
}

.traffic-document-query-seller strong {
  display: block;
  margin-top: 4px;
  color: #183b5b;
  font-size: 1rem;
}

.traffic-document-query-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf4fb;
  color: #174f7c;
  font-weight: 700;
}

.traffic-document-query-grid {
  display: grid;
  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    );
  gap: 10px;
}

.traffic-document-query-grid > div {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f5f8fb;
}

.traffic-document-query-grid span {
  display: block;
  margin-bottom: 3px;
  color: #60758a;
  font-size: 0.78rem;
}

.traffic-document-query-grid strong {
  display: block;
}

.traffic-document-query-permission {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef8f2;
  color: #16754c;
  font-weight: 700;
}

@media (
  max-width: 700px
) {
  .traffic-document-query-fields,
  .traffic-document-query-grid {
    grid-template-columns: 1fr;
  }
}

.excel-export-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
}

.excel-export-overlay.hidden {
  display: none;
}

.excel-export-loading {
  min-width: 280px;
  padding: 28px 32px;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
  text-align: center;
}

.excel-export-loading strong {
  display: block;
  margin-top: 14px;
  font-size: 18px;
  color: #1b2c4a;
}

.excel-export-loading span {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: #667085;
}

.excel-export-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 4px solid #dbe3ee;
  border-top-color: #1b2c4a;
  border-radius: 50%;
  animation: excel-export-spin 0.8s linear infinite;
}

@keyframes excel-export-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Preparacion de rutas */

.preparacion-date-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.preparacion-date-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #68768a;
  font-size: 0.72rem;
  font-weight: 700;
}

.preparacion-date-form input {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #fff;
}

.preparacion-date-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 1px solid #cfe0ef;
  border-left: 5px solid #1967a3;
  border-radius: 12px;
  background: #f4f9fd;
}

.preparacion-date-banner div span {
  display: block;
  margin-bottom: 4px;
  color: #68768a;
  font-size: 0.78rem;
}

.preparacion-date-banner div strong {
  color: #17263a;
  font-size: 1.35rem;
}

.preparacion-date-banner p {
  margin: 0;
  color: #526174;
  font-size: 0.85rem;
  text-align: right;
}

.preparacion-summary {
  display: grid;
  grid-template-columns:
    repeat(9, minmax(105px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.preparacion-summary .metric-card {
  padding: 15px;
}

.preparacion-summary .metric-card small {
  display: block;
  margin-top: 6px;
  color: #68768a;
  font-size: 0.68rem;
}

.preparacion-summary .metric-card.warning {
  border-left: 4px solid #d99a00;
}

.preparacion-layout {
  display: grid;
  grid-template-columns:
    minmax(280px, 0.85fr)
    minmax(260px, 0.7fr)
    minmax(360px, 1.15fr);
  gap: 16px;
  margin-bottom: 16px;
}

.preparacion-selector-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 410px;
  overflow-y: auto;
}

.preparacion-selector-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 12px;
  border: 1px solid #e2e9f0;
  border-radius: 10px;
  background: #fafcfe;
}

.preparacion-selector-item strong,
.preparacion-selector-item small {
  display: block;
}

.preparacion-selector-item small {
  margin-top: 3px;
  color: #68768a;
  font-size: 0.72rem;
}

.preparacion-selector-values {
  flex: 0 0 auto;
  text-align: right;
}

.preparacion-vehicles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.preparacion-vehicle-badge {
  display: inline-block;
  padding: 5px 7px;
  color: #0f4c81;
  background: #eaf3fb;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.preparacion-unassigned-resource {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #f0d58c;
  border-radius: 10px;
  background: #fff9e8;
}

.preparacion-unassigned-resource strong {
  display: block;
  margin-bottom: 8px;
  color: #725300;
  font-size: 0.8rem;
}

.preparacion-unassigned-resource
.preparacion-vehicles {
  justify-content: flex-start;
}

.preparacion-orders-panel {
  margin-bottom: 20px;
}

.preparacion-orders-table {
  min-width: 1700px;
}

.preparacion-orders-table td {
  font-size: 0.8rem;
}

.preparacion-orders-table
.preparacion-row-locked {
  background: #f6f7f9;
}

.preparacion-badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.preparacion-badge.editable {
  color: #146c43;
  background: #dff4e8;
}

.preparacion-badge.locked {
  color: #6c2731;
  background: #f8dfe3;
}

.preparacion-badge.warning {
  color: #725300;
  background: #fff0bd;
}

.preparacion-progress {
  width: 105px;
  height: 8px;
  overflow: hidden;
  background: #e7edf3;
  border-radius: 999px;
}

.preparacion-progress-bar {
  height: 100%;
  background: #d99521;
  border-radius: inherit;
}

.preparacion-progress[data-complete="true"]
.preparacion-progress-bar {
  background: #1f9d68;
}

.preparacion-empty {
  padding: 28px !important;
  color: #68768a;
  text-align: center;
}

@media (max-width: 1400px) {
  .preparacion-summary {
    grid-template-columns:
      repeat(5, minmax(120px, 1fr));
  }

  .preparacion-layout {
    grid-template-columns:
      repeat(2, minmax(280px, 1fr));
  }

  .preparacion-layout
  .dashboard-panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .preparacion-summary {
    grid-template-columns:
      repeat(2, minmax(120px, 1fr));
  }

  .preparacion-layout {
    grid-template-columns: 1fr;
  }

  .preparacion-layout
  .dashboard-panel:last-child {
    grid-column: auto;
  }

  .preparacion-date-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .preparacion-date-banner p {
    text-align: left;
  }

  .preparacion-date-form {
    align-items: stretch;
    flex-direction: column;
  }
}

.preparacion-filter-item {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.preparacion-filter-item:hover {
  border-color: #9fc5e4;
  background: #f1f7fc;
}

.preparacion-filter-item.active {
  border-color: #1967a3;
  background: #eaf3fb;
  box-shadow:
    inset 4px 0 0 #1967a3;
}

.preparacion-filter-item.active strong {
  color: #0f4c81;
}
.preparacion-filter-item[hidden] {
  display: none;
}

.preparacion-routes-panel .preparacion-selector-item,
.preparacion-communes-panel .preparacion-selector-item {
  min-height: 68px;
  padding: 10px 12px;
  align-items: flex-start;
}

.preparacion-selector-main {
  min-width: 0;
  flex: 1 1 auto;
}

.preparacion-routes-panel .preparacion-selector-main strong,
.preparacion-communes-panel .preparacion-selector-main strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.2;
}

.preparacion-routes-panel .preparacion-selector-main small,
.preparacion-communes-panel .preparacion-selector-main small {
  display: block;
  margin-top: 5px;
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: initial;
}

.preparacion-route-description {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.preparacion-routes-panel .preparacion-selector-values,
.preparacion-communes-panel .preparacion-selector-values {
  flex: 0 0 90px;
  min-width: 90px;
  padding-left: 10px;
  text-align: right;
}

.preparacion-active-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid #bdd8ed;
  border-radius: 9px;
  background: #f1f7fc;
  color: #526174;
  font-size: 0.78rem;
}

.preparacion-active-filter[hidden] {
  display: none;
}

.preparacion-active-filter strong {
  color: #0f4c81;
}

.preparacion-active-filter button {
  margin-left: auto;
  padding: 5px 9px;
  border: 1px solid #b7ccdc;
  border-radius: 7px;
  background: #fff;
  color: #0f4c81;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.preparacion-active-filter button:hover {
  background: #eaf3fb;
}

.preparacion-filter-item[hidden],
.preparacion-orders-table tr[hidden] {
  display: none;
}

.preparacion-planning-panel {
  margin-bottom: 16px;
}

.preparacion-planning-panel[hidden] {
  display: none;
}

.preparacion-planning-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #bdd8ed;
  border-radius: 10px;
  background: #f1f7fc;
}

.preparacion-planning-notice strong {
  flex: 0 0 auto;
  color: #0f4c81;
  font-size: 0.8rem;
}

.preparacion-planning-notice span {
  color: #5d6d80;
  font-size: 0.76rem;
}

.preparacion-sequences {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.preparacion-sequence-card {
  padding: 16px;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #fafcfe;
}

.preparacion-sequence-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.preparacion-sequence-header > div:first-child {
  margin-right: auto;
}

.preparacion-sequence-header div {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.preparacion-sequence-header span {
  color: #68768a;
  font-size: 0.75rem;
}

.preparacion-sequence-header strong {
  color: #17263a;
  font-size: 1.25rem;
}

.preparacion-sequence-remove {
  padding: 5px 8px;
  border: 1px solid #e3b8be;
  border-radius: 7px;
  background: #fff;
  color: #9c3340;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.preparacion-sequence-remove:hover {
  background: #fff2f4;
}

.preparacion-sequence-fields {
  display: grid;
  grid-template-columns:
    minmax(280px, 1.6fr)
    minmax(170px, 0.9fr)
    minmax(220px, 1.2fr)
    minmax(110px, 0.55fr)
    minmax(130px, 0.65fr)
    minmax(130px, 0.65fr)
    minmax(80px, 0.4fr);
  gap: 12px;
  align-items: end;
}

.preparacion-sequence-fields label,
.preparacion-sequence-value {
  min-width: 0;
}

.preparacion-sequence-fields label > span,
.preparacion-sequence-value > span {
  display: block;
  margin-bottom: 5px;
  color: #68768a;
  font-size: 0.7rem;
  font-weight: 700;
}

.preparacion-sequence-fields select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #fff;
  color: #17263a;
}

.preparacion-sequence-value strong {
  display: block;
  min-height: 38px;
  padding: 8px 9px;
  border: 1px solid #e1e8ef;
  border-radius: 8px;
  background: #fff;
  color: #17263a;
  font-size: 0.8rem;
  line-height: 1.35;
}

.preparacion-capacity {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f5f8fb;
}

.preparacion-capacity.success {
  background: #eef9f4;
}

.preparacion-capacity.warning {
  background: #fff8e6;
}

.preparacion-capacity.danger {
  background: #fff0f2;
}

.preparacion-capacity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 0.76rem;
}

.preparacion-capacity.success
.preparacion-capacity-header strong {
  color: #17724d;
}

.preparacion-capacity.warning
.preparacion-capacity-header strong {
  color: #8a6100;
}

.preparacion-capacity.danger
.preparacion-capacity-header strong {
  color: #a12c3a;
}

.preparacion-capacity-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe7ee;
}

.preparacion-capacity-progress div {
  height: 100%;
  border-radius: inherit;
  background: #1f9d68;
}

.preparacion-capacity.warning
.preparacion-capacity-progress div {
  background: #d99a00;
}

.preparacion-capacity.danger
.preparacion-capacity-progress div {
  background: #dc3545;
}

.preparacion-sequence-warning {
  display: block;
  margin-top: 7px;
  color: #8a6100;
  font-size: 0.7rem;
  font-weight: 700;
}

.preparacion-sequence-actions {
  margin-top: 14px;
}

@media (max-width: 1200px) {
  .preparacion-sequence-fields {
    grid-template-columns:
      repeat(
        2,
        minmax(180px, 1fr)
      );
  }
}

@media (max-width: 700px) {
  .preparacion-sequences {
    grid-template-columns: 1fr;
  }

  .preparacion-sequence-fields {
    grid-template-columns: 1fr;
  }

  .preparacion-planning-notice {
    align-items: flex-start;
    flex-direction: column;
  }
}

.preparacion-order-sequence {
  min-width: 115px;
  padding: 5px 7px;
  border: 1px solid #cbd7e3;
  border-radius: 7px;
  background: #fff;
  color: #17263a;
  font-size: 0.72rem;
  font-weight: 700;
}

.preparacion-order-sequence:focus {
  border-color: #1967a3;
  outline: none;
  box-shadow:
    0 0 0 2px
    rgba(25, 103, 163, 0.12);
}

.preparacion-order-sequence:disabled {
  cursor: not-allowed;
  background: #edf1f5;
  color: #7a8795;
}

.preparacion-row-changed {
  background: #fffbea;
}

.preparacion-row-changed td:first-child {
  box-shadow:
    inset 4px 0 0 #d99a00;
}

.preparacion-badge.pending {
  color: #725300;
  background: #fff0bd;
}

.preparacion-sequence-orders {
  display: inline-block;
  margin-left: 5px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #eaf3fb;
  color: #0f4c81;
  font-size: 0.67rem;
  font-weight: 700;
}

.preparacion-sequence-cell {
  white-space: nowrap;
}

.preparacion-order-route {
  width: 100%;
  min-width: 190px;
  max-width: 260px;
  padding: 5px 28px 5px 7px;
  border: 1px solid #cbd7e3;
  border-radius: 7px;
  background: #fff;
  color: #17263a;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preparacion-order-route:focus,
.preparacion-trip-input:focus {
  border-color: #1967a3;
  outline: none;
  box-shadow:
    0 0 0 2px
    rgba(25, 103, 163, 0.12);
}

.preparacion-route-plan-cell {
  min-width: 250px;
  white-space: nowrap;
}

.preparacion-trip-input {
  width: 85px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #fff;
  color: #17263a;
  font-weight: 700;
}

.preparacion-trip-input:disabled {
  background: #edf1f5;
  color: #7a8795;
}

.preparacion-vehicle-repeat-warning {
  display: block;
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #fff0bd;
  color: #725300;
  font-size: 0.7rem;
  font-weight: 700;
}

.preparacion-rutas-page
.dashboard-shell {
  width: calc(100% - 24px);
  max-width: none;
}

.preparacion-rutas-page
.preparacion-orders-panel {
  width: 100%;
  max-width: none;
}

.preparacion-rutas-page
.table-responsive {
  width: 100%;
}

.preparacion-sequence-clear {
  padding: 5px 8px;
  border: 1px solid #b7ccdc;
  border-radius: 7px;
  background: #ffffff;
  color: #0f4c81;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.preparacion-sequence-clear:hover {
  background: #eaf3fb;
}

.preparacion-capacity-free {
  color: #17724d !important;
}

.preparacion-capacity-excess {
  color: #a12c3a !important;
  background: #fff0f2 !important;
  border-color: #efc2c8 !important;
}

.preparacion-routes-panel
.preparacion-filter-item.has-vehicle {
  border-color: #8fd4b1;
  background: #edf9f3;
}

.preparacion-routes-panel
.preparacion-filter-item.has-vehicle:hover {
  border-color: #55b889;
  background: #e3f6ec;
}

.preparacion-routes-panel
.preparacion-filter-item.has-vehicle.active {
  border-color: #1967a3;
  background: #e7f2fb;
}

.preparacion-route-vehicle-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #d9f3e5;
  color: #17724d;
  font-size: 0.64rem;
  font-weight: 800;
  line-height: 1.25;
}

.preparacion-trailer-select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #cbd7e3;
  border-radius: 8px;
  background: #fff;
  color: #17263a;
  font-weight: 700;
}

.preparacion-trailer-select:disabled {
  background: #edf1f5;
  color: #7a8795;
  cursor: not-allowed;
}

.preparacion-planning-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preparacion-planning-header-actions
#preparacionSaveRoute {
  white-space: nowrap;
}

.preparacion-assign-order {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  padding: 7px 13px;
  border: 1px solid #1764a2;
  border-radius: 6px;
  background: #1764a2;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.preparacion-assign-order:hover {
  background: #104c7e;
}

.preparacion-assign-order:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================
   RUTAS3 - IDENTIFICADOR DE PLANTA
   PPA / PFT / PSL
   ========================================= */

.site-identifier {
  --site-color: #1456a0;
  --site-background: #e4efff;
  --site-border: #b9d5fa;

  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;

  max-width: 100%;
  margin-bottom: 10px;
  padding: 7px 11px;

  border: 1px solid var(--site-border);
  border-radius: 11px;

  background: var(--site-background);
  color: var(--site-color);

  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: normal;
}

.site-identifier__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;

  border-radius: 50%;
  background: var(--site-color);
}

.site-identifier__name {
  font-weight: 500;
  font-size: 13px;
  letter-spacing: normal;
}

.site-identifier__code {
  padding: 3px 7px;

  border-radius: 6px;
  background: var(--site-color);
  color: #fff;

  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: normal;
}

/* Paine - PPA */

.site-identifier--ppa {
  --site-color: #1456a0;
  --site-background: #e4efff;
  --site-border: #b9d5fa;
}

/* Osorno - PFT */

.site-identifier--pft {
  --site-color: #096b56;
  --site-background: #ddf5ed;
  --site-border: #a8dfce;
}

/* Concepcion - PSL */

.site-identifier--psl {
  --site-color: #673ab7;
  --site-background: #eee5ff;
  --site-border: #d3bdf6;
}

@media (max-width: 600px) {
  .site-identifier {
    font-size: 12px;
    padding: 7px 10px;
    gap: 6px;
  }
}
