/* ============================================================
   DESIGN SYSTEM — Plataforma Operativa 360
   Paleta Último Kilómetro · Profesional · DM Sans + Barlow
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* ── Paleta Último Kilómetro ── */
  --color-ink:           #17355f;
  --color-ink-dark:      #0f223c;
  --color-blue-cta:      #2ea3f2;
  --color-blue-cta-dark: #1a7fc4;
  --color-cyan:          #46c0e0;
  --color-cyan-light:    #d2f3fa;
  --color-teal:          #126277;

  /* Alias compatibilidad */
  --color-red:           #2ea3f2;
  --color-red-dark:      #1a7fc4;
  --color-red-light:     #e0f4fd;

  /* ── Semánticos ── */
  --color-success:       #1e7e4a;
  --color-success-light: #eaf7f0;
  --color-danger:        #dc2626;
  --color-danger-light:  #fef2f2;
  --color-warning:       #d97706;
  --color-warning-light: #fffbeb;
  --color-purple:        #7e3bd0;
  --color-purple-light:  #f3eeff;

  /* ── Superficies ── */
  --color-bg:            #eef3f9;
  --color-surface:       #ffffff;
  --color-border:        #d0dcea;
  --color-border-strong: #8aa0be;
  --color-text:          #0f223c;
  --color-text-muted:    #5a6e8a;
  --color-text-disabled: #a0b4cc;

  /* ── Alias ── */
  --color-primary:       var(--color-ink);
  --color-primary-dark:  #0f223c;
  --color-primary-light: #ddeafa;
  --color-accent:        var(--color-blue-cta);

  /* ── Layout ── */
  --sidebar-collapsed: 64px;
  --sidebar-expanded:  248px;
  --topbar-height:     60px;

  /* ── Forma ── */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Sombras ── */
  --shadow-xs:  0 1px 2px rgba(15,34,60,.06);
  --shadow-sm:  0 1px 4px rgba(15,34,60,.08), 0 0 0 1px rgba(15,34,60,.04);
  --shadow-md:  0 4px 16px rgba(15,34,60,.10), 0 1px 4px rgba(15,34,60,.06);
  --shadow-lg:  0 8px 32px rgba(15,34,60,.14), 0 2px 8px rgba(15,34,60,.07);
  --shadow-xl:  0 16px 48px rgba(15,34,60,.18), 0 4px 16px rgba(15,34,60,.08);

  /* ── Tipografía ── */
  --font-display: 'Barlow Condensed', sans-serif;
  --font-base:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-lg:   16px;
  --text-xl:   20px;
  --text-2xl:  24px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-base);
  font-size: var(--text-base);
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   SIDEBAR — Último Kilómetro navy gradient
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-collapsed);
  background: linear-gradient(180deg, #0f223c 0%, #17355f 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  overflow: hidden;
  transition: width .22s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.06);
  box-shadow: 4px 0 24px rgba(15,34,60,.25);
}
.sidebar.sidebar--expanded {
  width: var(--sidebar-expanded);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: var(--topbar-height);
  overflow: hidden;
  white-space: nowrap;
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2ea3f2, #46c0e0);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: .5px;
  box-shadow: 0 2px 8px rgba(46,163,242,.4);
}
.sidebar-logo-text {
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .5px;
  line-height: 1;
  opacity: 0;
  transition: opacity .14s ease .07s;
}
.sidebar-logo-sub {
  color: #5a87b8;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0;
  transition: opacity .14s ease .07s;
}
.sidebar.sidebar--expanded .sidebar-logo-text,
.sidebar.sidebar--expanded .sidebar-logo-sub {
  opacity: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 12px 10px 4px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .14s ease .07s;
}
.sidebar.sidebar--expanded .nav-section-label { opacity: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 11px;
  border-radius: var(--radius-sm);
  color: #7aadd4;
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: color .14s, background .14s;
  position: relative;
}
.nav-item:hover {
  background: rgba(70,192,224,.12);
  color: #d2f3fa;
}
.nav-item.activo {
  background: linear-gradient(90deg, rgba(46,163,242,.22), rgba(46,163,242,.08));
  color: #fff;
  border-left: 2px solid #46c0e0;
  padding-left: 9px;
}
.nav-item.activo .nav-icon {
  filter: drop-shadow(0 0 6px rgba(70,192,224,.6));
}
.nav-item .nav-icon {
  font-size: 1.1em;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.nav-item .nav-label {
  opacity: 0;
  transition: opacity .14s ease .07s;
  font-family: var(--font-base);
  font-size: 13px;
  font-weight: 500;
}
.sidebar.sidebar--expanded .nav-label { opacity: 1; }

/* Tooltip colapsado */
.nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-collapsed) + 12px);
  background: #0f223c;
  border: 1px solid rgba(255,255,255,.1);
  color: #d2f3fa;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
  z-index: 300;
  box-shadow: var(--shadow-md);
}
.sidebar:not(.sidebar--expanded) .nav-item:hover::after { opacity: 1; }

