/* ===========================================================
   PANEL MEATVALLÈS — Proxera Labs
   Paleta comandes: azul #5B6AB8, fondo #F5F4F2, sidebar navy
   =========================================================== */

:root {
  --primary:        #5B6AB8;
  --primary-dark:   #4a5a9f;
  --primary-light:  #7a87cc;
  --red:            #C0392B;
  --red-dark:       #96281B;
  --secondary:      #E67E22;
  --success:        #27AE60;
  --warning:        #F39C12;
  --danger:         #C0392B;
  --text:           #111111;
  --text-muted:     #555e7a;
  --text-dim:       #8a93b2;
  --bg:             #F5F4F2;
  --bg-card:        #ffffff;
  --bg-sidebar:     #1e2337;
  --border:         #e4e3e0;
  --border-active:  rgba(91,106,184,0.35);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      20px;
  --shadow-sm:      0 1px 3px rgba(30, 35, 55, 0.07);
  --shadow-md:      0 4px 14px rgba(30, 35, 55, 0.10);
  --shadow-lg:      0 8px 28px rgba(30, 35, 55, 0.14);
  --gradient:       linear-gradient(135deg, #5B6AB8, #4a5a9f);
  --gradient-red:   linear-gradient(135deg, #C0392B, #96281B);
  --sidebar-w:      260px;
  --header-h:       64px;
  --transition:     0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button { font-family: inherit; cursor: pointer; }

.hidden { display: none !important; }
.muted  { color: var(--text-muted); font-size: 0.875rem; }

/* ============================= BUTTONS ============================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 0.925rem;
  transition: var(--transition); text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--gradient); color: white; box-shadow: var(--shadow-sm); border: none; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); color: white; }
.btn-secondary { background: white; color: var(--primary); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); background: rgba(91,106,184,0.05); }
.btn-ghost { background: transparent; color: rgba(255,255,255,0.6); border: none; }
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: white; }
.btn-danger { background: var(--danger); color: white; border: none; }
.btn-danger:hover { background: var(--red-dark); color: white; }
.btn-success { background: var(--success); color: white; border: none; }
.btn-success:hover { background: #219a52; color: white; }
.btn-large { padding: 14px 28px; font-size: 1rem; }
.btn-small { padding: 6px 12px; font-size: 0.8125rem; }
.btn-full  { width: 100%; justify-content: center; }

/* ============================= ADMIN LAYOUT ============================= */
.admin-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ============================= SIDEBAR ============================= */
.sidebar {
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.sidebar-brand {
  padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 12px;
}
.brand-logo {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--gradient-red); display: inline-flex; align-items: center;
  justify-content: center; font-size: 1.35rem; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 1.0625rem; color: white; }
.brand-sub  { font-size: 0.75rem; color: rgba(255,255,255,0.7); }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 13px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.92); font-weight: 500; font-size: 0.9275rem;
  transition: var(--transition); margin-bottom: 2px; cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active {
  background: rgba(91,106,184,0.28);
  color: white; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-item.disabled { opacity: 0.35; pointer-events: none; }
.nav-badge {
  margin-left: auto; font-size: 0.65rem; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(91,106,184,0.4); color: rgba(255,255,255,0.8);
  letter-spacing: 0.03em; text-transform: uppercase;
}
.nav-badge-unread {
  background: #e74c3c; color: white; letter-spacing: 0;
  animation: pulse 2s ease-in-out infinite;
}

.sidebar-footer {
  padding: 14px; border-top: 1px solid rgba(255,255,255,0.07);
}

/* ============================= MAIN AREA ============================= */
.admin-main { padding: 24px 32px 64px; overflow-x: hidden; min-width: 0; }

.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  height: var(--header-h); margin-bottom: 24px; gap: 16px;
}
.admin-header h1 { font-size: 1.4rem; font-weight: 700; }
.admin-header-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* ============================= WEEK NAVIGATOR ============================= */
.week-nav {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 6px;
  box-shadow: var(--shadow-sm);
}
.week-nav-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 1rem; padding: 4px 8px; border-radius: 6px;
  line-height: 1; cursor: pointer; transition: var(--transition);
}
.week-nav-btn:hover { background: var(--bg); color: var(--text); }
.week-nav-label {
  font-size: 0.8125rem; font-weight: 600; color: var(--text);
  min-width: 120px; text-align: center; white-space: nowrap;
}
.week-nav-today {
  font-size: 0.75rem; color: var(--primary); font-weight: 600;
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
  background: rgba(91,106,184,0.08); transition: var(--transition);
}
.week-nav-today:hover { background: rgba(91,106,184,0.16); }

/* ============================= LIVE DOT ============================= */
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px rgba(39,174,96,0.18);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.4 } }

/* ============================= KPIs ============================= */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px; margin-bottom: 26px;
}
.kpi-card {
  background: var(--bg-card); padding: 18px 20px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-active); }
