/* ============================================================
   Deli Very — PRO DESIGN SYSTEM
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* === PALETA DELI VERY ===
     Rojo Antojo   #E53935  (40%) — principal, CTA, danger
     Naranja Sabor #FF7A00  (20%) — apoyo, warning, orange
     Amarillo Delicia #FFC107 (15%) — acentos, highlights
     Crema Suave   #FFF4E5  (15%) — fondos, superficies
     Gris Carbón   #2F2F2F  (10%) — textos, contraste          */

  /* === PALETA PRINCIPAL === */
  --primary:        #2F2F2F;
  --primary-light:  #3D3D3D;
  --accent:         #E53935;
  --accent-dark:    #C62828;
  --accent-light:   rgba(229,57,53,0.09);
  --accent-glow:    rgba(229,57,53,0.22);

  /* === SEMÁNTICOS === */
  --success:        #10b981;
  --success-light:  rgba(16,185,129,0.1);
  --success-dark:   #059669;
  --warning:        #FF7A00;
  --warning-light:  rgba(255,122,0,0.1);
  --warning-dark:   #CC6200;
  --danger:         #E53935;
  --danger-light:   rgba(229,57,53,0.1);
  --danger-dark:    #C62828;
  --info:           #CC8800;
  --info-light:     rgba(255,193,7,0.13);
  --orange:         #FF7A00;
  --purple:         #E53935;

  /* === NEUTROS === */
  --bg:             #FFF8F2;
  --surface:        #ffffff;
  --surface-2:      #FFF4E5;
  --border:         #EDD8C5;
  --border-light:   #F5EBE0;
  --text:           #2F2F2F;
  --text-2:         #4A3426;
  --text-muted:     #7A6050;
  --text-light:     #B89880;
  --text-placeholder: #D4BAA2;

  /* === SIDEBAR === */
  --sidebar-width:  260px;

  /* === LAYOUT === */
  --header-height:  64px;
  --radius-xs:      6px;
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --radius-full:    9999px;

  /* === SOMBRAS === */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow:     0 4px 20px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.10), 0 2px 10px rgba(0,0,0,0.06);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.14), 0 6px 20px rgba(0,0,0,0.08);
  --shadow-xl:  0 32px 80px rgba(0,0,0,0.18), 0 10px 30px rgba(0,0,0,0.10);

  /* === TRANSICIONES === */
  --t:     all 0.25s cubic-bezier(0.4,0,0.2,1);
  --t-fast: all 0.15s cubic-bezier(0.4,0,0.2,1);
  --t-slow: all 0.4s cubic-bezier(0.4,0,0.2,1);
  --t-spring: all 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* === SCROLLBAR CUSTOM === */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D4BAA2; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #B89880; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #1C0C08 0%, #2D1208 55%, #1C0C08 100%);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Línea decorativa top del sidebar */
.sidebar::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #E53935, #FF7A00, #FFC107);
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand h2 {
  font-size: 1.35rem;
  background: linear-gradient(135deg, #FFC107 0%, #FF7A00 50%, #E53935 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.sidebar-brand span {
  display: block;
  font-size: 0.67rem;
  color: rgba(255,255,255,0.3);
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar-menu {
  flex: 1;
  padding: 14px 10px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: var(--t);
  font-size: 0.855rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.sidebar-menu li a::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(229,57,53,0.15), rgba(255,122,0,0.08));
  opacity: 0;
  transition: var(--t-fast);
  border-radius: inherit;
}

.sidebar-menu li a:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.07);
}

.sidebar-menu li a:hover::before { opacity: 0; }

.sidebar-menu li a.active {
  color: white;
  background: linear-gradient(135deg, rgba(229,57,53,0.75) 0%, rgba(255,122,0,0.55) 100%);
  box-shadow: 0 4px 16px rgba(229,57,53,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}

.sidebar-menu li a.active i { color: #FFC107; }

.sidebar-menu li a i {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: var(--t-fast);
}

.sidebar-menu .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-full);
  padding: 2px 7px;
  font-size: 0.62rem;
  font-weight: 800;
  animation: pulse-count 2s ease-in-out infinite;
  letter-spacing: 0.02em;
}