.nav-item--logout {
  margin-top: auto;
  margin-bottom: 8px;
  color: #4a6a8a;
}
.nav-item--logout:hover {
  color: #d2f3fa;
  background: rgba(220,38,38,.10);
}

/* ── Botón toggle sidebar ─────────────────────────── */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: #7aadd4;
  cursor: pointer;
  font-size: 14px;
  transition: background .14s, color .14s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(70,192,224,.18); color: #d2f3fa; }
.sidebar-logo { justify-content: space-between; }
.sidebar-logo-left { display: flex; align-items: center; gap: 12px; overflow: hidden; }

/* ── Grupos de navegación ─────────────────────────── */
.nav-group { display: flex; flex-direction: column; }

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 11px;
  color: rgba(255,255,255,.35);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  transition: color .14s, background .14s;
  user-select: none;
  margin-top: 6px;
}
.nav-group-header:hover { color: rgba(255,255,255,.6); background: rgba(255,255,255,.04); }
.nav-group-header .grp-arrow {
  margin-left: auto;
  font-size: 9px;
  opacity: .5;
  transition: transform .18s;
  flex-shrink: 0;
}
.nav-group.open .nav-group-header .grp-arrow { transform: rotate(90deg); }

/* En modo colapsado: ocultar headers de grupo */
.sidebar:not(.sidebar--expanded) .nav-group-header { display: none; }

/* Items dentro del grupo */
.nav-group-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height .22s cubic-bezier(.4,0,.2,1);
}
.nav-group.open .nav-group-items { max-height: 600px; }

/* En modo colapsado: mostrar todos los items sin acordeón */
.sidebar:not(.sidebar--expanded) .nav-group-items { max-height: 600px; }

