/* ═══════════════════════════════════════════════════
   MARINELLI ERP
   ═══════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────── */
:root {
  --primary:        #0077BE;
  --primary-dark:   #005A8E;
  --primary-light:  #E8F4FD;
  --secondary:      #8954BA;
  --secondary-light:#F3EDF9;
  --success:        #27AE60;
  --success-light:  #E9F7EF;
  --warning:        #F39C12;
  --warning-light:  #FEF9E7;
  --danger:         #E74C3C;
  --danger-light:   #FDEDEC;
  --info:           #2980B9;

  --sidebar-bg:     #1A2332;
  --sidebar-hover:  rgba(255,255,255,.07);
  --sidebar-active: rgba(0,119,190,.18);
  --sidebar-width:  240px;
  --topbar-h:       58px;

  --body-bg:        #F4F6F9;
  --card-bg:        #FFFFFF;
  --border:         #E3E8EF;
  --border-light:   #F0F3F8;
  --text:           #1E2D3D;
  --text-muted:     #7B8EA6;
  --text-light:     #B4C0CE;

  --shadow-xs:      0 1px 3px rgba(0,0,0,.05);
  --shadow-sm:      0 2px 8px rgba(0,0,0,.07);
  --shadow:         0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:      0 10px 36px rgba(0,0,0,.14);
  --radius:         10px;
  --radius-sm:      6px;
  --radius-lg:      16px;
  --transition:     .18s ease;
}