.kpi-label { font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; margin-bottom: 6px; }
.kpi-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.kpi-value.meat  { color: var(--primary); }
.kpi-value.green { color: var(--success); }
.kpi-value.orange{ color: var(--secondary); }
.kpi-sub { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
.kpi-action {
  margin-top: 8px; font-size: 0.75rem; font-weight: 600; color: var(--primary);
  cursor: pointer; display: inline-block;
}
.kpi-action:hover { color: var(--primary-dark); text-decoration: underline; }
.kpi-action.hidden { display: none; }
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover { box-shadow: var(--shadow-md); border-color: var(--border-active); }
.kpi-semana {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8125rem; color: var(--text-muted);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px;
}

/* ============================= CARDS ============================= */
.two-col {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px;
}
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-card); border-radius: var(--radius-md);
  border: 1px solid var(--border); padding: 20px 22px;
  margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.card-header h2 { font-size: 1.025rem; font-weight: 600; }
.card-link { font-size: 0.875rem; font-weight: 500; cursor: pointer; color: var(--primary); }
.card-link:hover { color: var(--primary-dark); }

/* ============================= PEDIDO LIST ============================= */
.pedido-list { display: flex; flex-direction: column; gap: 8px; }
.pedido-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: var(--transition);
  background: var(--bg);
}
.pedido-row:hover { border-color: var(--border-active); background: white; }
.pedido-info { flex: 1; min-width: 0; }
.pedido-nombre { display: block; font-weight: 600; font-size: 0.9275rem; }
.pedido-meta   { font-size: 0.8125rem; color: var(--text-muted); }

/* ============================= TABLE ============================= */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left; padding: 11px 10px; font-weight: 600;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  font-size: 0.775rem; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg);
}
.data-table td {
  padding: 11px 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(91,106,184,0.03); }
.acciones { display: flex; gap: 4px; align-items: center; }

/* Icon-only action buttons — lightweight, no heavy fill */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid transparent; background: transparent;
  font-size: 0.8rem; font-weight: 700; cursor: pointer;
  transition: var(--transition); line-height: 1;
}
.icon-btn-success {
  color: var(--success); border-color: rgba(39,174,96,0.25);
}
.icon-btn-success:hover {
  background: rgba(39,174,96,0.10); border-color: rgba(39,174,96,0.45);
}
.icon-btn-danger {
  color: var(--danger); border-color: rgba(192,57,43,0.20);
}
.icon-btn-danger:hover {
  background: rgba(192,57,43,0.08); border-color: rgba(192,57,43,0.40);
}

/* Table helpers */
.pedido-cliente-name { font-weight: 600; font-size: 0.9rem; }
.pedido-ver-lineas {
  font-size: 0.775rem; color: var(--primary); cursor: pointer;
  font-weight: 500; transition: color 0.2s;
}
.pedido-ver-lineas:hover { color: var(--primary-dark); }
.mono-code { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); }
.text-center { text-align: center; }
.date-cell { white-space: nowrap; font-size: 0.8125rem; color: var(--text-muted); }