/* Sub-ítems (Puntos, Historial) */
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 11px 7px 28px;
  border-radius: var(--radius-sm);
  color: #5a87b8;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: color .14s, background .14s;
}
.nav-sub-item:hover { background: rgba(70,192,224,.10); color: #d2f3fa; }
.nav-sub-item.activo { color: #fff; background: rgba(46,163,242,.15); }
.nav-sub-item .nav-icon { font-size: 1em; flex-shrink: 0; width: 22px; text-align: center; }
.nav-sub-item .nav-label { opacity: 0; transition: opacity .14s ease .07s; font-size: 12px; }
.sidebar.sidebar--expanded .nav-sub-item .nav-label { opacity: 1; }

/* En modo colapsado, sub-ítems ocultos */
.sidebar:not(.sidebar--expanded) .nav-sub-item { display: none; }

/* Main wrapper */
.main-wrapper {
  margin-left: var(--sidebar-collapsed);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   TOPBAR — limpia, con sombra suave
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 6px rgba(15,34,60,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--color-ink);
  margin: 0;
  white-space: nowrap;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Page content */
.page-content {
  padding: 28px;
  flex: 1;
}

/* ============================================================
   FILTRO DE FECHAS
   ============================================================ */
.date-chips {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.date-chip {
  padding: 5px 14px;
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all .14s;
}
.date-chip:hover {
  border-color: var(--color-blue-cta);
  color: var(--color-blue-cta);
  background: rgba(46,163,242,.06);
}
.date-chip.activo {
  background: var(--color-blue-cta);
  border-color: var(--color-blue-cta);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46,163,242,.35);
}
.date-custom {
  display: none;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}
.date-custom.visible { display: flex; }
.date-custom input[type="date"] {
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-family: var(--font-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color .14s, box-shadow .14s;
}
.date-custom input[type="date"]:focus {
  outline: none;
  border-color: var(--color-blue-cta);
  box-shadow: 0 0 0 3px rgba(46,163,242,.15);
}
.date-custom button {
  padding: 5px 14px;
  background: var(--color-blue-cta);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-base);
  letter-spacing: .4px;
  text-transform: uppercase;
  transition: background .14s;
}
.date-custom button:hover { background: var(--color-blue-cta-dark); }

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); font-weight: 700; }
.text-muted  { color: var(--color-text-muted); }
.text-label  {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--color-text-muted);
}
.font-semibold { font-weight: 600; }

/* ============================================================
   BOTONES — profesional con transiciones suaves
   ============================================================ */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost, .btn-success {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-base);
  letter-spacing: .4px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .16s ease;
  white-space: nowrap;
  text-transform: uppercase;
}
.btn-primary {
  background: linear-gradient(135deg, #2ea3f2, #1a7fc4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46,163,242,.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1a7fc4, #17355f);
  box-shadow: 0 4px 16px rgba(46,163,242,.45);
  transform: translateY(-1px);
}
.btn-success {
  background: linear-gradient(135deg, #1e7e4a, #155e36);
  color: #fff;
  box-shadow: 0 2px 8px rgba(30,126,74,.30);
}
.btn-success:hover {
  box-shadow: 0 4px 14px rgba(30,126,74,.40);
  transform: translateY(-1px);
}
.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 2px 8px rgba(220,38,38,.30);
}
.btn-danger:hover {
  box-shadow: 0 4px 14px rgba(220,38,38,.40);
  transform: translateY(-1px);
}
.btn-secondary {
  background: transparent;
  color: var(--color-blue-cta);
  border: 1.5px solid var(--color-blue-cta);
}
.btn-secondary:hover {
  background: var(--color-blue-cta);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46,163,242,.30);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  border-color: var(--color-blue-cta);
  color: var(--color-blue-cta);
  background: rgba(46,163,242,.06);
}
.btn-sm { padding: 6px 14px; font-size: 10px; }

/* ============================================================
   BADGES — rounded chips
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-active    { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-done      { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-pending   { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.badge-cancelled { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-inactive  { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.badge-alert     { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-visited   { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }

/* ============================================================
   CARDS / KPI — paneles con elevación
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  background: linear-gradient(135deg, #f8fbff 0%, #f2f6fb 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body { padding: 20px; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px 22px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s, transform .16s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--color-blue-cta);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.kpi-card--blue::before   { background: linear-gradient(90deg, #2ea3f2, #46c0e0); }
.kpi-card--green::before  { background: linear-gradient(90deg, #1e7e4a, #22c55e); }
.kpi-card--red::before    { background: linear-gradient(90deg, #dc2626, #f87171); }
.kpi-card--yellow::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.kpi-card--orange::before { background: linear-gradient(90deg, #ea580c, #fb923c); }
.kpi-card--cyan::before   { background: linear-gradient(90deg, #46c0e0, #7dd3fc); }
.kpi-card--purple::before { background: linear-gradient(90deg, #7e3bd0, #a855f7); }

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  font-family: var(--font-base);
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  color: var(--color-ink);
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -.5px;
}
.kpi-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ============================================================
   DATA TABLE — profesional, legible
   ============================================================ */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead tr {
  background: linear-gradient(135deg, #17355f 0%, #1e4a7a 100%);
  border-bottom: none;
}
.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: rgba(210,243,250,.90);
  font-weight: 700;
  font-family: var(--font-base);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: rgba(238,243,249,.45); }
