/* ============================================================
   FormoPack Express — Estilos Corporativos (Premium UI)
   ============================================================ */

:root {
  /* Paleta principal — NO cambiar, solo mantener */
  --primary: #004481;
  --primary-light: #1a6bbf;
  --primary-dark: #003366;
  --sidebar-bg: #0a192f;
  --sidebar-active: rgba(255,255,255,0.08);
  
  /* Neutrales */
  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --text-main: #1a2332;
  --text-muted: #6c757d;
  --border: #e0e6ef;
  
  /* Sombras */
  --shadow-sm: 0 1px 4px rgba(0,68,129,0.08);
  --shadow-md: 0 4px 16px rgba(0,68,129,0.12);
  --shadow-lg: 0 8px 32px rgba(0,68,129,0.16);
  --shadow-hover: 0 8px 24px rgba(0,68,129,0.18);
  
  /* Bordes */
  --radius-sm: 6px;
  --radius-card: 10px;
  --radius-lg: 16px;
  
  /* Transiciones */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;

  /* Legacy Compat */
  --primary-hover: var(--primary-light);
  --secondary: #e9ecef;
  --success: #28a745;
  --warning: #ffc107;
  --info: #17a2b8;
  --danger: #dc3545;
  --sidebar-w: 240px;
  --sidebar-text: #a0aec0;
  --radius-input: var(--radius-sm);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
}