/* ============================= ESTADO BADGES ============================= */
.estado-badge {
  display: inline-block; font-size: 0.73rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.estado-completado  { background: rgba(39,174,96,0.10);   color: #1a7a3d; border: 1px solid rgba(39,174,96,0.2); }
.estado-sin_pdf     { background: rgba(241,196,15,0.13);  color: #7a6200; border: 1px solid rgba(241,196,15,0.35); }
.estado-no_necesita { background: rgba(192,57,43,0.09);   color: #8b1e14; border: 1px solid rgba(192,57,43,0.18); }
.estado-cancelado,
.estado-sin_pedido  { background: rgba(138,147,178,0.12); color: #555e7a; border: 1px solid rgba(138,147,178,0.2); }
.estado-pendiente   { background: rgba(138,147,178,0.10); color: #6b7494; border: 1px solid rgba(138,147,178,0.15); }

/* ============================= LINEAS DETAIL ============================= */
.lineas-detail {
  display: none; background: var(--bg); padding: 10px 14px;
  border-top: 1px solid var(--border); font-size: 0.8125rem;
}
.lineas-detail.open { display: block; }
.linea-item { display: flex; justify-content: space-between; padding: 3px 0; }
.linea-cod  { color: var(--text-muted); font-family: monospace; margin-right: 8px; }

/* ============================= RESUMEN TOTALES ============================= */
.resumen-total-banner {
  background: rgba(91,106,184,0.06); border: 1px solid rgba(91,106,184,0.2);
  border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
.resumen-total-banner strong { font-size: 1.1rem; color: var(--primary); }

/* ============================= CATÁLOGO ============================= */
.catalogo-add-form {
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: var(--radius-md); padding: 16px 18px; margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.catalogo-add-form .form-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.catalogo-add-form label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.catalogo-add-form input, .catalogo-add-form select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: inherit; background: white;
  transition: border-color 0.2s;
}
.catalogo-add-form input:focus, .catalogo-add-form select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,106,184,0.12);
}

.catalogo-seccion { margin-bottom: 22px; }
.catalogo-seccion-title {
  font-size: 0.73rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.catalogo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.catalogo-item {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-card);
  transition: var(--transition); position: relative;
}
.catalogo-item:hover { border-color: var(--border-active); box-shadow: var(--shadow-sm); }
.catalogo-item-actions {
  position: absolute; top: 8px; right: 8px;
  display: none; gap: 4px;
}
.catalogo-item:hover .catalogo-item-actions { display: flex; }
.catalogo-cod  { font-size: 0.73rem; font-family: monospace; color: var(--text-dim); }
.catalogo-name { font-weight: 600; font-size: 0.9125rem; }
.catalogo-unit { font-size: 0.8rem; color: var(--text-muted); }
.catalogo-aliases {
  margin-top: 4px; font-size: 0.73rem; color: var(--text-dim);
  font-style: italic;
}

/* ============================= ACTIVIDAD ============================= */
.actividad-feed { display: flex; flex-direction: column; gap: 7px; max-height: 600px; overflow-y: auto; }
.actividad-item {
  display: flex; gap: 12px; padding: 9px 13px;
  border-left: 3px solid var(--primary); background: var(--bg-card);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.875rem; border: 1px solid var(--border); border-left-color: var(--primary);
}
.actividad-tipo { font-weight: 600; min-width: 190px; }
.actividad-desc { color: var(--text-muted); flex: 1; }
.actividad-ts   { color: var(--text-dim); font-size: 0.73rem; white-space: nowrap; }
.actividad-item.new { animation: flashIn 1s ease-out; }
@keyframes flashIn { 0% { background: rgba(91,106,184,0.10); } 100% { background: var(--bg-card); } }

/* ============================= RATING (placeholder) ============================= */
.coming-soon-banner {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  background: repeating-linear-gradient(
    -45deg, var(--bg), var(--bg) 10px, rgba(91,106,184,0.025) 10px, rgba(91,106,184,0.025) 20px
  );
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 60px 24px; text-align: center; margin-bottom: 24px;
}
.coming-soon-banner .badge {
  background: var(--gradient); color: white;
  font-size: 0.75rem; font-weight: 700; padding: 4px 12px;
  border-radius: 999px; letter-spacing: 0.06em; text-transform: uppercase;
}
.coming-soon-banner h2 { font-size: 1.5rem; color: var(--text-muted); }
.coming-soon-banner p  { color: var(--text-dim); max-width: 400px; }
.rating-preview-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; opacity: 0.35; pointer-events: none;
}
.rating-preview-card {
  background: var(--bg-card); padding: 20px; border-radius: var(--radius-md);
  border: 1px solid var(--border); text-align: center;
}
.rating-preview-stars { font-size: 1.5rem; margin-bottom: 8px; }
.rating-preview-num   { font-size: 2rem; font-weight: 700; }
.rating-preview-label { font-size: 0.8125rem; color: var(--text-muted); }

/* ============================= CONFIG ============================= */
.config-section { margin-bottom: 32px; }
.config-section-title {
  font-size: 0.73rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.config-form { display: flex; flex-direction: column; gap: 12px; }
.config-row {
  display: grid; grid-template-columns: 200px 1fr 1fr; gap: 12px;
  align-items: center; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.config-key   { font-family: monospace; font-size: 0.875rem; color: var(--text-muted); }
.config-desc  { font-size: 0.8125rem; color: var(--text-dim); }
.config-input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9375rem; background: white;
  transition: var(--transition);
}
.config-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,106,184,0.12); }

.actions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.action-card {
  padding: 18px 20px; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--bg-card);
  display: flex; flex-direction: column; gap: 8px;
}
.action-card-title { font-weight: 600; font-size: 0.9375rem; }
.action-card-desc  { font-size: 0.8125rem; color: var(--text-muted); flex: 1; }

/* ============================= FILTER ============================= */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-select {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.875rem; background: var(--bg-card);
  transition: border-color 0.2s;
}
.filter-select:focus { outline: none; border-color: var(--primary); }

/* ============================= TOAST ============================= */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: white;
  padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); z-index: 2000;
  font-size: 0.9375rem; font-weight: 500;
  animation: slideUp 0.3s ease-out;
  cursor: pointer; user-select: none;
}
.toast.error   { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideUp   { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================= LOGIN MODAL ============================= */
#login-modal {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30,35,55,0.72); backdrop-filter: blur(6px);
}
#login-modal.hidden { display: none !important; }
.login-panel {
  background: white; padding: 48px 40px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-width: 380px; width: 90%; text-align: center;
}
.login-logo {
  width: 56px; height: 56px; border-radius: var(--radius-md);
  background: var(--gradient-red); display: inline-flex; align-items: center;
  justify-content: center; font-size: 1.75rem; margin-bottom: 20px;
}
.login-panel h2 { margin-bottom: 6px; font-size: 1.4rem; }
.login-panel p  { color: var(--text-muted); margin-bottom: 28px; font-size: 0.925rem; }
#login-form { display: flex; flex-direction: column; gap: 14px; }
#user-input, #pass-input {
  padding: 12px 16px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 1rem;
  font-family: inherit; width: 100%;
  transition: border-color 0.2s;
}
#user-input:focus, #pass-input:focus { outline: none; border-color: var(--primary); }
#login-form button {
  padding: 12px 24px; background: var(--gradient-red); color: white;
  border: none; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 1rem; transition: opacity 0.2s;
}
#login-form button:hover { opacity: 0.88; }
#login-error { color: var(--danger); font-size: 0.875rem; min-height: 20px; }

/* ============================= EMPTY STATE ============================= */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-dim);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p    { font-size: 0.9375rem; }