.data-table tbody tr:hover { background: rgba(46,163,242,.06); }

/* Números en mono */
.data-table td.col-number,
.data-table td.col-time,
.data-table td.col-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Avatar de iniciales */
.avatar-initials {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.av-0 { background: #dbeafe; color: #1e40af; }
.av-1 { background: #dcfce7; color: #15803d; }
.av-2 { background: #fef9c3; color: #854d0e; }
.av-3 { background: #fce7f3; color: #9d174d; }
.av-4 { background: #ede9fe; color: #6d28d9; }
.av-5 { background: #ffedd5; color: #9a3412; }

.cargo-chip {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  background: var(--color-primary-light);
  color: var(--color-text-muted);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  display: inline-block;
  margin-top: 2px;
}

/* ============================================================
   MODAL — elevado, profesional
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,34,60,.6);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px 16px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modal-in .20s cubic-bezier(.4,0,.2,1);
  border: 1px solid rgba(255,255,255,.8);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  background: linear-gradient(135deg, #17355f 0%, #1e4a7a 100%);
  color: #fff;
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.modal-header.danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}
.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.55);
  font-size: 1.3em;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color .12s;
  border-radius: 4px;
}
.modal-close:hover { color: #fff; background: rgba(255,255,255,.12); }
.modal-body  { padding: 24px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ============================================================
   FORMULARIOS — inputs pulidos
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-text-muted);
}
.form-input, .form-select, .form-textarea {
  padding: 9px 13px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .14s, box-shadow .14s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-blue-cta);
  box-shadow: 0 0 0 3px rgba(46,163,242,.16);
}
.form-input:hover, .form-select:hover, .form-textarea:hover {
  border-color: var(--color-border-strong);
}
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 20px;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success {
  background: var(--color-success-light);
  color: #15803d;
  border-left-color: var(--color-success);
}
.alert-danger {
  background: var(--color-danger-light);
  color: #b91c1c;
  border-left-color: var(--color-danger);
}
.alert-info {
  background: #e0f4fd;
  color: #17355f;
  border-left-color: var(--color-blue-cta);
}
.alert-warning {
  background: var(--color-warning-light);
  color: #92400e;
  border-left-color: var(--color-warning);
}

/* ============================================================
   SECTION HEADER
   ============================================================ */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--color-border);
}
.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--color-ink);
  margin: 0;
}
.section-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 3px 0 0;
  font-weight: 400;
}

/* ============================================================
   CHART BOX
   ============================================================ */
.chart-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-box h3 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-ink);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

/* ============================================================
   CHARTS GRID
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

/* ============================================================
   UTILIDADES
   ============================================================ */
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-4         { margin-top: 16px; }
.mb-4         { margin-bottom: 16px; }
.mb-6         { margin-bottom: 24px; }
.w-full       { width: 100%; }
.text-center  { text-align: center; }

/* ============================================================
   INTERACTIVE DASHBOARD
   ============================================================ */
.kpi-card--clickable {
  cursor: pointer;
  transition: box-shadow .16s, transform .16s;
  user-select: none;
}
.kpi-card--clickable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.kpi-card--clickable.kpi-active {
  box-shadow: 0 0 0 2px var(--color-blue-cta), var(--shadow-md);
  transform: translateY(-3px);
}
.kpi-card--clickable.kpi-active::before {
  height: 4px;
}

.dash-row-2fr1fr {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.dash-row-1fr1fr {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1000px) {
  .dash-row-2fr1fr,
  .dash-row-1fr1fr { grid-template-columns: 1fr; }
}

/* Filter bar */
.dash-filter-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: var(--text-sm);
  color: #92400e;
  flex-wrap: wrap;
}
.dash-filter-bar.visible { display: flex; }
.dash-filter-bar .filter-label { font-weight: 700; }

.dash-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--color-blue-cta);
  color: #fff;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.dash-filter-chip .chip-remove {
  cursor: pointer;
  opacity: .7;
  font-size: 1.1em;
}
.dash-filter-chip .chip-remove:hover { opacity: 1; }
.dash-filter-clear {
  margin-left: auto;
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--color-warning);
  text-decoration: none;
  background: none;
  border: none;
  font-family: var(--font-base);
}
.dash-filter-clear:hover { color: var(--color-danger); }