/* ──────────────── LAYOUT ──────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  width: 100%;
}

.main-content {
  padding: 28px 32px;
  background: var(--bg-main);
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  width: calc(100% - var(--sidebar-w));
  max-width: 100%;
}

/* ──────────────── SIDEBAR ──────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: var(--transition);
}

.sidebar-header-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.2);
}

.sidebar-close-btn {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 25, 47, 0.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.sidebar-active-body .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body.sidebar-active-body {
  overflow: hidden !important;
}

.sidebar-brand {
  padding: 20px;
  background: transparent;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  flex: 1;
}
.sidebar-brand .brand-icon { font-size: 24px; color: #4da3ff; }
.sidebar-brand .brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: #8892b0;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.nav-section {
  padding: 12px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-link, .sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.nav-link:hover, .sidebar-link:hover {
  background: rgba(255,255,255,0.05);
  transform: translateX(4px);
  color: #ffffff;
}
.nav-link.active, .sidebar-link.active {
  border-left: 3px solid #4da3ff;
  background: var(--sidebar-active);
  color: #ffffff;
}
.nav-link .nav-icon, .sidebar-link .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  background: rgba(0,0,0,0.15);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-footer .user-info { flex: 1; }
.sidebar-footer .user-name { font-weight: 600; color: #ffffff; font-size: 13px; }
.sidebar-footer .user-role {
  display: block;
  font-size: 11px;
  color: #4da3ff;
  text-transform: capitalize;
}
.sidebar-footer .logout-btn {
  color: #8892b0;
  text-decoration: none;
  font-size: 16px;
  transition: var(--transition);
}
.sidebar-footer .logout-btn:hover { color: #ffffff; }

/* ──────────────── TOPBAR ──────────────── */
.topbar {
  background: #fff;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  margin: -28px -32px 28px -32px; /* Pull into main padding area */
}
.mobile-menu-button { display: none; border: 0; background: transparent; color: var(--primary); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.topbar-title { font-size: 18px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px;}
.topbar-actions { display: flex; gap: 16px; align-items: center; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.topbar-user span { color: var(--text-muted); font-size: 12px; }

/* ──────────────── AVATAR ──────────────── */
.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

/* ──────────────── CARDS ──────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--transition);
  overflow: visible;
  padding: 24px;
  margin-bottom: 20px;
}

.card-body {
  overflow: visible;
}
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f8fafd 0%, #f0f4f8 100%);
  margin: -24px -24px 20px -24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ──────────────── MÉTRICAS ──────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  border-top: 3px solid var(--primary);
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.metric-card.green  { border-top-color: var(--success); }
.metric-card.yellow { border-top-color: var(--warning); }
.metric-card.blue   { border-top-color: var(--info); }
.metric-card.red    { border-top-color: var(--danger); }

.metric-icon { font-size: 24px; color: var(--text-muted); margin-bottom: 12px; opacity: 0.8; }
.metric-card .metric-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  margin: 8px 0;
  color: var(--text-main);
  letter-spacing: -0.5px;
}
.metric-card .metric-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

/* ──────────────── FORMS ──────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}
.form-control {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: var(--transition);
  font-size: 14px;
  width: 100%;
  background: #ffffff;
  color: var(--text-main);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,68,129,0.12);
}
.form-control::placeholder { color: #adb5bd; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* ──────────────── BUTTONS ──────────────── */
.btn {
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.3s ease;
}
.btn:hover::after {
  background: rgba(255,255,255,0.1);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(0,68,129,0.3);
}
.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 12px rgba(0,68,129,0.4);
  transform: translateY(-1px);
}
.btn-secondary { background: #f8f9fa; border-color: var(--border); color: var(--text-main); }
.btn-secondary:hover { background: #e2e6ea; }
.btn-success  { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }
.btn-warning  { background: var(--warning); color: #212529; }
.btn-warning:hover { background: #e0a800; }
.btn-danger   { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ──────────────── TABLES ──────────────── */
.table-responsive { overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
table { 
  width: 100%; 
  border-collapse: separate; 
  border-spacing: 0; 
  font-size: 14px; 
}
table tr:first-child th:first-child { border-top-left-radius: var(--radius-sm); }
table tr:first-child th:last-child { border-top-right-radius: var(--radius-sm); }
thead th {
  background: #f0f4f8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: #f8fafd; }
tbody tr:nth-child(even) { background: rgba(0,0,0,0.01); }

/* ──────────────── BADGES / STATUS ──────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
/* Envíos */
.badge-recibido { background: #e3f2fd; color: #1565c0; }
.badge-en_planta { background: #fff8e1; color: #f57f17; }
.badge-en_ruta { background: #e8f5e9; color: #2e7d32; }
.badge-entregado { background: #e8f5e9; color: #1b5e20; font-weight: 700; }
.badge-fallido { background: #ffebee; color: #c62828; }
.badge-devolucion { background: #ffebee; color: #c62828; }
/* Vehículos */
.badge-disponible { background: #e8f5e9; color: #2e7d32; }
.badge-mantenimiento { background: #fff8e1; color: #e65100; }
.badge-fuera_de_servicio { background: #ffebee; color: #c62828; }
/* Pagos */
.badge-efectivo { background: #f3e5f5; color: #6a1b9a; }
.badge-digital { background: #e0f7fa; color: #006064; }
.badge-mercadopago { background: #e3f2fd; color: #009ee3; }
.badge-cuenta_corriente { background: #fff3e0; color: #e65100; }
.badge-pagado { background: #e8f5e9; color: #1b5e20; font-weight: 600; }
.badge-pendiente { background: #ffebee; color: #c62828; font-weight: 600; }
/* Roles */
.badge-administrador { background: #fbe9e7; color: #bf360c; }
.badge-recepcionista { background: #e3f2fd; color: #1565c0; }
.badge-chofer { background: #e8f5e9; color: #1b5e20; }

/* ──────────────── TIMELINE ──────────────── */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary), transparent);
}
.timeline-item {
  position: relative;
  padding: 12px 0 20px;
  transition: var(--transition);
}
.timeline-dot {
  position: absolute;
  left: -26px;
  top: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  box-shadow: 0 0 0 3px white, 0 0 0 5px var(--primary);
  z-index: 1;
}
.timeline-dot.done { border-color: var(--primary); color: white; }
.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 3px white, 0 0 0 5px var(--success); }
.timeline-dot.warning { background: var(--warning); box-shadow: 0 0 0 3px white, 0 0 0 5px var(--warning); }
.timeline-dot.danger { background: var(--danger); box-shadow: 0 0 0 3px white, 0 0 0 5px var(--danger); }
.timeline-date { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.timeline-estado { font-weight: 700; font-size: 14px; color: var(--text-main); }
.timeline-obs { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ──────────────── ALERTS / FLASH ──────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  border: none;
  border-left: 4px solid;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  animation: slideDown 0.3s ease;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.alert-success { background: #e8f5e9; color: #1b5e20; border-color: #4caf50; }
.alert-danger { background: #ffebee; color: #c62828; border-color: #ef5350; }
.alert-warning { background: #fff8e1; color: #e65100; border-color: #ff9800; }
.alert-info { background: #e3f2fd; color: #1565c0; border-color: #2196f3; }

/* ──────────────── GESTIÓN DE USUARIOS ──────────────── */
.user-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 12px;
  background: var(--bg-card);
  transition: var(--transition);
}
.user-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.user-card-info { flex: 1; }
.user-card-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.user-card-email { color: var(--text-muted); font-size: 13px; }
.user-card-actions { display: flex; gap: 8px; align-items: center; }

/* ──────────────── MÓDULO CHOFER ──────────────── */
.driver-intro { display:flex; justify-content:space-between; gap:20px; align-items:flex-end; margin-bottom:22px; }
.driver-intro h1 { margin:6px 0; font-size:28px; color:var(--text-main); font-weight: 700; }
.driver-intro p, .driver-route p { color:var(--text-muted); font-size:14px; }
.eyebrow { color:var(--primary); font-size:11px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; }
.driver-status { color:var(--success); font-size:13px; font-weight:600; }
.offline-banner, .queue-banner { padding:14px 16px; margin-bottom:20px; border-radius:var(--radius-input); font-size:14px; display:flex; gap:12px; align-items:center; box-shadow: var(--shadow-sm); font-weight: 500; }
.offline-banner[hidden], .queue-banner[hidden] { display:none; }
.offline-banner { color:#7a5200; background:#fff5d6; border:1px solid #f0d47b; }
.queue-banner { color:#174d72; background:#eaf5ff; border:1px solid #b8daf2; }
.driver-route-head { display:flex; justify-content:space-between; align-items:flex-start; gap:18px; margin-bottom: 20px; }
.driver-route-head h2 { margin:7px 0 4px; font-size:20px; font-weight: 700; }
.route-code { color:var(--primary); font-size:13px; font-weight:700; background: #e3f2fd; padding: 4px 8px; border-radius: 4px; }
.driver-deliveries { display:grid; gap:16px; }
.delivery-item { display:grid; grid-template-columns:36px minmax(0, 1fr) minmax(280px, .9fr); align-items:start; gap:16px; border:1px solid var(--border); border-radius:var(--radius-card); padding:16px; background: var(--bg-card); transition: var(--transition); box-shadow: var(--shadow-sm); }
.delivery-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.delivery-order { width:36px; height:36px; display:grid; place-items:center; border-radius:50%; background:#e3f2fd; color:var(--primary); font-weight:700; font-size: 14px; }
.delivery-main { min-width:0; overflow-wrap:anywhere; }
.delivery-meta { display:flex; align-items:center; gap:8px; font-size:13px; margin-bottom: 4px; }
.delivery-meta strong { overflow-wrap:anywhere; }
.delivery-main h3 { margin:0 0 4px; font-size:16px; font-weight: 600; }
.delivery-main p { margin:0 0 6px; overflow-wrap:anywhere; }
.delivery-main small { color:var(--text-muted); font-size: 13px; }
.delivery-actions { display:grid; align-content:start; gap:10px; min-width:0; }
.delivery-actions > .btn { justify-self:start; }
.delivery-done { border-color:#c8e6c9; background:#f1f8e9; }
.delivery-done .delivery-order { background: #c8e6c9; color: #2e7d32; }
.delivery-failed { border-color:#ffcdd2; background:#ffebee; }
.delivery-result { color:var(--success); font-size:13px; font-weight:700; }
.delivery-pending { color:#d97706; font-size:12px; font-weight:700; display:inline-flex; align-items:center; gap:6px; background:#fffbeb; padding:6px 12px; border-radius:var(--radius-input); border:1px solid #fde68a; }
.empty-driver { text-align:center; padding:70px 20px; }
.empty-driver > i { color:var(--primary); font-size:48px; margin-bottom:16px; }
.empty-driver h2 { margin-bottom:8px; font-weight: 600; }
.empty-driver p { color:var(--text-muted); }

/* ──────────────── MODALES ──────────────── */
.modal-backdrop { position:fixed; inset:0; z-index:200; display:grid; place-items:center; padding:20px; background:rgba(10,25,47,.7); backdrop-filter: blur(2px); }
.modal-backdrop[hidden] { display:none; }
.modal-card { width:min(620px,100%); max-height:92vh; overflow:auto; background:#fff; border-radius:var(--radius-card); padding:28px; box-shadow:0 18px 60px rgba(0,0,0,.3); }
.modal-header, .modal-actions { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.modal-header { border-bottom:1px solid var(--border); padding-bottom:16px; margin-bottom:20px; }
.modal-header h2 { margin-top:0; font-size:20px; font-weight: 600; }
.icon-button { border:0; background:transparent; color:var(--text-muted); font-size:24px; cursor:pointer; transition: var(--transition); }
.icon-button:hover { color: var(--danger); transform: scale(1.1); }
.signature-pad { width:100%; height:auto; display:block; border:2px dashed var(--border); border-radius:var(--radius-input); background:#f8f9fa; margin-bottom:12px; touch-action:none; }
.modal-actions { justify-content:flex-end; margin-top:24px; gap: 12px; }

/* ──────────────── RECEPCIÓN ──────────────── */
.bulto-item { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius-input); padding: 16px; margin-bottom: 12px; }
.bulto-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.bulto-numero { font-weight: 700; color: var(--primary); font-size: 13px; text-transform: uppercase; }

.cotizacion-result { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius-card); padding: 24px; text-align: center; }
.cotizacion-total { font-size: 36px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.desglose-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; text-align: left; }
.desglose-row:last-child { border-bottom: none; font-weight: 700; color: var(--primary); font-size: 16px; margin-top: 8px; }

/* Dashboard e interfaces adaptables */
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.history-bars { min-height: 190px; display: flex; align-items: flex-end; justify-content: space-around; gap: 12px; padding: 16px 8px 8px; border-bottom: 1px solid var(--border); }
.history-day { flex: 1; min-width: 34px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.history-value, .history-label { font-size: 11px; color: var(--text-muted); }
.history-bar { width: min(42px, 100%); min-height: 4px; background: var(--primary); border-radius: 4px 4px 0 0; }
.empty-state { color: var(--text-muted); padding: 24px 0; text-align: center; }
.cobro-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.payment-reference { font-size: 11px; color: var(--text-muted); margin-top: 8px; word-break: break-all; }
.delivery-return-form { display:grid; grid-template-columns:minmax(0, 1fr) auto; align-items:end; gap:8px; min-width:0; padding-top:10px; border-top:1px solid rgba(198,40,40,.18); }
.delivery-return-form .form-label { grid-column:1 / -1; margin:0 0 -3px; }
.delivery-return-form textarea { width:100%; min-width:0; min-height:64px; resize:vertical; }
.delivery-return-form .btn { max-width:132px; min-height:44px; white-space:normal; }

/* ──────────────── SKELETON ──────────────── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% center; }
  to { background-position: -200% center; }
}

/* ──────────────── LAYOUT & COMPONENTES RESPONSIVOS ──────────────── */
.page-grid-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}
.page-grid-3col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.cotizador-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
}
.form-actions-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Comprobante de servicio */
.comprobante-card {
  padding: 40px;
}
.comprobante-partes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.comprobante-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}
.comprobante-btn-main {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.comprobante-actions-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.comprobante-actions-secondary .btn {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  min-width: 140px;
}

/* Botones de selección de pago */
.payment-toggle-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.payment-toggle-buttons .btn {
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
  min-width: 110px;
}

/* Filtros de liquidaciones */
.liquidaciones-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 16px;
  align-items: end;
}

/* Filtros y acciones de comprobantes */
.comprobantes-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.comprobantes-actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

/* Utilidades comunes */
.d-flex { display: flex !important; }
.justify-content-center { justify-content: center !important; }
.align-items-center { align-items: center !important; }
.text-center { text-align: center !important; }
.flex-fill { flex: 1 1 auto !important; }
.usuarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.tracking-search-bar {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
}
.page-actions-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

/* ──────────────── RESPONSIVE BREAKPOINTS ──────────────── */
@media (max-width: 992px) {
  .cotizador-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .page-grid-2col {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 1000;
    height: 100vh;
    width: min(280px, 84vw);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    margin-right: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition-fast);
  }
  .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
  }

  .main-content {
    margin-left: 0 !important;
    padding: 14px 12px;
    width: 100%;
    max-width: 100vw;
  }
  
  .topbar {
    padding: 12px 14px;
    margin: -14px -12px 16px -12px;
  }
  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 6px 10px;
  }
  .topbar-title {
    font-size: 15px;
    max-width: calc(100vw - 110px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-user span {
    display: none;
  }

  .page-grid-2col {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .page-grid-3col {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .comprobante-card {
    padding: 20px 14px;
  }
  .comprobante-partes-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .card {
    padding: 16px 14px;
    margin-bottom: 16px;
  }
  .card-header {
    margin: -16px -14px 16px -14px;
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .page-actions-header {
    justify-content: stretch;
  }
  .page-actions-header .btn {
    width: 100%;
    justify-content: center;
  }

  /* Tablas adaptables sin romper el ancho de pantalla */
  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
  }
  .table-responsive > table:not(.table-compact) {
    min-width: 540px;
  }
  .table-compact {
    min-width: 100% !important;
    width: 100% !important;
  }

  .form-actions-bar {
    flex-direction: column-reverse;
  }
  .form-actions-bar .btn {
    width: 100%;
    justify-content: center;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .metric-card {
    padding: 14px;
  }
  .metric-card .metric-value {
    font-size: 22px;
  }
  .metric-card .metric-label {
    font-size: 10px;
  }
  .cobro-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .liquidaciones-filter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .liquidaciones-filter-grid .btn {
    width: 100%;
    justify-content: center;
  }
  .comprobantes-filter-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .comprobantes-filter-grid .btn {
    width: 100%;
    justify-content: center;
  }
  .comprobantes-actions-cell {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .driver-intro, .driver-route-head { display:block; }
  .driver-status { margin-top:12px; }
  .driver-route-head form { margin:16px 0; }
  .delivery-item { grid-template-columns:36px minmax(0, 1fr); gap:12px; }
  .delivery-actions { grid-column:2; width:100%; }
  .delivery-actions > .btn { width:100%; }
  .history-bars { gap: 5px; }
  .delivery-return-form { width:100%; grid-template-columns:minmax(0, 1fr) 120px; }
  .delivery-return-form .btn { width:100%; }
}

@media (max-width: 480px) {
  .comprobante-actions-secondary {
    flex-direction: column;
  }
  .comprobante-actions-secondary .btn {
    width: 100%;
  }
  .payment-toggle-buttons .btn {
    flex: 1 1 100%;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .usuarios-grid {
    grid-template-columns: 1fr;
  }
  .tracking-search-bar .btn-search {
    width: 100%;
    justify-content: center;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .metric-icon { font-size: 19px; }
  .btn { white-space: normal; text-align: center; }
  .modal-card { padding: 18px 14px; }
  .delivery-return-form { grid-template-columns: minmax(0, 1fr); }
  .delivery-return-form .form-label { grid-column: 1; }
  .delivery-return-form .btn { max-width: none; width: 100%; }
}

/* ──────────────── UTILITIES ──────────────── */
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.w-100 { width: 100%; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