/* ============================= WHATSAPP CHAT ============================= */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-h) - 80px);
  min-height: 500px;
  max-height: calc(100vh - 120px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
}

/* Contact list (left) */
.chat-contacts {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-height: 0;
}
.chat-contacts-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9375rem;
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-perm-btn {
  background: none; border: none; font-size: 1rem; cursor: pointer;
  opacity: 0.5; transition: opacity 0.2s; padding: 2px 4px;
}
.notif-perm-btn:hover { opacity: 1; }
.notif-request-bar {
  background: rgba(91,106,184,0.07); border-bottom: 1px solid var(--border);
  padding: 9px 14px; font-size: 0.78rem; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-shrink: 0;
}
.chat-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.chat-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}
.chat-search input:focus { border-color: var(--primary); }

.chat-contact-list {
  flex: 1;
  overflow-y: auto;
}
.chat-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: var(--transition);
}
.chat-contact:hover  { background: rgba(91,106,184,0.05); }
.chat-contact.active { background: rgba(91,106,184,0.1); }
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9375rem;
  flex-shrink: 0;
}
.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-contact-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.chat-contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.chat-contact-time {
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Conversation (right) — WhatsApp Web style */
.chat-conversation {
  display: flex;
  flex-direction: column;
  background: #efeae2;
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.chat-conv-header {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f0f2f5;
  flex-shrink: 0;
  z-index: 2;
}
.chat-conv-name  { font-weight: 600; font-size: 0.9375rem; color: #111b21; }
.chat-conv-phone { font-size: 0.78rem; color: #667781; margin-top: 1px; }
.chat-back-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: #667781;
  padding: 0 8px;
  cursor: pointer;
  line-height: 1;
  font-weight: 700;
}
.chat-back-btn:hover { color: #111b21; }

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 7%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  background-color: #efeae2;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,0.4) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(255,255,255,0.2) 0%, transparent 50%);
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 65%;
  margin-bottom: 2px;
}
.chat-bubble-wrap.saliente {
  align-self: flex-end;
  align-items: flex-end;
}
.chat-bubble-wrap.entrante {
  align-self: flex-start;
  align-items: flex-start;
}
.chat-bubble-wrap.sistema {
  align-self: center;
  align-items: center;
  max-width: 80%;
  margin: 8px 0;
}

.chat-bubble {
  padding: 6px 9px 8px 10px;
  border-radius: 7.5px;
  font-size: 0.875rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
}
.chat-bubble.saliente {
  background: #d9fdd3;
  color: #111b21;
}
.chat-bubble.entrante {
  background: white;
  color: #111b21;
}
.chat-bubble-meta {
  display: inline-block;
  float: right;
  font-size: 0.6875rem;
  color: rgba(0,0,0,0.45);
  margin: 6px -4px -4px 8px;
  white-space: nowrap;
}
.chat-bubble-tick {
  font-size: 0.78rem;
  margin-left: 3px;
  color: #53bdeb;
  letter-spacing: -2px;
}

/* Interactive messages (outgoing with buttons) */
.chat-btn-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-btn-option {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #008069;
  padding: 6px 10px;
  border: 1px solid rgba(0,128,105,0.3);
  border-radius: 6px;
  text-align: center;
  background: rgba(0,128,105,0.04);
}

/* Button reply (incoming — client tapped a button) */
.chat-btn-reply-pill {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #008069;
  padding: 2px 0;
}
.chat-day-divider {
  align-self: center;
  background: rgba(225,245,254,0.92);
  color: #54656f;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(11,20,26,0.13);
  margin: 8px 0;
}
.chat-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.9375rem;
}
.chat-tipo-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-style: italic;
  color: var(--text-muted);
}
.chat-readonly-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.chat-readonly-bar {
  background: rgba(138,147,178,0.10);
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 10px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ============================= MODALES ============================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30,35,55,0.55); backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none !important; }
.modal-panel {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 32px 36px;
  max-width: 400px; width: 90%; text-align: center;
  animation: modalIn 0.18s ease-out;
}
.modal-panel-wide { max-width: 560px; text-align: left; }
@keyframes modalIn {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.modal-icon { font-size: 2.25rem; margin-bottom: 12px; }
.modal-panel h3 { font-size: 1.0625rem; font-weight: 700; margin-bottom: 8px; }
.modal-panel p  { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }
.modal-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 24px;
}
.modal-panel-wide .modal-actions { justify-content: flex-end; }
.modal-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.modal-form-row { display: flex; gap: 12px; }
.modal-form .form-field { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.modal-form label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.modal-form input {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: inherit; background: var(--bg);
  transition: border-color 0.2s;
}
.modal-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,106,184,0.12); }
.form-hint { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

/* ============================= CATÁLOGO SEARCH ============================= */
.catalogo-search-input {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.875rem; background: var(--bg-card);
  width: 200px; transition: border-color 0.2s;
}
.catalogo-search-input:focus { outline: none; border-color: var(--primary); }

/* ============================= RESUMEN PROGRESS BAR ============================= */
.resumen-bar-wrap { display: flex; align-items: center; gap: 8px; }
.resumen-bar {
  flex: 1; height: 5px; background: rgba(91,106,184,0.1);
  border-radius: 3px; overflow: hidden; min-width: 40px;
}
.resumen-bar-fill {
  height: 100%; background: var(--primary);
  border-radius: 3px; transition: width 0.4s ease;
}

/* ============================= CHAT CONTACT BADGE ============================= */
.chat-contact-badge { margin-top: 3px; }

/* ============================= TABLE ROW CLICKABLE ============================= */
.data-table tr.row-clickable { cursor: pointer; }
.data-table tr.row-clickable:hover td { background: rgba(91,106,184,0.06); }

/* ============================= ACCIÓN BOTONES PEDIDOS ============================= */
.td-acciones { text-align: right; white-space: nowrap; }

/* ============================= TOAST EXIT ============================= */
.toast.hiding {
  animation: slideDown 0.25s ease-in forwards;
}
@keyframes slideDown {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(12px); opacity: 0; }
}