/* Ranking list */
.ranking-list { list-style: none; padding: 0; margin: 0; }
.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .12s;
  font-size: var(--text-sm);
  border-radius: var(--radius-xs);
  margin: 1px 0;
}
.ranking-item:last-child { border-bottom: none; }
.ranking-item:hover { background: rgba(46,163,242,.06); }
.ranking-position {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, #2ea3f2, #46c0e0);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ranking-name  { flex: 1; font-weight: 500; }
.ranking-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--color-ink);
}
.ranking-bar-wrap {
  width: 100px;
  height: 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  overflow: hidden;
  flex-shrink: 0;
}
.ranking-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ea3f2, #46c0e0);
  border-radius: 20px;
  transition: width .35s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #fff;
  font-weight: 700;
  min-width: 28px;
  white-space: nowrap;
}

/* Horizontal bar chart list */
.hbar-list { list-style: none; padding: 0; margin: 0; }
.hbar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .12s;
  font-size: var(--text-sm);
}
.hbar-item:last-child { border-bottom: none; }
.hbar-item:hover { background: rgba(46,163,242,.06); }
.hbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  background: var(--color-primary-light);
  color: var(--color-ink);
}
.hbar-name {
  width: 120px;
  flex-shrink: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  position: relative;
}
.hbar-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ea3f2, #46c0e0);
  border-radius: var(--radius-xs);
  transition: width .35s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: #fff;
  font-weight: 600;
  min-width: 28px;
}

/* Sync button */
.btn-sync {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  background: linear-gradient(135deg, #1e7e4a, #155e36);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  font-family: var(--font-base);
  cursor: pointer;
  transition: all .16s;
  box-shadow: 0 2px 8px rgba(30,126,74,.25);
}
.btn-sync:hover {
  box-shadow: 0 4px 14px rgba(30,126,74,.35);
  transform: translateY(-1px);
}
.btn-sync:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sync .sync-spinner {
  display: none;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn-sync.loading .sync-spinner { display: block; }
.btn-sync.loading .sync-icon   { display: none; }
.btn-sync.syncing .sync-spinner { display: block; }
.btn-sync.syncing .sync-icon   { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Table pagination */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}
.table-pagination button {
  padding: 5px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  font-family: var(--font-base);
  cursor: pointer;
  transition: all .14s;
}
.table-pagination button:hover {
  border-color: var(--color-blue-cta);
  color: var(--color-blue-cta);
}
.table-pagination button.active {
  background: var(--color-blue-cta);
  border-color: var(--color-blue-cta);
  color: #fff;
  box-shadow: 0 2px 6px rgba(46,163,242,.30);
}
.table-pagination button:disabled { opacity: .4; cursor: default; }
.table-pagination .page-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0 8px;
  font-family: var(--font-mono);
}

/* ============================================================
   MODAL WIDE / TABS
   ============================================================ */
.modal--wide  { max-width: 920px; }
.modal--order { max-width: 660px; }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  padding: 0 22px;
  background: var(--color-bg);
  gap: 0;
}
.modal-tab {
  padding: 11px 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-base);
  position: relative;
  transition: color .12s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.modal-tab:hover { color: var(--color-ink); }
.modal-tab.active {
  color: var(--color-blue-cta);
  border-bottom-color: var(--color-blue-cta);
}