@keyframes pulse-count {
  0%,100% { opacity: 1; box-shadow: none; }
  50% { opacity: 0.8; box-shadow: 0 0 8px rgba(239,68,68,0.5); }
}

.sidebar-admin-box {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-admin-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px;
}

.sidebar-admin-name {
  color: rgba(255,255,255,0.82);
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sidebar-admin-role {
  color: rgba(255,255,255,0.3);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-admin-logout { justify-content: center; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--header-height);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(226,232,240,0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar h1 {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 i {
  color: var(--accent);
  font-size: 1rem;
  background: var(--accent-light);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: var(--t);
  position: relative;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(90deg);
}

.sidebar-toggle {
  display: none;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  transition: var(--t);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: var(--t);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sidebar-overlay.active { opacity: 1; visibility: visible; }

.notification-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  flex: 1;
  padding: 28px;
  animation: page-in 0.4s ease both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-actions-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 20px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  transition: var(--t);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: #d1d9e6;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface-2);
}

.card-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.1px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-body { padding: 22px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--t);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: -24px; right: -16px;
  width: 72px; height: 72px;
  border-radius: 50%;
  opacity: 0.07;
  transition: var(--t);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::after { transform: scale(1.3); opacity: 0.12; }

.stat-card.blue  { border-top: 3px solid var(--info);    }
.stat-card.green { border-top: 3px solid var(--success); }
.stat-card.orange{ border-top: 3px solid var(--orange);  }
.stat-card.red   { border-top: 3px solid var(--danger);  }
.stat-card.purple{ border-top: 3px solid var(--purple);  }

.stat-card.blue::after  { background: var(--info);    }
.stat-card.green::after { background: var(--success); }
.stat-card.orange::after{ background: var(--orange);  }
.stat-card.red::after   { background: var(--danger);  }
.stat-card.purple::after{ background: var(--purple);  }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: var(--t);
}

.stat-card:hover .stat-icon { transform: scale(1.08) rotate(-3deg); }

.stat-icon.blue   { background: var(--info-light);             color: var(--info); }
.stat-icon.green  { background: var(--success-light);          color: var(--success); }
.stat-icon.orange { background: rgba(249,115,22,0.1);          color: var(--orange); }
.stat-icon.red    { background: var(--danger-light);           color: var(--danger); }
.stat-icon.purple { background: rgba(229,57,53,0.1);           color: var(--purple); }

.stat-info { min-width: 0; }

.stat-info h3 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1.5px;
  white-space: nowrap;
}

.stat-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   TABLAS — PRO
   ============================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #EDD8C5 transparent;
}
.table-responsive::-webkit-scrollbar { height: 5px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb { background: #EDD8C5; border-radius: 99px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #D4BAA2; }

/* Contenedor completo (tabla + paginación) */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.855rem;
  table-layout: auto;
}

/* === ENCABEZADO === */
.table thead tr { background: var(--surface-2); }

.table th {
  padding: 13px 18px;
  text-align: left;
  font-weight: 700;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--surface-2);
  user-select: none;
}

/* === FILAS === */
.table tbody tr { transition: background 0.15s; }

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

.table tbody tr:hover td {
  background: rgba(229,57,53,0.04) !important;
}

.table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-2);
  background: var(--surface);
  line-height: 1.5;
}

.table tbody tr:last-child td { border-bottom: none; }

/* === STICKY: COLUMNA ACCIONES (última) ===
   Solo aplica cuando la tabla tiene scroll horizontal */
.table th:last-child,
.table td:last-child {
  position: sticky;
  right: 0;
  white-space: nowrap;
}

.table th:last-child {
  background: var(--surface-2);
  border-left: 1.5px solid var(--border);
  z-index: 3;
}