/* ============================= LOADING SPINNER ============================= */
.btn.loading { opacity: 0.65; pointer-events: none; }
.btn.loading::after {
  content: '…';
}

/* ============================= SKELETON ============================= */
.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, rgba(180,185,210,0.15) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================= CHAT UNREAD ============================= */
.chat-contact.unread .chat-contact-name    { color: #111b21; }
.chat-contact.unread .chat-contact-preview { color: #111b21; font-weight: 500; }
.chat-unread-count {
  background: #25d366; color: white;
  font-size: 0.65rem; font-weight: 700;
  padding: 1px 5px; border-radius: 999px;
  min-width: 18px; text-align: center; line-height: 16px;
  flex-shrink: 0;
}

/* ============================= BROADCAST PREVIEW MODAL ============================= */
.modal-panel-broadcast { max-width: 520px; text-align: left; }
.modal-panel-broadcast h3,
.modal-panel-broadcast .modal-icon { text-align: center; }
.modal-panel-broadcast p  { text-align: center; margin-bottom: 0; }
.broadcast-preview-langs { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.broadcast-lang-block { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.broadcast-lang-header {
  padding: 5px 12px; background: var(--bg);
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.broadcast-lang-text {
  padding: 10px 12px; font-size: 0.8125rem; white-space: pre-wrap;
  line-height: 1.55; color: var(--text); background: white;
}

/* ============================= GLOBAL SEARCH ============================= */
.global-search-wrap {
  position: relative; display: flex; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 10px;
  box-shadow: var(--shadow-sm); flex: 0 1 260px;
  transition: var(--transition);
}
.global-search-wrap:focus-within {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,106,184,0.12);
}
.global-search-icon {
  font-size: 1.1rem; color: var(--text-dim); pointer-events: none; line-height: 1;
  margin-right: 4px;
}
.global-search-input {
  border: none; outline: none; background: transparent;
  font-size: 0.875rem; color: var(--text); width: 100%;
  padding: 7px 0; font-family: inherit;
}
.global-search-input::placeholder { color: var(--text-dim); }
.global-search-input::-webkit-search-cancel-button { cursor: pointer; }
.global-search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 200; overflow: hidden; min-width: 280px;
}
.search-group-label {
  padding: 6px 12px 4px; font-size: 0.68rem; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.search-result-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; transition: background 0.12s;
  border-bottom: 1px solid rgba(228,227,224,0.5);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg); }
.search-result-icon { font-size: 0.9rem; flex-shrink: 0; }
.search-result-name { flex: 1; font-size: 0.875rem; font-weight: 500; color: var(--text); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-meta { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.search-empty { padding: 12px 16px; font-size: 0.875rem; color: var(--text-muted); text-align: center; }

/* ============================= CHAT HISTORIAL ============================= */
.chat-historial {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg); font-size: 0.78rem;
}
.chat-historial-label {
  font-size: 0.68rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-right: 2px; flex-shrink: 0;
}
.chat-historial-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  background: white; border: 1px solid var(--border);
  color: var(--text-muted); white-space: nowrap;
}
.chat-historial-semana { font-weight: 600; color: var(--text); font-size: 0.75rem; }
.chat-historial-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.chat-historial-estado { color: var(--text-muted); }
.chat-historial-lineas { color: var(--text-dim); font-size: 0.72rem; }
.dot-completado  { background: var(--success); }
.dot-sin_pdf     { background: #F1C40F; }
.dot-no_necesita { background: var(--red); }
.dot-cancelado   { background: #aaa; }

/* Historial pill clickable */
.chat-historial-pill-clickable {
  cursor: pointer;
  transition: var(--transition);
}
.chat-historial-pill-clickable:hover {
  border-color: var(--primary);
  background: rgba(91,106,184,0.05);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ============================= REFRESH BUTTON ============================= */
.refresh-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
  font-size: 1.05rem;
}
.refresh-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(91,106,184,0.05);
}
.refresh-icon { display: inline-block; transition: transform 0.6s; }
.refresh-btn.refreshing .refresh-icon { transform: rotate(360deg); }

/* ============================= ATTENTION BLOCK ============================= */
.attention-block {
  background: linear-gradient(135deg, rgba(243,156,18,0.06), rgba(192,57,43,0.04));
  border: 1px solid rgba(243,156,18,0.25);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 22px;
}
.attention-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.attention-icon { font-size: 1.2rem; }
.attention-header h2 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.attention-sub {
  font-size: 0.78rem; color: var(--warning);
  background: rgba(243,156,18,0.12);
  padding: 2px 9px; border-radius: 999px;
  font-weight: 600;
}
.attention-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.attention-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: var(--transition);
  display: flex; flex-direction: column; gap: 4px;
}
.attention-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.attention-card-top {
  display: flex; align-items: baseline; gap: 8px; justify-content: space-between;
}
.attention-card-icon { font-size: 1.1rem; }
.attention-card-num {
  font-size: 1.6rem; font-weight: 700; line-height: 1;
  color: var(--text);
}
.attention-high .attention-card-num    { color: var(--danger); }
.attention-medium .attention-card-num  { color: var(--warning); }
.attention-low .attention-card-num     { color: var(--text-muted); }
.attention-card-label {
  font-size: 0.8125rem; color: var(--text-muted); line-height: 1.3;
}
.attention-card-action {
  font-size: 0.72rem; font-weight: 600; color: var(--primary);
  margin-top: 2px;
}

/* ============================= BULK ACTIONS BAR ============================= */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
  animation: slideUp 0.2s ease-out;
}
.bulk-bar-count { font-size: 0.875rem; }
.bulk-bar-count strong { font-size: 1rem; margin-right: 4px; }
.bulk-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bulk-bar.bulk-bar-loading { opacity: 0.6; pointer-events: none; }
.bulk-bar .btn-ghost { color: rgba(255,255,255,0.85); }
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,0.15); color: white; }