.modal-tab-panel { display: none; padding: 22px; }
.modal-tab-panel.active { display: block; overflow-y: auto; }

/* Scrollable body area within modal — header stays pinned */
.modal-tabs ~ .modal-tab-panel,
.modal-body--scroll {
  overflow-y: auto;
  flex: 1;
}

/* Mini KPIs inside modal */
.mini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.mini-kpi {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-blue-cta);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.mini-kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--color-ink);
  line-height: 1.1;
}
.mini-kpi-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 3px;
}

/* Attendance calendar */
.attendance-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 12px;
}
.cal-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: center;
  padding: 4px 0;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text);
  position: relative;
}
.cal-day--empty   { background: transparent; }
.cal-day--rest    { background: #e8eef6; color: var(--color-text-disabled); }
.cal-day--ontime  { background: #dcfce7; color: #15803d; }
.cal-day--late    { background: #fee2e2; color: #991b1b; }
.cal-day--extra   { background: #fef9c3; color: #854d0e; }
.cal-day--future  { background: var(--color-bg); color: var(--color-text-disabled); }

/* Order detail modal */
.order-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ============================================================
   PAGE HEADER COMPONENT
   ============================================================ */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--color-ink);
  letter-spacing: .3px;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
}
.page-header-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 4px 0 0;
}

/* ============================================================
   TABLA: estilos table clásica
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table thead tr { background: var(--color-bg); }
.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(46,163,242,.04); }

/* ============================================================
   SCROLLBAR — suave, de marca
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
  background: #b0c4de;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-blue-cta); }

/* ============================================================
   FOCUS RING GLOBAL
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--color-blue-cta);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ============================================================
   FRANJA HORARIA WIDGET
   ============================================================ */
.franja-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.franja-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.franja-pct {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--color-ink);
}
.franja-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--color-text-muted);
}
.franja-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.franja-bar-wrap {
  height: 8px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
}
.franja-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}
.franja-bar--conf   { background: #22c55e; }
.franja-bar--noconf { background: #f97316; }

.franja-correlation {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}
.franja-corr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  padding: 3px 0;
  color: var(--color-ink);
}

/* ============================================================
   INSPECCIÓN DE VEHÍCULOS — encabezado logo + leyenda colores
   ============================================================ */
.insp-header {
  background: #46c0e0;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.insp-header svg {
  height: 38px;
  width: auto;
  flex-shrink: 0;
}
.insp-header-titulo {
  text-align: right;
  color: #17355f;
}
.insp-header-titulo strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
}
.insp-header-titulo span {
  font-size: 11px;
  opacity: .8;
}
.insp-leyenda {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 2px solid #e2e8f0;
  font-size: 12px;
}
.insp-cal {
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 700;
  border: 1px solid;
}
.insp-cal--b  { background: #dcfce7; color: #15803d; border-color: #86efac; }
.insp-cal--r  { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.insp-cal--m  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.insp-cal--na { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

/* Tablero de sesión de inspección (en /vehiculos) */
.sesion-tablero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}
.sesion-tablero h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--color-ink);
}
.sesion-vehiculos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.sesion-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--color-surface);
  transition: border-color .15s;
}
.sesion-card--borrador { border-color: #fcd34d; background: #fffbeb; }
.sesion-card--completa { border-color: #86efac; background: #f0fdf4; }
.sesion-card-placa { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.sesion-card-badges { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.sesion-card-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
  background: #f1f5f9;
  color: #64748b;
}
.sesion-card-badge--ok { background: #dcfce7; color: #15803d; }
.sesion-card-badge--warn { background: #fef3c7; color: #92400e; }
.sesion-progreso-wrap {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
}
.sesion-progreso-bar-bg {
  background: #e2e8f0;
  border-radius: 99px;
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
}
.sesion-progreso-bar-fill {
  height: 100%;
  background: #22c55e;
  border-radius: 99px;
  transition: width .4s;
}