.table td:last-child {
  background: var(--surface);
  border-left: 1.5px solid var(--border-light);
  z-index: 1;
}

.table tbody tr:nth-child(even) td:last-child { background: #FFF8F4; }
.table tbody tr:hover td:last-child { background: rgba(229,57,53,0.04) !important; }

/* === EMPTY STATE === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 24px;
  gap: 14px;
  text-align: center;
}

.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-light);
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0;
}

.empty-state small {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* === PAGINACIÓN === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
  flex-wrap: wrap;
  gap: 10px;
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pagination-btns {
  display: flex;
  align-items: center;
  gap: 3px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
}

.page-btn:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 8px rgba(229,57,53,0.3);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 32px;
  color: var(--text-light);
  font-size: 0.8rem;
}

/* Desactivar sticky en móvil (modo cards) */
@media (max-width: 768px) {
  .table th:last-child,
  .table td:last-child {
    position: static;
    border-left: none;
  }
  .pagination {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ============================================================
   TABLA PEDIDOS
   ============================================================ */
.tabla-pedidos { table-layout: fixed; }

.td-nombre {
  font-weight: 600;
  font-size: 0.855rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.td-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acciones-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.acciones-btns .btn-sm {
  padding: 5px 9px;
  font-size: 0.78rem;
  line-height: 1;
}

/* Botones icono-solo en acciones de tabla */
.tabla-pedidos td:last-child .btn-sm,
.tabla-pedidos td:last-child .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* Bono opciones */
.bono-opcion {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--t-fast);
}

.bono-opcion:hover { border-color: var(--orange); background: rgba(249,115,22,0.04); }
.bono-opcion input[type="radio"] { margin-top: 3px; accent-color: var(--orange); }
.bono-opcion input[type="radio"]:checked + div { color: var(--orange); }
.bono-opcion-disabled { opacity: 0.42; cursor: not-allowed; }
.bono-opcion-disabled:hover { border-color: var(--border); background: none; }

/* Chips informativos */
.btn-info-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  border-radius: var(--radius-full);
  padding: 3px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: var(--t-fast);
  letter-spacing: 0.02em;
}

.btn-info-chip:hover { opacity: 0.8; transform: scale(0.97); }
.btn-chip-bono        { background: rgba(249,115,22,0.12); color: var(--orange); }
.btn-chip-sin-bono    { background: var(--border-light); color: var(--text-muted); }
.btn-chip-sin-bono:hover { background: var(--border); }
.btn-chip-tiempo      { background: var(--info-light); color: #CC8800; }

.tiempo-detalle { display: flex; flex-direction: column; gap: 10px; }
.tiempo-detalle div { display: flex; align-items: center; gap: 6px; }
.chip-diff {
  background: var(--info-light);
  color: #CC8800;
  border-radius: var(--radius-full);
  padding: 2px 9px;
  font-size: 0.74rem;
  font-weight: 700;
}

@media (max-width: 1280px) {
  .tabla-pedidos th, .tabla-pedidos td { padding: 10px 11px; }
}
@media (max-width: 1100px) {
  .tabla-pedidos th, .tabla-pedidos td { padding: 8px 9px; font-size: 0.79rem; }
  .td-sub { font-size: 0.72rem; }
  .acciones-btns .btn-sm { padding: 4px 7px; }
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-pendiente,
.badge-pendiente_asignacion { background: rgba(245,158,11,0.12); color: #92400e; border: 1px solid rgba(245,158,11,0.2); }
.badge-recibido             { background: var(--info-light); color: #7A4500; border: 1px solid rgba(204,136,0,0.25); }
.badge-pendiente_validacion { background: rgba(239,68,68,0.1); color: #991b1b; border: 1px solid rgba(239,68,68,0.2); }
.badge-resolver_problema    { background: var(--danger); color: #fff; border: 1px solid transparent; }
.badge-validado             { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.2); }
.badge-aceptado             { background: rgba(255,122,0,0.12); color: #7A3500; border: 1px solid rgba(255,122,0,0.25); }
.badge-en_camino            { background: rgba(229,57,53,0.1);  color: #7B1010; border: 1px solid rgba(229,57,53,0.22); }
.badge-entregado            { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.2); }
.badge-cancelado            { background: var(--danger-light); color: #991b1b; border: 1px solid rgba(239,68,68,0.2); }
.badge-disponible           { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.2); }
.badge-ocupada              { background: rgba(245,158,11,0.12); color: #92400e; border: 1px solid rgba(245,158,11,0.2); }
.badge-activo               { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.2); }
.badge-inactivo             { background: var(--danger-light); color: #991b1b; border: 1px solid rgba(239,68,68,0.2); }
.badge-en_ruta              { background: rgba(229,57,53,0.1);  color: #7B1010; border: 1px solid rgba(229,57,53,0.22); }
.badge-pedido               { background: rgba(245,158,11,0.12); color: #92400e; border: 1px solid rgba(245,158,11,0.2); }
.badge-acumulado            { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.2); }
.badge-ninguno              { background: var(--border-light); color: var(--text-muted); border: 1px solid var(--border); }
.badge-info                 { background: var(--info-light); color: #7A4500; border: 1px solid rgba(204,136,0,0.25); }
.badge-validado             { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.2); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.865rem;
  font-weight: 600;
  transition: var(--t);
  text-decoration: none;
  letter-spacing: -0.1px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
}

.btn:active::after { opacity: 0.12; }
.btn:active { transform: scale(0.97) !important; }

.btn-primary {
  background: linear-gradient(135deg, #E53935 0%, #C62828 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(229,57,53,0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #C62828 0%, #B71C1C 100%);
  box-shadow: 0 6px 20px rgba(229,57,53,0.45);
  transform: translateY(-1px);
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}
.btn-success:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 6px 20px rgba(16,185,129,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(239,68,68,0.3);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 20px rgba(239,68,68,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-warning {
  background: linear-gradient(135deg, #FF7A00 0%, #CC6200 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(255,122,0,0.3);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #CC6200 0%, #A85000 100%);
  box-shadow: 0 6px 20px rgba(255,122,0,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-info {
  background: linear-gradient(135deg, #FFC107 0%, #CC8800 100%);
  color: #2F2F2F;
  box-shadow: 0 4px 14px rgba(204,136,0,0.3);
}
.btn-info:hover {
  background: linear-gradient(135deg, #CC8800 0%, #A86B00 100%);
  box-shadow: 0 6px 20px rgba(204,136,0,0.4);
  transform: translateY(-1px);
  color: white;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border-light);
  border-color: #c8d3e0;
  color: var(--text);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, #FF7A00 0%, #E53935 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(255,122,0,0.3);
}
.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255,122,0,0.4);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.785rem;
  border-radius: var(--radius-xs);
  gap: 5px;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 400;
  transition: var(--t-fast);
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  appearance: auto;
}

.form-control:hover { border-color: #b8c5d6; }

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(229,57,53,0.12);
  background: #fffaf8;
}

.form-control::placeholder { color: var(--text-placeholder); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ============================================================
   MODALES
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  overflow-y: auto;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  min-width: 0;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255,255,255,0.9);
  transform: scale(0.94) translateY(12px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.22s ease;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  flex: 1;
  letter-spacing: -0.3px;
}

.modal-header h3 i {
  color: var(--accent);
  margin-right: 5px;
  font-size: 0.95rem;
}

.modal-body { padding: 22px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.btn-close-modal {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--t);
  flex-shrink: 0;
  font-weight: 700;
  line-height: 1;
}

.btn-close-modal:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
  transform: rotate(90deg) scale(1.05);
}

/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 15px;
  font-size: 0.865rem;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.alert-success { background: var(--success-light); color: #064e3b; border: 1px solid rgba(16,185,129,0.25); }
.alert-danger   { background: var(--danger-light);  color: #991b1b; border: 1px solid rgba(239,68,68,0.25); }
.alert-warning  { background: var(--warning-light); color: #92400e; border: 1px solid rgba(245,158,11,0.25); }
.alert-info     { background: var(--info-light);    color: #7A4500; border: 1px solid rgba(204,136,0,0.25); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 78px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: min(400px, calc(100vw - 32px));
  animation: toast-in 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  pointer-events: all;
}

.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--info); }

@keyframes toast-in {
  from { transform: translateX(110%) scale(0.88); opacity: 0; }
  to   { transform: translateX(0)    scale(1);    opacity: 1; }
}

/* ============================================================
   LOADING / SPINNER
   ============================================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 40px;
  color: var(--text-muted);
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}

.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

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

/* ============================================================
   GRID
   ============================================================ */
.grid   { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ============================================================
   FILTROS
   ============================================================ */
.filtros-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.filtros-bar .form-control { width: auto; min-width: 0; flex-shrink: 1; }

@media (max-width: 1100px) {
  .filtros-bar .form-control { font-size: 0.82rem; padding: 8px 11px; }
}

@media (max-width: 768px) {
  .filtros-bar { flex-direction: column; align-items: stretch; }
  .filtros-bar .form-control { width: 100%; }
}

/* ============================================================
   STOCK CRÍTICO
   ============================================================ */
.stock-critico { color: var(--danger) !important; font-weight: 700; }
.stock-bajo    { color: var(--warning) !important; font-weight: 600; }
.row-critico   { background: rgba(239,68,68,0.035) !important; }

/* ============================================================
   BONO INFO
   ============================================================ */
.bono-info { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; }
.bono-pedido   { color: var(--orange); }
.bono-acumulado{ color: var(--success); font-weight: 700; }
.bono-ninguno  { color: var(--text-muted); }

.tiempo-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============================================================
   BADGE ALERTA INVENTARIO (SIDEBAR)
   ============================================================ */
.badge-alerta-inv {
  background: var(--danger);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 5px;
  vertical-align: middle;
  animation: pulse-count 2s ease-in-out infinite;
}

/* ============================================================
   ALERTA NUEVO PEDIDO
   ============================================================ */
.pedido-alert-overlay {
  position: fixed;
  top: 78px; right: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  padding: 20px 22px;
  z-index: 5000;
  min-width: 300px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  animation: bounceIn 0.55s cubic-bezier(0.34,1.56,0.64,1);
  display: none;
}

.pedido-alert-overlay.show { display: block; }

@keyframes bounceIn {
  0%  { transform: scale(0.6) translateY(-30px); opacity: 0; }
  70% { transform: scale(1.04); opacity: 1; }
  100%{ transform: scale(1) translateY(0); opacity: 1; }
}

/* ============================================================
   DOMICILIARIO STYLES
   ============================================================ */
.dom-header {
  background: linear-gradient(135deg, #1C0C08 0%, #E53935 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.dom-tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 0;
}

.dom-tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.845rem;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: var(--t);
  margin-bottom: -1px;
}

.dom-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-light);
}

.pedido-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  transition: var(--t);
}

.pedido-card:hover {
  box-shadow: var(--shadow);
  transform: translateX(2px);
}

.pedido-card.entregado {
  border-left-color: var(--success);
  opacity: 0.72;
}

/* ============================================================
   CONTABILIDAD
   ============================================================ */
.ingreso-row { background: rgba(16,185,129,0.04) !important; }
.egreso-row  { background: rgba(239,68,68,0.04)  !important; }

.total-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--t);
}

.total-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.total-card .amount {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -1.5px;
}

.total-card.ingresos .amount { color: var(--success); }
.total-card.egresos  .amount { color: var(--danger);  }
.total-card.neto     .amount { color: var(--accent);  }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */
@media (min-width: 1600px) {
  :root { --sidebar-width: 280px; }
  .page-content { padding: 32px 36px; }
}

@media (max-width: 1400px) {
  :root { --sidebar-width: 250px; }
}

@media (max-width: 1200px) {
  :root { --sidebar-width: 225px; }
  .sidebar-brand h2 { font-size: 1.15rem; }
  .sidebar-menu li a { padding: 10px 12px; font-size: 0.845rem; gap: 10px; }
  .page-content { padding: 22px; }
}

@media (max-width: 1050px) {
  :root { --sidebar-width: 205px; }
  .sidebar-menu li a { padding: 9px 10px; font-size: 0.83rem; }
  .sidebar-brand { padding: 18px 15px 16px; }
  .topbar h1 { font-size: 1.1rem; }
  .topbar { padding: 0 20px; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 270px; }
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .main-content { margin-left: 0; }
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .sidebar-toggle { display: inline-flex; }
  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: var(--header-height);
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
  }
  /* Título ocupa el espacio central entre hamburguesa y botón sync */
  .topbar h1 { flex: 1; min-width: 0; }
  /* En móvil, topbar-right muestra solo el btn-icon (sync); oculta selects, spans y CTAs */
  .topbar-right > *:not(.btn-icon) { display: none; }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .page-content { padding: 14px; }
  .card-body  { padding: 15px; }
  .card-header{ padding: 14px 15px; }
  .modal-body { padding: 16px; }
  .modal-header{ padding: 18px 16px 14px; }
  .modal-footer{ padding: 14px 16px; }
  .topbar h1  { font-size: 1rem; }
  .topbar h1 i { display: none; }

  .page-actions-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 14px;
  }
  .page-actions-toolbar > * { width: 100%; }
  .btn, .btn-sm { width: 100%; justify-content: center; }
  .page-actions-toolbar .btn-icon,
  .page-actions-toolbar .btn { width: 100%; border-radius: var(--radius-sm); }
  .page-actions-toolbar .form-control { width: 100% !important; }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
    background: rgba(15,23,42,0.7);
  }
  .modal {
    max-width: none;
    width: 100%;
    max-height: min(92vh, 100dvh - 8px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    opacity: 1;
  }
  .modal-overlay.active .modal {
    transform: translateY(0);
  }
  .modal-footer { flex-direction: column-reverse; align-items: stretch; }
  .modal-footer .btn { width: 100%; }
  .modal .grid-2,
  .modal .grid-3,
  .modal .grid-4,
  .modal .grid-5 { grid-template-columns: 1fr; gap: 12px; }
  .form-control { font-size: 16px; }

  .toast-container {
    left: 10px; right: 10px;
    top: auto; bottom: 14px;
  }
  .toast {
    min-width: 0; width: 100%; max-width: none;
    padding: 12px 14px;
  }
  .sidebar-admin-box { padding: 12px 10px; }
}

/* ============================================================
   TABLA → CARDS EN MÓVIL
   ============================================================ */
@media (max-width: 768px) {
  .table-responsive { overflow-x: visible; }

  .table thead { display: none; }

  .table tbody tr {
    display: block;
    background: var(--surface);
    margin-bottom: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--t);
  }

  .table tbody tr:hover {
    box-shadow: var(--shadow);
    background: var(--surface);
  }

  .table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.845rem;
    min-height: 38px;
    gap: 10px;
  }

  .table td:last-child { border-bottom: none; }

  .table td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    min-width: 90px;
    flex-shrink: 0;
    padding-top: 1px;
  }

  .table td[data-label="Acciones"] { flex-direction: column; gap: 6px; }
  .table td[data-label="Acciones"]::before { min-width: unset; }
  .table td[data-label="Acciones"] > div { width: 100%; }
  .table td[data-label="Acciones"] .btn { width: 100%; justify-content: center; }
  .table td[data-label] { overflow-wrap: anywhere; word-break: break-word; }
  .table td[data-label] > *:not(:first-child) { min-width: 0; }
}