/* Checkbox column en tabla de pedidos */
.th-checkbox, .td-checkbox {
  width: 40px; text-align: center;
  padding: 11px 6px !important;
}
.td-checkbox input[type="checkbox"],
.th-checkbox input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; margin: 0;
  accent-color: var(--primary);
}
.data-table tr.row-selected td {
  background: rgba(91,106,184,0.06);
}
.data-table tr.row-selected:hover td {
  background: rgba(91,106,184,0.10);
}

/* ============================= BROADCAST WARNING ============================= */
.broadcast-warning {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(243,156,18,0.10);
  border: 1px solid rgba(243,156,18,0.40);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 14px 0 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  text-align: left;
  color: var(--text);
}
.broadcast-warning-icon { font-size: 1.1rem; flex-shrink: 0; }
.broadcast-warning strong { color: #7a5500; }

#broadcast-modal-ok:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--text-dim) !important;
}

/* ============================= PEDIDO DETAIL MODAL ============================= */
.pedido-detail-body {
  max-height: 60vh; overflow-y: auto;
  text-align: left;
  margin: 8px 0;
}
.pedido-detail-meta {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.pedido-detail-body .data-table { font-size: 0.8625rem; }
.pedido-detail-body .data-table td { padding: 9px 8px; }

/* ============================= MOBILE MENU ============================= */
.mobile-menu-btn {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 36px; height: 36px;
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.mobile-menu-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30,35,55,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.mobile-overlay-show { display: block; }

/* ============================= TABLA ORDENABLE ============================= */
.data-table th[data-sort] {
  cursor: pointer; user-select: none;
  transition: color 0.15s;
}
.data-table th[data-sort]:hover { color: var(--primary); }
.data-table th.th-sort-active { color: var(--primary); }
.th-sort-arrow { font-size: 0.7rem; margin-left: 2px; }

/* ============================= INACTIVIDAD BADGE ============================= */
.inact-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.inact-activo { background: rgba(39,174,96,0.10); color: #1a7a3d; border: 1px solid rgba(39,174,96,0.25); }
.inact-medio  { background: rgba(243,156,18,0.10); color: #7a5500; border: 1px solid rgba(243,156,18,0.30); }
.inact-alto   { background: rgba(192,57,43,0.10); color: #8b1e14; border: 1px solid rgba(192,57,43,0.25); }
.inact-nuevo  { background: rgba(91,106,184,0.10); color: var(--primary); border: 1px solid rgba(91,106,184,0.25); }

/* ============================= SPARKLINE EN KPI ============================= */
.kpi-sparkline {
  width: 100%; height: 24px;
  margin: 4px 0 2px;
  display: block;
}
.kpi-sparkline.hidden { display: none; }

/* ============================= BROADCAST RESULT MODAL ============================= */
.broadcast-result-list {
  max-height: 50vh; overflow-y: auto;
  margin: 8px 0 16px;
  text-align: left;
}
.broadcast-result-group { margin-bottom: 14px; }
.broadcast-result-group:last-child { margin-bottom: 0; }
.broadcast-result-group-header {
  font-size: 0.78rem; font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.broadcast-result-names {
  display: flex; flex-wrap: wrap; gap: 5px;
}
.broadcast-result-pill {
  display: inline-block;
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ============================= NOTA CLIENTE ============================= */
.chat-nota-btn {
  background: rgba(91,106,184,0.08);
  border: 1px solid rgba(91,106,184,0.25);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
  transition: var(--transition);
  max-width: 220px;
  flex-shrink: 0;
}
.chat-nota-btn:hover {
  background: rgba(91,106,184,0.14);
  border-color: var(--primary);
}
.chat-nota-preview {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
  font-style: italic;
  color: var(--text-muted);
}
.chat-nota-btn[data-nota=""]:not([data-nota=""]) .chat-nota-preview,
.chat-nota-btn:not([data-nota]) .chat-nota-preview {
  font-style: italic;
}

.cliente-nota-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 100px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}
.cliente-nota-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(91,106,184,0.10);
}

/* ============================= RESPONSIVE — TABLET (≤960px) ============================= */
@media (max-width: 960px) {
  :root { --sidebar-w: 220px; }
  .admin-main { padding: 18px 20px 50px; }
  .admin-header h1 { font-size: 1.2rem; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 1.65rem; }
  .actions-grid { grid-template-columns: 1fr 1fr; }
  .config-row { grid-template-columns: 1fr; gap: 6px; }
  .config-key { font-size: 0.78rem; }
  .chat-layout { grid-template-columns: 260px 1fr; }
}

/* ============================= RESPONSIVE — MOBILE (≤700px) ============================= */
@media (max-width: 700px) {
  .admin-body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.sidebar-open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .admin-main {
    padding: 14px 14px 40px;
    width: 100%;
    min-width: 0;
  }
  .admin-header {
    flex-wrap: wrap;
    gap: 10px;
    height: auto;
    margin-bottom: 18px;
  }
  .admin-header h1 { font-size: 1.1rem; }
  .admin-header-right {
    width: 100%;
    justify-content: space-between;
  }
  .global-search-wrap { width: 100%; order: 99; }
  .week-nav-label { min-width: 90px; font-size: 0.75rem; }
  .week-nav-today { font-size: 0.7rem; padding: 2px 6px; }
  .week-nav-btn { padding: 4px 6px; }

  /* KPIs en grid 2 columnas */
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-label { font-size: 0.74rem; }
  .kpi-sub { font-size: 0.68rem; }

  /* Cards y secciones */
  .card { padding: 14px 14px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header h2 { font-size: 0.95rem; }

  /* Tablas en móvil: scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 0.78rem; min-width: 480px; }
  .data-table th, .data-table td { padding: 8px 6px; }

  /* Acciones bulk - botones full width */
  .bulk-bar { flex-direction: column; align-items: stretch; }
  .bulk-bar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .bulk-bar-actions .btn { font-size: 0.75rem; padding: 6px 8px; }

  /* Atención block */
  .attention-grid { grid-template-columns: 1fr; }

  /* Actions grid en config */
  .actions-grid { grid-template-columns: 1fr; }

  /* Chat layout en móvil: lista o conversación, no las dos */
  .chat-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - 180px);
  }
  .chat-contacts { display: flex; }
  .chat-conversation { display: none; }
  .chat-layout.chat-active .chat-contacts { display: none; }
  .chat-layout.chat-active .chat-conversation { display: flex; }
  .chat-messages { padding: 12px 8px; }
  .chat-bubble-wrap { max-width: 80%; }
  .chat-back-btn { display: inline-flex !important; }
  .chat-nota-btn { max-width: 130px; padding: 5px 8px; font-size: 0.72rem; }
  .chat-nota-preview { display: none; }

  /* Catálogo form en columnas */
  .catalogo-add-form { flex-direction: column; }
  .catalogo-add-form .form-field { width: 100%; }
  .catalogo-grid { grid-template-columns: 1fr; }
  .catalogo-item-actions { display: flex !important; }

  /* Modales más compactos */
  .modal-panel { padding: 22px 18px; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; }

  /* Resumen banner */
  .resumen-total-banner { flex-direction: column; align-items: flex-start; text-align: left; }

  /* Toast */
  .toast { left: 14px; right: 14px; bottom: 14px; text-align: center; }

  /* Header siempre visible y compacto */
  .admin-header h1 { flex-shrink: 1; min-width: 0; }
}

/* ============================= RESPONSIVE — MOBILE PEQUEÑO (≤420px) ============================= */
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 6px; }
  .kpi-value { font-size: 1.2rem; }
  .nav-item { font-size: 0.875rem; padding: 8px 11px; }
  .actividad-tipo { min-width: 130px; font-size: 0.82rem; }
}

/* ============================= MORNING BAR ============================= */
.morning-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.morning-bar-left { min-width: 0; }
.morning-date {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.morning-semana {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.morning-countdown {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 5px;
}
.morning-countdown.urgent { color: var(--danger); }
.morning-countdown.closed { color: var(--text-muted); font-weight: 500; }
.morning-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.morning-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.morning-action-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.morning-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}
@media (max-width: 700px) {
  .morning-bar { flex-direction: column; align-items: flex-start; }
  .morning-actions { width: 100%; }
  .morning-divider { display: none; }
}

/* ============================= VIEW TABS ============================= */
.view-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.view-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-panel { }
.tab-panel.hidden { display: none !important; }

/* ============================= EDITAR LÍNEAS ============================= */
.icon-btn-edit {
  color: var(--primary);
  border-color: rgba(91,106,184,0.25);
}
.icon-btn-edit:hover {
  background: rgba(91,106,184,0.08);
  border-color: rgba(91,106,184,0.45);
}
.lineas-edit-body {
  max-height: 65vh;
  overflow-y: auto;
}
.lineas-edit-table { width: 100%; }
.lineas-edit-table td { vertical-align: middle; padding: 8px 6px; }
.linea-edit-cod {
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
  display: block;
}
.linea-edit-desc {
  font-size: 0.875rem;
  font-weight: 500;
}
.linea-input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--bg);
  transition: border-color 0.15s;
}
.linea-input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}
.linea-input-sm { max-width: 60px; }
.th-sort-arrow { font-size: 0.65rem; margin-left: 2px; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--primary); }
th.th-sort-active { color: var(--primary); }