/* ── Tema personalizado: sidebar glass ─────────────── */
body.sidebar-glass .sidebar {
  background: rgba(26, 35, 50, 0.72) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* ── Calendario Tareas ──────────────────────────────── */
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.cal-header-day { text-align:center; font-size:11px; font-weight:700; color:var(--text-muted); padding:4px 0; text-transform:uppercase; }
.cal-cell { min-height:120px; border:1px solid var(--border); border-radius:4px; padding:4px; background:var(--card-bg); }
.cal-cell-vacia { background:transparent !important; border-color:transparent !important; }
.cal-cell-hoy { border-color:#2563eb !important; background:#eff6ff !important; }
body.dark-mode .cal-cell-hoy { background:#1e3a5f !important; }
.cal-cell-num { font-size:11px; font-weight:600; color:var(--text-muted); margin-bottom:3px; }
.cal-hoy-num { color:#2563eb !important; }
.cal-task-chip { padding:2px 4px; border-radius:3px; margin-bottom:2px; overflow:hidden; }
.cal-task-chip:hover { opacity:.8; }

/* ── Modo oscuro ────────────────────────────────────── */
body.dark-mode {
  --body-bg:       #0f172a;
  --card-bg:       #1e293b;
  --border:        #334155;
  --border-light:  #263347;
  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --text-light:    #475569;
  --shadow-xs:     0 1px 3px rgba(0,0,0,.3);
  --shadow-sm:     0 2px 8px rgba(0,0,0,.4);
  --shadow:        0 4px 16px rgba(0,0,0,.5);
  --primary-light: rgba(0,119,190,.15);
  --secondary-light:rgba(137,84,186,.15);
  --success-light: rgba(39,174,96,.12);
  --warning-light: rgba(243,156,18,.12);
  --danger-light:  rgba(231,76,60,.12);
}
body.dark-mode .topbar          { background: #1e293b; border-bottom-color: #334155; }
body.dark-mode .card            { background: var(--card-bg); border-color: var(--border); color: var(--text); }
body.dark-mode .card-header     { background: var(--card-bg); border-bottom-color: var(--border); color: var(--text); }
body.dark-mode .card-body       { color: var(--text); }
body.dark-mode .table           { --bs-table-bg: transparent; --bs-table-striped-bg: rgba(255,255,255,.02); color: var(--text); }
body.dark-mode .table thead th  { background: #0f172a; border-color: var(--border); color: var(--text-muted); }
body.dark-mode .table td        { border-color: var(--border); }
body.dark-mode .form-control,
body.dark-mode .form-select     { background: #0f172a; border-color: var(--border); color: var(--text); }
body.dark-mode .form-control::placeholder { color: var(--text-light); }
body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus { background: #0f172a; color: var(--text); }
body.dark-mode #erp-bg-layer { display: none !important; }
body.dark-mode.has-bg-image { background-image: none !important; }
body.dark-mode .org-node { background: #1e293b !important; color: var(--text) !important; }
body.dark-mode .org-node div { color: var(--text); }
body.dark-mode #canvas-wrapper { background: #0f172a !important; }
body.dark-mode .btn-light       { background: #334155; border-color: #475569; color: var(--text); }
body.dark-mode .text-muted          { color: var(--text-muted) !important; }
body.dark-mode .btn-outline-secondary { border-color: #475569; color: var(--text-muted); }
body.dark-mode .btn-outline-secondary:hover { background: #334155; color: var(--text); }
body.dark-mode .modal-content   { background: #1e293b; color: var(--text); }
body.dark-mode .modal-header,
body.dark-mode .modal-footer    { border-color: var(--border); }
body.dark-mode .nav-tabs        { border-color: var(--border); }
body.dark-mode .nav-link        { color: var(--text-muted); }
body.dark-mode .nav-link.active { background: var(--card-bg); border-color: var(--border) var(--border) var(--card-bg); color: var(--primary); }
body.dark-mode .dropdown-menu   { background: #1e293b; border-color: var(--border); }
body.dark-mode .input-group-text{ background: #0f172a; border-color: var(--border); color: var(--text-muted); }
body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
.item-sin-stock td { background: rgba(220,53,69,.07) !important; color: #dc3545; }
.item-sin-stock .badge-sin-stock { background: #dc3545; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 10px; }

/* ── Módulo Notas ──────────────────────────────────── */
.nota-section-label { font-size: 10.5px; font-weight: 700; letter-spacing: .7px; color: var(--text-muted); margin-bottom: 10px; }
.notas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 8px; }
.nota-card {
  border-radius: 10px; border: 1px solid rgba(0,0,0,.1); padding: 14px 14px 10px;
  cursor: pointer; transition: box-shadow .15s, transform .1s;
  display: flex; flex-direction: column; min-height: 120px;
}
.nota-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.13); transform: translateY(-2px); }
.nota-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.nota-card-titulo { font-weight: 700; font-size: 13.5px; color: #1a1a2e; line-height: 1.3; flex: 1; }
.nota-pin-btn { background: none; border: none; padding: 0; font-size: 14px; color: #aaa; line-height: 1; cursor: pointer; flex-shrink: 0; }
.nota-pin-btn.pinned { color: #e67e22; }
.nota-card-body { font-size: 12.5px; color: #444; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; line-height: 1.5; word-break: break-word; }
.nota-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 11px; color: #999; }
.nota-del-btn { background: none; border: none; padding: 0; font-size: 13px; color: #bbb; cursor: pointer; opacity: 0; transition: opacity .15s; }
.nota-card:hover .nota-del-btn { opacity: 1; }
.nota-del-btn:hover { color: #e74c3c; }

/* Overlay editor */
.nota-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1060; display: flex; align-items: center; justify-content: center; padding: 16px; }
.nota-editor { border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); border: 1px solid rgba(0,0,0,.08); overflow: hidden; }
.nota-ed-titulo { border: none; outline: none; background: transparent; font-size: 17px; font-weight: 700; padding: 18px 20px 6px; width: 100%; color: #1a1a2e; }
.nota-ed-titulo::placeholder { color: #bbb; }
.nota-ed-body { border: none; outline: none; background: transparent; font-size: 14px; padding: 6px 20px 12px; width: 100%; resize: none; min-height: 160px; line-height: 1.6; color: #333; flex: 1; overflow-y: auto; }
.nota-ed-body::placeholder { color: #bbb; }
.nota-ed-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 12px; border-top: 1px solid rgba(0,0,0,.07); flex-wrap: wrap; gap: 8px; }
.nota-color-row { display: flex; gap: 7px; }
.nota-color-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); cursor: pointer; transition: transform .1s; }
.nota-color-swatch:hover { transform: scale(1.2); }
.nota-color-swatch.active { border: 3px solid #555; transform: scale(1.15); }
.nota-ed-status { font-size: 11px; color: #aaa; }

.nota-card[draggable="true"]:active { cursor: grabbing; }
.nota-folder-btn.drag-over { box-shadow: 0 0 0 3px var(--primary, #0d6efd); transform: scale(1.05); transition: transform .12s, box-shadow .12s; }

/* Dark mode adjustments */
body.dark-mode .nota-card { border-color: rgba(255,255,255,.08); filter: brightness(.88) saturate(.9); }
body.dark-mode .nota-card-titulo { color: #111; }
body.dark-mode .nota-card-body { color: #333; }
body.dark-mode .nota-editor { filter: brightness(.9); }
body.dark-mode .nota-ed-titulo, body.dark-mode .nota-ed-body { color: #111; }
body.dark-mode .search-input-wrap { background: #0f172a; border-color: var(--border); }
body.dark-mode .login-right     { background: linear-gradient(rgba(15,23,42,.55), rgba(15,23,42,.55)), url('../wallpaper.jpg') center/cover no-repeat; }
body.dark-mode .login-form-card { background: rgba(30,41,59,.88); color: var(--text); }
body.dark-mode .bg-light        { background-color: #0f172a !important; color: var(--text); }
/* Kanban cards */
body.dark-mode .kanban-card      { background: var(--card-bg); }
body.dark-mode .kanban-col       { background: var(--body-bg); }
body.dark-mode .kanban-col-count { background: var(--card-bg); }
/* Tablas con filas coloreadas */
body.dark-mode .table-light      { --bs-table-bg: var(--border-light); --bs-table-color: var(--text); }
body.dark-mode .table-success    { --bs-table-bg: rgba(39,174,96,.15); --bs-table-color: var(--text); }
body.dark-mode .table-warning    { --bs-table-bg: rgba(243,156,18,.15); --bs-table-color: var(--text); }
body.dark-mode .table-danger     { --bs-table-bg: rgba(231,76,60,.15); --bs-table-color: var(--text); }
/* Cajas de importación / feedback */
body.dark-mode .imp-tip-box      { background: var(--body-bg) !important; border-color: var(--border) !important; }
body.dark-mode .imp-warn-box     { background: rgba(243,156,18,.12) !important; border-color: rgba(243,156,18,.3) !important; color: var(--text) !important; }
body.dark-mode .imp-err-box      { background: rgba(231,76,60,.12) !important; border-color: rgba(231,76,60,.3) !important; color: var(--text) !important; }
/* Cotizaciones totales panel */
body.dark-mode .cot-totals       { background: var(--body-bg); }
/* Code/badge spans con background hardcodeado */
body.dark-mode code { background: var(--border-light) !important; color: var(--text) !important; }
body.dark-mode span[style*="background:#f1f4f8"],
body.dark-mode span[style*="background: #f1f4f8"],
body.dark-mode span[style*="background:#f1f5f9"],
body.dark-mode span[style*="background:#f8fafc"] { background: var(--border-light) !important; color: var(--text) !important; }
/* Dashboard card headers con color fijo */
body.dark-mode .card-header[style*="background:#FFF8E7"],
body.dark-mode .card-header[style*="background: #FFF8E7"] { background: rgba(243,156,18,.12) !important; }
/* Badges de proceso (estampado/bordado) en dark mode */
body.dark-mode span[style*="background:#dbeafe"] { background: rgba(37,99,235,.2) !important; }
body.dark-mode span[style*="background:#fef9c3"] { background: rgba(133,77,14,.2) !important; color: #fbbf24 !important; }
/* Fondos de sección fijos */
body.dark-mode .list-group-item  { background: var(--card-bg); border-color: var(--border); color: var(--text); }
body.dark-mode .alert-light      { background: var(--border-light); border-color: var(--border); color: var(--text); }
body.dark-mode .alert-info       { background: rgba(14,165,233,.12); border-color: rgba(14,165,233,.3); color: #7dd3fc; }
body.dark-mode .alert-success    { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); color: #86efac; }
body.dark-mode .alert-warning    { background: rgba(234,179,8,.12); border-color: rgba(234,179,8,.3); color: #fde047; }
body.dark-mode .alert-danger     { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); color: #fca5a5; }
body.dark-mode .dropdown-item    { color: var(--text); }
body.dark-mode .dropdown-item:hover { background: var(--border-light); color: var(--text); }
/* Tablas — texto en filas coloreadas */
body.dark-mode .table-warning td,
body.dark-mode .table-danger td,
body.dark-mode .table-info td,
body.dark-mode .table-success td { color: var(--text) !important; }
/* tfoot TOTAL row — Bootstrap --bs-table-color overrides tr color inheritance */
body.dark-mode .table tfoot td { color: var(--text) !important; }
/* Filtros en pedidos — texto del input */
body.dark-mode .pedido-filtros .form-control,
body.dark-mode .pedido-filtros .form-select { color: var(--text); font-size: 13px; }
/* Mensajes de pedidos con backgrounds fijos */
body.dark-mode .ped-msg.pregunta .ped-msg-text         { background: rgba(253,126,20,.12) !important; }
body.dark-mode .ped-msg.material_faltante .ped-msg-text { background: rgba(220,53,69,.12) !important; }
body.dark-mode .ped-msg.respuesta .ped-msg-text         { background: rgba(25,135,84,.12) !important; }

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

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 13.5px;
  overflow: hidden;
  height: 100vh;
}
body.has-bg-image { background: transparent; }
body.has-bg-image .main-area,
body.has-bg-image .content-area,
body.has-bg-image .topbar { background: transparent; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
a { text-decoration: none; }

/* ══════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════ */
.login-screen { display: flex; height: 100vh; overflow: hidden; }
.input-group-lg>.form-control {transition: all 0.3s ease;}
.input-group-lg>.form-control:focus {transform: scale(1); border-color: #2a56db; }
.input-group-lg>.form-control {padding: 10px; font-size: 1.1rem;}

/*  .login-left {
  width: 24% !important;
  background: linear-gradient(168deg, #ef417a 0%, #112f85 45%, #0e0b0c 130%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5%;
  color: white;
  position: relative;
  overflow: hidden;
} */

.login-left::after {
  content: '';
  position: absolute;
  bottom: -100px; right: -100px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
}

.login-left::before {
  content: '';
  position: absolute;
  top: -60px; left: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
}

.login-logo-img {
  max-width: 220px; height: auto;
  filter: drop-shadow(0 12px 4px rgba(1, 0, 0, .25));
}

.login-subtitle { color: rgba(255,255,255,.6); font-size: 14.5px; margin-bottom: 44px; line-height: 1.5; }

.login-features { list-style: none; padding: 0; margin-bottom: 40px; display: flex; flex-direction: column; gap: 13px; }
.login-features li { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: rgba(255,255,255,.78); }
.login-features li i { color: #6BC95E; font-size: 16px; flex-shrink: 0; }

.login-right {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: url('../wallpaper.jpg') center/cover no-repeat;
  padding: 40px 24px; overflow-y: auto;
}

.login-form-card {
  width: 100%; max-width: 390px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 32px 28px;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.login-form-header { margin-bottom: 28px; }
.login-form-header h2 { font-size: 23px; color: var(--text); margin-bottom: 4px; font-weight: 700; }
.login-form-header p { color: var(--text-muted); font-size: 13.5px; margin: 0; }

.input-group-text { background: var(--border-light); border-color: var(--border); color: var(--text-muted); }

.form-control, .form-select {
  border-color: var(--border);
  background: var(--border-light);
  font-size: 13.5px;
  font-family: 'Montserrat', sans-serif;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-select { padding: 0; }

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,119,190,.1);
  background: white;
  outline: none;
}

.btn-primary { background: var(--primary); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.login-demo-hint {
  margin-top: 18px;
  padding: 10px 14px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.6;
}
.login-demo-hint i { color: var(--primary); }

@media (max-width: 768px) {
  .login-left { display: none; }
}

/* ══════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════ */
.app-shell { display: flex; height: 100vh; overflow: hidden; position: relative; z-index: 1; }

/* ── SIDEBAR ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  height: 100vh;
  overflow-y: auto; overflow-x: hidden;
  transition: transform var(--transition), width var(--transition);
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 15px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}

.sidebar-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: #0d6efd;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,119,190,.4);
}

.sidebar-brand-name { display: block; font-size: 14.5px; font-weight: 700; color: white; line-height: 1.15; }
.sidebar-brand-sub {
  display: block; font-size: 9.5px; font-weight: 600;
  color: rgba(255,255,255,.35); letter-spacing: 1.8px; text-transform: uppercase;
}

.sidebar-section-label {
  padding: 18px 18px 5px;
  font-size: 9.5px; font-weight: 700;
  color: rgba(255,255,255,.22);
  letter-spacing: 1.4px; text-transform: uppercase;
}

.sidebar-nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px 9px 13px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.52);
  font-size: 13px; font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: rgba(255,255,255,.88);
  background: var(--sidebar-hover);
}

/* ── ACTIVE nav item: estilo facto.cl — borde izquierdo azul ── */
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
  border-left: 3px solid var(--primary);
  padding-left: 10px;
}

.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }

.nav-badge {
  background: var(--danger);
  color: white; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}
.nav-badge:empty { display: none; }

/* ── Sidebar accordion submenu ──────────────────────── */
.nav-group { position: static; }
.nav-group > .nav-item { width: 100%; }
.nav-group > .nav-item .nav-arrow {
  font-size: 10px;
  margin-left: auto;
  transition: transform 0.25s ease;
}
.nav-group.open > .nav-item .nav-arrow { transform: rotate(90deg); }
.nav-group > .nav-item .nav-group-badge { margin-right: 4px; }
.nav-dropdown {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 0 0 12px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, padding 0.28s ease;
}
.nav-group.open .nav-dropdown {
  max-height: 600px;
  padding: 2px 0 4px 12px;
}
.nav-dropdown a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px;
  color: rgba(255,255,255,.6);
  font-size: 12px; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  border-left: 2px solid rgba(255,255,255,.08);
  position: relative;
}
.nav-dropdown a:hover { background: var(--sidebar-hover); color: white; border-left-color: var(--primary); }
.nav-dropdown a.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--primary);
}
.nav-dropdown a .nav-badge {
  margin-left: auto;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px;
  border-top: 1px solid rgba(255,255,255,.05);
}

.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white; flex-shrink: 0;
}

.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 10.5px; color: rgba(255,255,255,.35); }

.sidebar-logout-btn {
  background: none; border: none;
  color: rgba(255,255,255,.3); font-size: 15px;
  padding: 4px; cursor: pointer;
  transition: color var(--transition); flex-shrink: 0;
}
.sidebar-logout-btn:hover { color: var(--danger); }

/* ── SIDEBAR OVERLAY (mobile) ──────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 199;
}

/* ── MAIN AREA ──────────────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── TOPBAR ─────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0; z-index: 100;
  box-shadow: var(--shadow-xs);
  gap: 12px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.topbar-menu-btn {
  background: none; border: none;
  font-size: 20px; color: var(--text-muted);
  cursor: pointer; padding: 5px 7px;
  border-radius: var(--radius-sm);
  transition: all var(--transition); line-height: 1;
}
.topbar-menu-btn:hover { background: var(--body-bg); color: var(--text); }

.breadcrumb { font-size: 14.5px; font-weight: 700; color: var(--text); margin: 0; }

.topbar-titles {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
  min-width: 0;
}
.topbar-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.topbar-subtitle:empty { display: none; }

/* Search box en topbar */
.topbar-search {
  flex: 1; max-width: 340px;
  position: relative;
}
.topbar-search i {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.topbar-search input {
  width: 100%; padding: 7px 60px 7px 34px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--body-bg); font-size: 13px;
  font-family: 'Montserrat', sans-serif; color: var(--text);
  transition: all var(--transition);
  outline: none;
}
.topbar-search-kbd {
  position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: var(--card-bg); border: 1px solid var(--border);
  color: var(--text-muted); pointer-events: none;
  font-family: inherit;
}
.topbar-search input:focus ~ .topbar-search-kbd { opacity: 0; }
.topbar-search input:focus {
  background: var(--card-bg); border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,119,190,.1);
}
.topbar-search input::placeholder { color: var(--text-light); }

/* Resultados búsqueda global */
.global-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 999; max-height: 320px; overflow-y: auto;
}
.gs-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 14px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.gs-item:last-child { border-bottom: none; }
.gs-item:hover { background: var(--body-bg); }
.gs-icon { font-size: 15px; color: var(--primary); margin-top: 2px; flex-shrink: 0; }
.gs-label { font-size: 13px; font-weight: 600; }
.gs-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.gs-empty { padding: 14px; font-size: 13px; color: var(--text-muted); text-align: center; }

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

.topbar-btn {
  background: #e9eef5; border: 1px solid #c8d0dc;
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text); cursor: pointer;
  position: relative; transition: all var(--transition);
}
.topbar-btn:hover { background: #d8e0ea; border-color: #a9b4c4; }
body.dark-mode .topbar-btn { background: #334155; border-color: #475569; color: var(--text); }
body.dark-mode .topbar-btn:hover { background: #475569; border-color: #64748b; }

.topbar-btn-badge {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--danger); border-radius: 50%; border: 1.5px solid white;
}

.topbar-user {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--body-bg); }

.topbar-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
}

.topbar-user-name { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── CONTENT AREA ──────────────────────────────────── */
.content-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 22px 24px;
  background: var(--body-bg);
}

/* ══════════════════════════════════════════════════════
   COMPONENTES COMUNES
═══════════════════════════════════════════════════════ */

/* Page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}

.page-title { font-size: 19px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -.3px; }
.page-subtitle { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}

.card-header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  background: transparent;
  display: flex; align-items: center; justify-content: space-between;
}

.card-body { padding: 16px; }

/* ── STAT CARDS (estilo facto.cl) ───────────────────── */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

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

/* Línea de color superior en stat cards */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}

.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.purple { background: var(--secondary-light); color: var(--secondary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: #C97B00; }
.stat-icon.red    { background: var(--danger-light); color: var(--danger); }
.stat-icon.teal   { background: rgba(26,188,156,.15); color: #1ABC9C; }

.stat-body { flex: 1; min-width: 0; }
.stat-value { font-size: 19px; font-weight: 700; color: var(--text); line-height: 1.15; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.stat-delta { font-size: 10.5px; margin-top: 4px; font-weight: 600; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* Tables */
.table { margin: 0; font-size: 13px; }

.table thead th {
  background: #F7F9FC;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  padding: 10px 14px; white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.table tbody tr:hover { background: var(--border-light); }

.table tbody td { padding: 10px 14px; vertical-align: middle; color: var(--text); }

/* Hover con borde izquierdo azul en filas (facto style) */
.table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

/* Badges */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-status::before {
  content: ''; width: 5px; height: 5px;
  border-radius: 50%; background: currentColor; opacity: .7;
}

.badge-activo    { background: var(--success-light); color: #1E8449; }
.badge-inactivo  { background: var(--border-light); color: var(--text-muted); }
.badge-pendiente { background: var(--warning-light); color: #9A6700; }
.badge-aceptada  { background: var(--success-light); color: #1E8449; }
.badge-rechazada { background: var(--danger-light); color: #C0392B; }
.badge-enviada   { background: var(--primary-light); color: var(--primary); }
.badge-pagada    { background: var(--success-light); color: #1E8449; }
.badge-vencida   { background: var(--danger-light); color: #C0392B; }
.badge-alta      { background: var(--danger-light); color: #C0392B; }
.badge-media     { background: var(--warning-light); color: #9A6700; }
.badge-baja      { background: var(--border-light); color: var(--text-muted); }
.badge-completada{ background: var(--success-light); color: #1E8449; }
.badge-proceso   { background: var(--primary-light); color: var(--primary); }
.badge-stock-bajo{ background: var(--danger-light); color: #C0392B; }

/* Buttons */
.btn { font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 13px; border-radius: var(--radius-sm); }

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-icon {
  width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 13px;
}

/* Search bar */
.search-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search-input-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; flex-shrink: 0; }
.search-input-wrap i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
.search-input-wrap input {
  padding-left: 33px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  height: 34px; font-size: 13px; width: 100%;
  font-family: 'Montserrat', sans-serif;
  background: var(--card-bg); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0,119,190,.08);
  outline: none;
}

/* Scroll to top */
.scroll-top-btn {
  position: fixed; bottom: 80px; right: 20px; z-index: 9000;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: white; border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  cursor: pointer; font-size: 16px;
  transition: opacity .2s, transform .2s;
}
.scroll-top-btn:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* Empty state */
.empty-state { text-align: center; padding: 44px 24px; color: var(--text-muted); }
.empty-state i { font-size: 44px; opacity: .2; display: block; margin-bottom: 10px; }
.empty-state p { font-size: 13.5px; margin: 0; }

/* Modal */
.modal-header { border-bottom: 1px solid var(--border); padding: 14px 18px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 18px; }
.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-body { padding: 18px; }

.form-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* Action buttons in table */
.table-actions { display: flex; gap: 3px; }

/* Toasts */
.toast { border: none; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13px; min-width: 250px; background: var(--card-bg); color: var(--text); }
body.dark-mode .toast .btn-close { filter: invert(1); }

/* Loading state */
.page-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 24px; color: var(--text-muted); font-size: 13.5px;
}

/* ══════════════════════════════════════════════════════
   MOBILE / RESPONSIVE
═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100%;
    transform: translateX(-100%); z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.open { display: block; }
  .content-area { padding: 14px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar-search { display: none; }
}

@media (min-width: 769px) { #sidebar-toggle { display: none; } }

/* ══════════════════════════════════════════════════════
   COTIZACIONES — items table + totals
═══════════════════════════════════════════════════════ */
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th {
  background: var(--border-light); padding: 8px 10px;
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; border-bottom: 1px solid var(--border);
}
.items-table td { padding: 5px 6px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.items-table input, .items-table select { font-size: 13px; font-family: 'Montserrat', sans-serif; }
.items-table .btn-del { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 15px; padding: 2px 5px; }

.cot-totals { background: #F7F9FC; border-radius: var(--radius-sm); padding: 12px 16px; border: 1px solid var(--border-light); }
.cot-totals-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.cot-totals-row.total { font-size: 16px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; color: var(--primary); }

/* ══════════════════════════════════════════════════════
   TAREAS — Kanban
═══════════════════════════════════════════════════════ */
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }

.kanban-col {
  min-width: 255px; flex: 1;
  background: #F0F3F8; border-radius: var(--radius); padding: 12px;
  border: 1px solid var(--border);
}

.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}

.kanban-col-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }
.kanban-col-count { background: white; color: var(--text-muted); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); }

.kanban-card {
  background: white; border-radius: var(--radius-sm);
  padding: 11px 13px; margin-bottom: 7px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.kanban-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.kanban-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; line-height: 1.4; }
.kanban-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════════════ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 14px;
}

/* Stock indicator */
.stock-bar { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.stock-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.stock-bar-fill.ok   { background: var(--success); }
.stock-bar-fill.warn { background: var(--warning); }
.stock-bar-fill.low  { background: var(--danger); }

/* ══════════════════════════════════════════════════════
   EXCEL IMPORT — Modal especial
═══════════════════════════════════════════════════════ */
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--border-light);
}

.import-dropzone:hover, .import-dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.import-dropzone i { font-size: 40px; color: var(--text-light); margin-bottom: 10px; display: block; }
.import-dropzone:hover i, .import-dropzone.drag-over i { color: var(--primary); }

.import-dropzone .drop-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.import-dropzone .drop-sub   { font-size: 12px; color: var(--text-muted); }

.import-progress { margin-top: 12px; }
.import-progress-bar {
  height: 6px; background: var(--border);
  border-radius: 4px; overflow: hidden; margin-bottom: 6px;
}
.import-progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s ease; }
.import-progress-label { font-size: 12px; color: var(--text-muted); text-align: center; }

.import-preview {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px;
}
.import-preview table { margin: 0; font-size: 11.5px; }
.import-preview th { position: sticky; top: 0; background: var(--border-light); z-index: 1; padding: 7px 10px !important; }
.import-preview td { padding: 5px 10px !important; }

.import-summary {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--border-light); border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: 13px;
}

.import-summary .imp-stat { display: flex; flex-direction: column; align-items: center; }
.import-summary .imp-stat strong { font-size: 20px; font-weight: 700; color: var(--text); }
.import-summary .imp-stat span { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* ══════════════════════════════════════════════════════
   NOTIFICACIONES — Panel desplegable
═══════════════════════════════════════════════════════ */
.notif-wrap { position: relative; }

.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 1080;
  animation: fadeInDown .15s ease;
}

@keyframes fadeInDown {
  from { opacity:0; transform:translateY(-6px); }
  to   { opacity:1; transform:translateY(0); }
}

.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
}

.notif-list { max-height: 340px; overflow-y: auto; }

.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 16px; border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: background var(--transition);
  text-decoration: none; color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--body-bg); }

.notif-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; margin-top: 1px;
}
.notif-icon.warn  { background: var(--warning-light); color: var(--warning); }
.notif-icon.danger { background: var(--danger-light);  color: var(--danger); }
.notif-icon.info  { background: var(--primary-light);  color: var(--primary); }

.notif-body { flex: 1; min-width: 0; }
.notif-dismiss {
  background: none; border: none; padding: 2px 4px; margin-left: 4px;
  color: var(--text-muted); font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity .15s; flex-shrink: 0; align-self: center;
  border-radius: 4px; cursor: pointer;
}
.notif-item:hover .notif-dismiss { opacity: 1; }
.notif-dismiss:hover { background: var(--border-light); color: var(--text); }
.notif-title { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.notif-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.notif-empty {
  text-align: center; padding: 28px 16px;
  color: var(--text-muted); font-size: 13px;
}
.notif-empty i { font-size: 28px; display: block; margin-bottom: 8px; opacity:.4; }

/* ══════════════════════════════════════════════════════
   MISC
═══════════════════════════════════════════════════════ */
.cursor-pointer { cursor: pointer; }

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Skeleton loading */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

/* Section divider */
.section-divider {
  height: 1px; background: var(--border-light);
  margin: 20px 0;
}

/* Chip / tag filter buttons */
.chip {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--card-bg); color: var(--text-muted);
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.chip.active { border-color: var(--primary); background: var(--primary); color: white; }

/* ══════════════════════════════════════════════════════
   PRODUCCIÓN — Kanban + Pipeline + Tallas
═══════════════════════════════════════════════════════ */

/* Pipeline bar */
.prod-pipeline-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 0; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
  overflow-x: auto;
}
.prod-pipeline-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; min-width: 72px;
}
.prod-pipeline-dot {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.prod-pipeline-step:hover .prod-pipeline-dot { transform: scale(1.1); }
.prod-pipeline-label { font-size: 10.5px; font-weight: 600; text-align: center; white-space: nowrap; }
.prod-pipeline-arrow { color: var(--text-light); font-size: 12px; padding: 0 4px; padding-bottom: 18px; }

/* Kanban board */
.kanban-wrap { overflow-x: auto; padding: 16px; }
.kanban-board { display: flex; gap: 12px; min-width: max-content; }

.kanban-col {
  width: 224px; background: var(--body-bg);
  border-radius: var(--radius); padding: 10px;
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 2px 4px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
}
.kanban-count {
  min-width: 22px; height: 22px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; padding: 0 6px;
}
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-empty { text-align: center; padding: 20px 8px; font-size: 12px; color: var(--text-light); }

.kanban-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  cursor: pointer; transition: all var(--transition);
}
.kanban-card:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,.1);
  transform: translateY(-2px);
  border-color: #c8d0dc;
}
.kanban-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.kanban-num { font-family: monospace; font-size: 10.5px; color: var(--text-muted); background: var(--body-bg); padding: 1px 5px; border-radius: 3px; }
.kanban-card-title { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; margin-bottom: 3px; }
.kanban-card-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.kanban-card-tallas { font-size: 10.5px; color: var(--text-muted); margin-bottom: 4px; font-family: monospace; }
.kanban-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 6px; border-top: 1px solid var(--border-light);
  margin-top: 6px;
}

/* Tallas grid en modal */
.tallas-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
  margin-bottom: 10px;
}
.talla-input-wrap { text-align: center; }
.talla-label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase;
}
.talla-input { text-align: center; padding: 6px 4px; font-weight: 600; font-size: 14px; }
.tallas-total {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--body-bg);
  border-radius: var(--radius-sm); border: 1px solid var(--border-light);
}

/* Talla pills en tabla */
.talla-pill {
  display: inline-block; background: var(--border-light);
  border-radius: 4px; padding: 1px 6px;
  font-size: 11px; margin: 1px; white-space: nowrap;
}
.talla-pill strong { color: var(--primary); }

@media (max-width: 768px) {
  .tallas-grid { grid-template-columns: repeat(3, 1fr); }
  .prod-pipeline-bar { justify-content: flex-start; }
}

/* ══════════════════════════════════════════════════════
   GASTOS — Stats, barras y filtros
═══════════════════════════════════════════════════════ */
.gastos-stat-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
@media (max-width: 768px) { .gastos-stat-cards { grid-template-columns: repeat(2, 1fr); } }

.gastos-stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
}
.gastos-stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.gastos-stat-value { font-size: 18px; font-weight: 700; color: var(--text); }

/* Barras por categoría */
.gasto-barra-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.gasto-barra-label { font-size: 12px; color: var(--text-muted); width: 150px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gasto-barra-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.gasto-barra-fill  { height: 100%; border-radius: 4px; transition: width .4s ease; }
.gasto-barra-monto { font-size: 12px; font-weight: 600; color: var(--text); width: 110px; text-align: right; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════
   CLIENTES / PROVEEDORES — Módulo unificado
═══════════════════════════════════════════════════════ */
.cl-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.cl-tab-btn {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-muted);
  cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; gap: 6px;
}
.cl-tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.cl-tab-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.cl-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 10px; background: var(--border); color: var(--text-muted);
  font-size: 10.5px; font-weight: 700;
}
.cl-tab-btn.active .cl-tab-count { background: var(--primary); color: white; }

/* Datos extra editor */
.cl-extra-list { display: flex; flex-direction: column; gap: 6px; }
.cl-extra-row  { display: flex; gap: 8px; align-items: center; }
.cl-extra-row input:first-child { width: 160px; flex-shrink: 0; }
.cl-extra-row input:nth-child(2) { flex: 1; }

/* ═══════════════════════════════════════════════════
   PEDIDOS COLABORATIVOS
═══════════════════════════════════════════════════════ */

/* Barra de filtros genérica */
.filters-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.filters-bar .form-select,
.filters-bar .form-control,
.filters-bar .input-group { font-size: 13px; }
.filters-bar .form-select,
.filters-bar .form-control { height: 36px; padding-top: 6px; padding-bottom: 6px; }
.filters-bar .input-group .form-control { height: 36px; }
.filters-bar .input-group-text { height: 36px; }

/* Layout split */
.ped-layout {
  display: flex; gap: 16px; align-items: flex-start; min-height: 60vh;
}
.ped-list-col {
  width: 34%; flex-shrink: 0;
}
.ped-detail-panel {
  flex: 1; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-y: auto; position: sticky;
  top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px);
  min-width: 0;
}
.ped-detail-close {
  position: absolute; top: 12px; right: 12px; cursor: pointer;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--border-light); color: var(--text-muted);
  font-size: 14px; z-index: 2; transition: var(--transition);
}
.ped-detail-close:hover { background: var(--danger-light); color: var(--danger); }

@media (max-width: 900px) {
  .ped-layout { flex-direction: column; }
  .ped-list-col { width: 100%; }
  .ped-detail-panel { width: 100%; }
}

/* Pedido card */
.ped-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: var(--transition);
}
.ped-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.ped-card-active { border-color: var(--primary); background: var(--primary-light); }
.ped-card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; flex-wrap: wrap; }
.ped-numero { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.5px; }
.ped-card-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ped-card-client, .ped-card-date { font-size: 12px; color: var(--text-muted); }

/* Progress bar en card */
.ped-progress-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.ped-progress-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width .3s; }

/* Detail sections */
.ped-detail-head {
  padding: 20px 20px 14px; border-bottom: 1px solid var(--border-light);
}
.ped-section {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.ped-section:last-child { border-bottom: none; }
.ped-section-title {
  font-size: 12.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px;
}

/* Items list en detalle */
.ped-items-list { display: flex; flex-direction: column; gap: 6px; }
.ped-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm); background: var(--border-light);
}
.ped-item-check { cursor: pointer; font-size: 17px; color: var(--text-muted); flex-shrink: 0; transition: var(--transition); }
.ped-item-check.checked { color: var(--success); }
.ped-item-check:hover { color: var(--success); }
.ped-item-desc { flex: 1; font-size: 13.5px; }
.ped-item-qty { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Items editor en modal */
/* Fichas técnicas + Control de calidad — filas dinámicas */
.fic-row { flex-wrap: wrap; }
.fic-row input, .fic-row select { min-width: 0; }

.ped-items-editor-wrap { display: flex; flex-direction: column; gap: 6px; }
.ped-item-edit-row { display: flex; gap: 6px; align-items: center; }
.ped-item-edit-row input:first-child { flex: 1; }

/* Hilo de comentarios */
.ped-thread { display: flex; flex-direction: column; gap: 12px; max-height: 400px; overflow-y: auto; padding-right: 4px; }
.ped-thread-empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 24px; color: var(--text-muted); font-size: 13px;
}
.ped-thread-empty i { font-size: 28px; opacity: 0.5; }

.ped-msg { display: flex; gap: 10px; align-items: flex-start; }
.ped-msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; background: var(--border-light); color: var(--text-muted);
}
.ped-msg-body { flex: 1; min-width: 0; }
.ped-msg-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
}
.ped-msg-autor { font-size: 13px; font-weight: 600; color: var(--text); }
.ped-msg-tipo  { font-size: 11.5px; color: var(--text-muted); }
.ped-msg-time  { font-size: 11px; color: var(--text-light); margin-left: auto; }
.ped-msg-text  {
  font-size: 13.5px; line-height: 1.5; color: var(--text);
  background: var(--border-light); padding: 8px 12px; border-radius: var(--radius-sm);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
}
.ped-msg.pregunta .ped-msg-text         { background: var(--warning-light); border-left: 3px solid #fd7e14; }
.ped-msg.material_faltante .ped-msg-text { background: var(--danger-light);  border-left: 3px solid #dc3545; }
.ped-msg.respuesta .ped-msg-text         { background: var(--success-light); border-left: 3px solid #198754; }

/* Respuestas anidadas bajo pregunta */
.ped-replies-wrap { margin-top: 6px; padding-left: 20px; border-left: 2px solid var(--border); }
.ped-msg-reply    { margin-top: 8px; }
.ped-msg-reply .ped-msg-avatar { width: 28px; height: 28px; font-size: 10px; }

/* Tipo buttons en modal comentario */
.ped-tipo-btn { cursor: pointer; }
.ped-tipo-btn span {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 500;
  border: 1.5px solid var(--border); color: var(--text-muted);
  transition: var(--transition); white-space: nowrap;
}
.ped-tipo-btn:hover span, .ped-tipo-btn.active span {
  border-color: var(--primary); background: var(--primary-light); color: var(--primary);
}

/* btn-xs */
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ── Print / PDF ───────────────────────────────────── */
#cot-print-area { display: none; }

@media print {
  /* Ocultar todo excepto el área de impresión */
  body > *                { visibility: hidden !important; }
  #cot-print-area         { display: block !important; visibility: visible !important;
                            position: fixed; inset: 0; background: white; z-index: 99999;
                            padding: 20mm 18mm; font-family: 'Montserrat', sans-serif; }
  #cot-print-area *       { visibility: visible !important; }
}

/* Estilos del documento impreso (visibles siempre para preview) */
.print-doc { max-width: 800px; margin: 0 auto; color: #1E2D3D; font-size: 12.5px; }

.print-hdr {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 3px solid #0077BE; padding-bottom: 16px; margin-bottom: 20px;
}
.print-brand-block { display: flex; align-items: center; gap: 12px; }
.print-logo-circle {
  width: 48px; height: 48px; border-radius: 50%; background: #0077BE;
  color: white; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.print-brand-name { font-size: 20px; font-weight: 700; color: #0077BE; }
.print-brand-sub  { font-size: 11px; color: #7B8EA6; }

.print-doc-block { text-align: right; }
.print-doc-type  { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: #7B8EA6; text-transform: uppercase; }
.print-doc-num   { font-size: 22px; font-weight: 800; color: #1E2D3D; line-height: 1.1; }

.print-parties {
  display: flex; gap: 24px; margin-bottom: 20px; align-items: flex-start;
}
.print-party         { flex: 1; }
.print-party-label   { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #7B8EA6; margin-bottom: 4px; }
.print-party-name    { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.print-meta-table    { min-width: 200px; }
.print-meta-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-meta-table td { padding: 2px 6px; }
.print-meta-table td:first-child { color: #7B8EA6; white-space: nowrap; }

.print-items { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 12px; }
.print-items thead tr { background: #F4F6F9; }
.print-items th { padding: 8px 10px; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: #7B8EA6; border-bottom: 2px solid #E3E8EF; }
.print-items td { padding: 8px 10px; border-bottom: 1px solid #F0F3F8; }
.print-items tbody tr:last-child td { border-bottom: none; }

.print-totals       { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-bottom: 20px; }
.print-total-row    { display: flex; gap: 40px; font-size: 12.5px; }
.print-total-row span:first-child { color: #7B8EA6; min-width: 130px; text-align: right; }
.print-total-row span:last-child  { min-width: 110px; text-align: right; font-weight: 600; }
.print-total-final  { font-size: 16px !important; font-weight: 800 !important; color: #0077BE; border-top: 2px solid #E3E8EF; padding-top: 6px; margin-top: 2px; }
.print-total-final span { font-weight: 800 !important; }

.print-section-lbl  { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #7B8EA6; margin-bottom: 6px; }
.print-notes        { background: #F8FAFC; border-left: 3px solid #E3E8EF; padding: 10px 14px; border-radius: 4px; margin-bottom: 20px; font-size: 12px; }
.print-notes p      { margin: 0; color: #4A5568; }

.print-footer       { border-top: 1px solid #E3E8EF; padding-top: 14px; font-size: 11.5px; color: #7B8EA6; }
.print-sigs         { display: flex; justify-content: space-around; margin-top: 40px; text-align: center; }
.print-sig-line     { width: 180px; border-top: 1.5px solid #B4C0CE; margin: 0 auto 6px; }
.print-sigs small   { font-size: 11px; color: #9BA7B5; }

/* ═══════════════════════════════════════════════════
   BODEGA — Stock bajo mínimo + Sucursales
═══════════════════════════════════════════════════════ */
.bodega-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 768px) {
  .bodega-stats { grid-template-columns: repeat(2, 1fr); }
}
.bodega-stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.bodega-stat-card.danger  { border-left: 4px solid var(--danger); }
.bodega-stat-card.warning { border-left: 4px solid #fd7e14; }
.bodega-stat-card.info    { border-left: 4px solid var(--primary); }
.bodega-stat-card.neutral { border-left: 4px solid var(--border); }
.bodega-stat-num {
  font-size: 28px; font-weight: 800; line-height: 1;
  color: var(--text);
}
.bodega-stat-card.danger  .bodega-stat-num { color: var(--danger); }
.bodega-stat-card.warning .bodega-stat-num { color: #fd7e14; }
.bodega-stat-card.info    .bodega-stat-num { color: var(--primary); }
.bodega-stat-lbl { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ═══════════════════════════════════════════════════
   PIPELINE — Seguimiento de pedido
═══════════════════════════════════════════════════════ */
.ped-pipeline {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(220,53,69,0); }
}

/* ── Cuentas Corrientes ───────────────────────────────── */
.cc-cliente-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.cc-cliente-row:hover { background: var(--hover); }
.cc-cliente-row.cc-con-deuda { border-left: 3px solid var(--danger); }
.cc-cliente-info { display: flex; flex-direction: column; gap: 2px; }
.cc-cliente-monto { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }

/* ── Facturación ──────────────────────────────────── */
.fac-comprobante { font-family: 'Courier New', monospace; }
.fac-header-doc  { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: start; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.fac-tipo-box    { text-align: center; border: 2px solid var(--text); padding: 8px 16px; border-radius: 4px; }
.fac-tipo-letra  { font-size: 36px; font-weight: 900; line-height: 1; }
.fac-cae-box     { display: flex; gap: 24px; background: var(--border-light); border: 1px solid var(--border); border-radius: 4px; padding: 8px 12px; font-size: 12px; }
@media (max-width: 576px) { .fac-header-doc { grid-template-columns: 1fr; } }

/* ── Permisos: rol lector oculta acciones de escritura ── */
body[data-nivel="lector"] [onclick*="openModal"]:not(.lector-ok),
body[data-nivel="lector"] [onclick*="save("]:not(.lector-ok),
body[data-nivel="lector"] [onclick*=".remove("]:not(.lector-ok),
body[data-nivel="lector"] [onclick*=".edit("]:not(.lector-ok),
body[data-nivel="lector"] [onclick*=".add("]:not(.lector-ok),
body[data-nivel="lector"] [onclick*="delete("]:not(.lector-ok),
body[data-nivel="lector"] [onclick*="Nueva"]:not(.lector-ok),
body[data-nivel="lector"] [onclick*="nuevo"]:not(.lector-ok),
body[data-nivel="lector"] [onclick*="Nuevo"]:not(.lector-ok),
body[data-nivel="lector"] .table-actions { display: none !important; }

/* ══════════════════════════════════════════════════════
   MOBILE — mejoras generales responsive
══════════════════════════════════════════════════════ */
@media (max-width: 576px) {
  /* Modales full-screen en mobile */
  .modal-dialog { margin: 0; max-width: 100%; height: 100%; }
  .modal-content { border-radius: 0; min-height: 100vh; }
  .modal-body { max-height: calc(100vh - 130px); overflow-y: auto; }

  /* Tablas: scroll horizontal */
  .card-body .table-responsive,
  .card-body > .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 540px; }

  /* Page header: stack vertical */
  .page-header .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
  .page-header .page-actions .btn { flex: 1 1 auto; }

  /* Stats grid: 1 columna en mobile muy pequeño */
  .dashboard-grid { grid-template-columns: 1fr 1fr; }

  /* Card header con filtros: stack vertical */
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header .search-bar { width: 100%; }
  .card-header .form-control,
  .card-header .form-select { font-size: 14px; }

  /* Ocultar columnas secundarias en mobile */
  .hide-mobile { display: none !important; }

  /* Sidebar overlay más grande en mobile */
  .sidebar { width: 85vw; min-width: unset; }

  /* Topbar ajustado */
  .topbar { padding: 0 10px; }
  .topbar-right { gap: 4px; }
}

/* ══════════════════════════════════════════════════════
   REPORTES — Tabs de categoría
══════════════════════════════════════════════════════ */
.cfg-tab {
  padding: 7px 16px; border-radius: 20px; font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-muted);
  cursor: pointer; transition: var(--transition);
  font-family: 'Montserrat', sans-serif;
}
.cfg-tab:hover { border-color: var(--primary); color: var(--primary); }
.cfg-tab.active {
  border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 600;
}
.cfg-tabs-wrap, .cfg-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — módulos específicos
══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Reportes: tabs en wrap */
  .cfg-tabs-wrap { gap: 4px; }
  .cfg-tab { padding: 5px 11px; font-size: 12px; }

  /* Chat: layout vertical */
  .chat-layout { flex-direction: column; height: auto; }
  .chat-sidebar { width: 100%; height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-main { height: 60vh; }

  /* Pedidos: layout vertical */
  .ped-layout { flex-direction: column; }
  .ped-list-col { width: 100%; }

  /* Cotizaciones: tabla con scroll */
  .items-table { min-width: 560px; }
  .items-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Dashboard grid: 2 columnas */
  .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Stats cards genéricos */
  .stat-cards-row { flex-direction: column; }

  /* Kanban: scroll horizontal (ya existe, reforzar) */
  .kanban { padding-bottom: 12px; }
  .kanban-col { min-width: 220px; }

  /* Filtros: wrap completo */
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar .form-select,
  .filters-bar .form-control,
  .filters-bar .input-group { width: 100%; }

  /* Acciones en page-header: wrap */
  .page-actions { flex-wrap: wrap; gap: 6px; }
  .page-actions .btn { flex: 1 1 auto; min-width: 120px; }

  /* Tabs de clientes/proveedores */
  .cl-tabs { gap: 4px; }
  .cl-tab-btn { padding: 5px 10px; font-size: 12px; }

  /* Ocultar columnas secundarias en tablas */
  .col-hide-sm { display: none !important; }

  /* Cards de reportes: stack */
  .reportes-stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  /* Dashboard: 1 columna en pantallas muy chicas */
  .dashboard-grid { grid-template-columns: 1fr; }
  .reportes-stat-grid { grid-template-columns: 1fr; }
  .gastos-stat-cards { grid-template-columns: 1fr; }
  .bodega-stats { grid-template-columns: 1fr 1fr; }

  /* Chat sidebar más chico */
  .chat-sidebar { height: 160px; }

  /* Botones de acción: texto oculto, solo ícono */
  .btn-icon-label { display: none; }
}

/* ══════════════════════════════════════════════════════
   MOBILE — fixes específicos por módulo
══════════════════════════════════════════════════════ */

/* POS y cualquier sticky-top dentro del content: quitar sticky en mobile
   para que no tape el sidebar y el botón COBRAR sea alcanzable */
@media (max-width: 991px) {
  .content-area .sticky-top {
    position: relative !important;
    top: auto !important;
    z-index: 1 !important;
  }
}

@media (max-width: 768px) {
  /* Tablas sin wrapper table-responsive: scroll horizontal */
  .card-body.p-0 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Reportes y configuración: secciones scrollables */
  [id^="cfg-sec-"],
  [id^="rep-tab-"] {
    overflow-x: auto;
    max-width: 100%;
  }

  /* Col-md-6 en reportes: full width en mobile */
  .col-md-6 { min-width: 0; }

  /* Sección encabezado configuración: stack vertical */
  .cfg-enc-grid,
  .cfg-datos-grid { grid-template-columns: 1fr !important; }

  /* POS: cobro va arriba del carrito en mobile */
  .row.g-3 > [class*="col-lg-4"]:has(.card) { order: -1; }

  /* Calculadora: panel IVA debajo de la calc, con padding */
  .row.g-4.justify-content-center { padding-bottom: 16px; }

  /* stat-card: texto largo que no desborde */
  .stat-delta { white-space: normal; font-size: 11px; }
  .stat-value  { font-size: 22px; }
}

.destajo-stat-cards {
  margin-bottom: 15px;
}

/* ══════════════════════════════════════════════════════
   TABLET / SPLIT-SCREEN (~720-1199px)
   Cubre el caso de ventana a media pantalla en monitores
   1080p/1440p, donde la sidebar sigue presente pero el
   contenido tiene ~720-960px de ancho util.
═══════════════════════════════════════════════════════ */
@media (max-width: 1199px) {
  /* Stats grids: pasar de 4 columnas a 2 */
  .gastos-stat-cards { grid-template-columns: repeat(2, 1fr); }
  .bodega-stats     { grid-template-columns: repeat(2, 1fr); }

  /* Tallas: 4 cols en lugar de 6 */
  .tallas-grid { grid-template-columns: repeat(4, 1fr); }

  /* Dashboard grid: minmax mas chico para acomodar */
  .dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  /* Topbar search: ocupar menos espacio */
  .topbar-search { max-width: 220px; }

  /* Tablas dentro de cards: scroll horizontal en lugar de truncarse.
     :has() esta soportado en navegadores modernos (~97%); fallback
     en navegadores viejos: tabla puede recortarse, igual que antes. */
  .card-body:has(.table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .card-body:has(.table) > .table { min-width: 640px; }

  /* Page header: si las acciones no entran, que envuelvan en otra fila */
  .page-header .page-actions { flex-wrap: wrap; }
}

/* ════════════════════════════════════════════════════════
   DASHBOARD CHART (#dash-chart-body)
   ════════════════════════════════════════════════════════ */
.dash-chart .chart-bar rect {
  transition: filter .2s ease;
  cursor: pointer;
}
.dash-chart .chart-bar:hover rect { filter: brightness(1.12); }
.dash-chart .chart-point {
  transition: r .15s ease;
  cursor: pointer;
}
.dash-chart .chart-point:hover { r: 5; }
body.dark-mode .dash-chart .chart-point { stroke: #1e293b; }

/* Animación de primera carga */
.dash-chart.chart-animate .chart-bar {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: dashBarRise 700ms cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  animation-delay: calc(var(--i) * 60ms);
}
.dash-chart.chart-animate .chart-area {
  opacity: 0;
  animation: dashFadeIn 600ms ease-out 1100ms forwards;
}
.dash-chart.chart-animate .chart-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: dashLineDraw 1100ms ease-out 600ms forwards;
}
.dash-chart.chart-animate .chart-point {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: dashPointPop 380ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: calc(1500ms + var(--i) * 55ms);
}

@keyframes dashBarRise {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
@keyframes dashLineDraw {
  to { stroke-dashoffset: 0; }
}
@keyframes dashPointPop {
  0%   { opacity: 0; transform: scale(0); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes dashFadeIn {
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .dash-chart.chart-animate .chart-bar,
  .dash-chart.chart-animate .chart-area,
  .dash-chart.chart-animate .chart-line,
  .dash-chart.chart-animate .chart-point {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
  }
}