/* ============================= SPARKLINE ============================= */
.kpi-sparkline {
  display: block;
  width: 100%;
  height: 28px;
  margin: 4px 0 2px;
}
.kpi-sparkline.hidden { display: none; }


/* ─── GESTIÓN DE CLIENTES ────────────────────────────────────────────────── */
.gestion-filtros {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 0 0 14px; margin-bottom: 4px;
}
.gestion-search {
  flex: 1 1 260px; min-width: 200px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.875rem; font-family: inherit; background: var(--bg);
}
.gestion-search:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,106,184,0.12);
}
.gestion-select {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; font-family: inherit; background: var(--bg);
  color: var(--text); cursor: pointer;
}
.gestion-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,106,184,0.12);
}

/* Badges de estado en la tabla */
.g-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; white-space: nowrap;
}
.g-badge-on   { background: rgba(34,163,94,0.12);  color: #1c7a47; }
.g-badge-off  { background: rgba(234,160,32,0.14); color: #96620a; }
.g-badge-arch { background: rgba(120,120,130,0.14); color: #5d5d68; }
.g-badge-dia  { background: rgba(91,106,184,0.12); color: #45529b; }

/* Acciones de fila */
.g-acciones { text-align: right; white-space: nowrap; }
.g-acciones .btn { margin-left: 4px; }

/* Formulario del modal */
.modal-panel-form { max-width: 620px; max-height: 88vh; overflow-y: auto; }
.modal-form select,
.modal-form textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: inherit; background: var(--bg); color: var(--text);
}
.modal-form select:focus,
.modal-form textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,106,184,0.12);
}
.gestion-check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 0.85rem; color: var(--text-muted); cursor: pointer; line-height: 1.4;
}
.gestion-check input { margin-top: 2px; flex-shrink: 0; }
.gestion-extra summary {
  cursor: pointer; font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted); padding: 6px 0;
}
.gestion-extra summary:hover { color: var(--primary); }
.gestion-error {
  background: rgba(214,69,69,0.10); color: #a32b2b;
  border: 1px solid rgba(214,69,69,0.25); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 0.84rem; margin-top: 12px;
}

/* Ficha del cliente */
.g-ficha-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; margin: 16px 0 4px;
}
.g-ficha-item { display: flex; flex-direction: column; gap: 2px; }
.g-ficha-item .lbl {
  font-size: 0.7rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.g-ficha-item .val { font-size: 0.9rem; color: var(--text); word-break: break-word; }
.g-ficha-aviso {
  background: rgba(234,160,32,0.10); border: 1px solid rgba(234,160,32,0.28);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 0.82rem; color: #8a5a06; margin-top: 14px;
}

@media (max-width: 640px) {
  .gestion-filtros { flex-direction: column; }
  .gestion-search, .gestion-select { width: 100%; }
}

/* Aviso de clientes con datos incoherentes (normalmente por ediciones hechas
   directamente en Supabase, que no pasan por las validaciones del panel). */
.gestion-avisos {
  background: rgba(234,160,32,0.10);
  border: 1px solid rgba(234,160,32,0.30);
  border-radius: var(--radius-sm);
  padding: 11px 14px; margin-bottom: 14px;
  font-size: 0.83rem; color: #8a5a06; line-height: 1.5;
}
.gestion-avisos ul { padding: 0; }
.gestion-avisos li { margin: 2px 0; }


/* ─── PAGINADOR ──────────────────────────────────────────────────────────── */
.paginador {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 4px 4px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.pag-info { font-size: 0.82rem; color: var(--text-muted); }
.pag-info strong { color: var(--text); }
.pag-botones { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pag-btn {
  min-width: 34px; height: 34px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font-size: 0.85rem; font-family: inherit; font-weight: 600;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.pag-btn:hover:not(:disabled):not(.pag-btn-activa) {
  border-color: var(--primary); color: var(--primary);
  background: rgba(91,106,184,0.06);
}
.pag-btn-activa {
  background: var(--primary); border-color: var(--primary); color: #fff; cursor: default;
}
.pag-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pag-nav { font-size: 1.05rem; line-height: 1; }
.pag-puntos { color: var(--text-dim); padding: 0 2px; user-select: none; }

@media (max-width: 640px) {
  .paginador { justify-content: center; }
  .pag-info { width: 100%; text-align: center; }
}

/* Badge "N/A": el cliente no está en ninguna lista de envío. Gris neutro para
   que se distinga de un domingo/lunes reales sin parecer un error. */
.g-badge-na {
  background: rgba(120,120,130,0.12); color: #6b6b76;
  font-style: italic; letter-spacing: 0.02em;
}
