/* =========================================================
   Sistema Inventario · Tema moderno (Bootstrap 5 + Dark Mode)
   ========================================================= */

:root {
  /* === Paleta Indigo Corporativo + Cyan Domado ===
     Brand: Indigo-600 #4F46E5 (entre azul corporativo y púrpura Orvelyx)
     Accent: Cyan-700 #0891B2 (cyan profesional, no neón)
     Texto: Slate-900 #0F172A
     Fondo: Slate-50 #F8FAFC + White
  */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4F46E5;   /* PRIMARIO oficial */
  --brand-700: #4338CA;   /* hover/pressed */
  --brand-800: #3730a3;
  --brand-900: #312e81;

  --accent-50:  #ecfeff;
  --accent-100: #cffafe;
  --accent-200: #a5f3fc;
  --accent-300: #67e8f9;
  --accent-400: #22d3ee;
  --accent-500: #06b6d4;
  --accent-600: #0891B2;  /* ACENTO oficial domado */
  --accent-700: #0e7490;
  --accent-800: #155e75;
  --accent-900: #164e63;

  --ink:       #0F172A;   /* Slate-900 */
  --paper:     #FFFFFF;
  --hairline:  #E2E8F0;   /* Slate-200 — más profesional que #E5E7EB */

  --success: #059669;     /* Emerald-600 — sobrio */
  --success-soft: #d1fae5;
  --warning: #D97706;     /* Amber-600 — cálido y serio */
  --warning-soft: #fef3c7;
  --danger:  #DC2626;     /* Red-600 */
  --danger-soft: #fee2e2;
  --info:    var(--accent-600);
  --info-soft: var(--accent-50);

  /* Sombras más sutiles y premium */
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.05), 0 1px 2px rgba(15,23,42,0.03);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,0.08), 0 4px 12px rgba(15,23,42,0.05);

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius:   14px;
  --radius-sm: 10px;
}

/* ---------- Tema CLARO (default) ---------- */
[data-bs-theme="light"], :root {
  --bg:        #F8FAFC;                  /* Slate-50 - off-white premium */
  --surface:   var(--paper);             /* #FFFFFF */
  --surface-2: #F1F5F9;                  /* Slate-100 */
  --surface-3: var(--hairline);          /* Slate-200 */
  --border:    var(--hairline);          /* Slate-200 */
  --border-strong: #cbd5e1;              /* Slate-300 */
  --text:      var(--ink);               /* Slate-900 #0F172A */
  --text-muted:#475569;                  /* Slate-600 */
  --text-soft: #94a3b8;                  /* Slate-400 */
  --sidebar-bg:  var(--paper);
  --sidebar-text:#475569;
  --sidebar-active-bg: var(--brand-50);
  --sidebar-active-text: var(--brand-700);
  --topbar-bg: rgba(255,255,255,0.88);
  --link: var(--brand-600);
}

/* ---------- Tema OSCURO ---------- */
[data-bs-theme="dark"] {
  --bg:        #0a1322;
  --surface:   var(--ink);               /* #0F172A */
  --surface-2: #1a2438;
  --surface-3: #243049;
  --border:    #1e293b;
  --border-strong: #334155;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --text-soft: #64748b;
  --sidebar-bg:  var(--ink);
  --sidebar-text:#cbd5e1;
  --sidebar-active-bg: rgba(37,99,235,0.18);
  --sidebar-active-text: var(--brand-200);
  --topbar-bg: rgba(15,23,42,0.85);
  --link: var(--brand-400);
}

/* ---------- Base ---------- */
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--brand-700); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-soft); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 1040;
  transition: transform .25s ease, width .25s ease;
}
.app-sidebar .brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.app-sidebar .brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--accent-500) 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}
.app-sidebar .brand .brand-name {
  font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em;
}
.app-sidebar .brand .brand-sub { font-size: 11px; color: var(--text-muted); }

.app-sidebar .nav-list {
  flex: 1 1 auto;
  padding: 14px 12px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
}
.app-sidebar .nav-section {
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin: 14px 12px 6px;
  font-weight: 600;
}
.app-sidebar .nav-link-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 13.5px;
  margin: 2px 0;
  position: relative;
  transition: background .15s, color .15s;
  cursor: pointer;
}
.app-sidebar .nav-link-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.app-sidebar .nav-link-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
  position: relative;
}
.app-sidebar .nav-link-item.active::after {
  content: "";
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--brand-600) 0%, var(--accent-500) 100%);
}
.app-sidebar .nav-link-item i,
.app-sidebar .nav-link-item .bi {
  font-size: 16px; width: 20px; text-align: center;
}
.app-sidebar .nav-link-item .chev {
  margin-left: auto; transition: transform .2s;
}
.app-sidebar .nav-group.open > .nav-link-item .chev { transform: rotate(90deg); }
.app-sidebar .nav-sub {
  list-style: none; padding: 2px 0 4px 38px; margin: 0;
  max-height: 0; overflow: hidden;
  transition: max-height .25s ease;
}
.app-sidebar .nav-group.open > .nav-sub { max-height: 400px; }
.app-sidebar .nav-sub .nav-link-item {
  font-size: 13px; padding: 7px 10px;
}
.app-sidebar .nav-sub .nav-link-item::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-soft); display: inline-block;
  margin-right: 4px;
}
.app-sidebar .nav-sub .nav-link-item.active::before { background: var(--brand-500); }

.app-sidebar .sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-muted);
}

/* Collapsed (icon-only) sidebar */
body.sidebar-collapsed .app-sidebar { width: 72px; }
body.sidebar-collapsed .app-sidebar .brand-name,
body.sidebar-collapsed .app-sidebar .brand-sub,
body.sidebar-collapsed .app-sidebar .nav-link-item span,
body.sidebar-collapsed .app-sidebar .nav-section,
body.sidebar-collapsed .app-sidebar .chev,
body.sidebar-collapsed .app-sidebar .sidebar-footer { display: none !important; }
body.sidebar-collapsed .app-sidebar .nav-link-item { justify-content: center; }
body.sidebar-collapsed .app-main { margin-left: 72px; }

/* Topbar */
.app-main {
  flex: 1 1 auto;
  margin-left: var(--sidebar-w);
  min-width: 0;
  transition: margin-left .25s ease;
}
.app-topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  z-index: 1030;
}
.app-topbar .sidebar-toggle-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.app-topbar .sidebar-toggle-btn:hover { background: var(--surface-2); }
.app-topbar .page-title { font-size: 15px; font-weight: 600; color: var(--text); }
.app-topbar .topbar-spacer { flex: 1 1 auto; }
.app-topbar .icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.app-topbar .icon-btn:hover { background: var(--surface-2); color: var(--text); }

.user-chip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: background .15s;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip img, .user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: var(--surface-3);
}
.user-chip .name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-chip .role { font-size: 11px; color: var(--text-muted); }

.app-content {
  padding: 24px;
  max-width: 100%;
}
.app-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-muted);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

/* Page header */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-header h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text); margin: 0 0 4px;
}
.page-header .subtitle { color: var(--text-muted); font-size: 13px; }
.page-header .breadcrumbs {
  font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 8px;
}
.page-header .breadcrumbs a { color: var(--text-muted); }
.page-header .breadcrumbs a:hover { color: var(--brand-600); }
.page-header .breadcrumbs .sep { opacity: .5; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-header h3, .card-header .card-title {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.card-body { padding: 20px; }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: 14px 20px; }

/* Stat boxes (KPIs) - rediseñados con la paleta Casa Centro */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-600) 0%, var(--accent-500) 100%);
}
.stat-card.tone-success::before { background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%); }
.stat-card.tone-warning::before { background: linear-gradient(90deg, #f59e0b 0%, #fcd34d 100%); }
.stat-card.tone-danger::before  { background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%); }
.stat-card.tone-info::before    { background: linear-gradient(90deg, var(--accent-500) 0%, var(--accent-300) 100%); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .ic {
  width: 48px; height: 48px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.stat-card.tone-primary .ic {
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--accent-500) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.stat-card.tone-success .ic { background: var(--success-soft); color: var(--success); }
.stat-card.tone-warning .ic { background: var(--warning-soft); color: #b45309; }
.stat-card.tone-danger  .ic { background: var(--danger-soft);  color: var(--danger); }
.stat-card.tone-info    .ic {
  background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-300) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}
[data-bs-theme="dark"] .stat-card.tone-success .ic { background: rgba(16,185,129,0.15); color: #6ee7b7; box-shadow: none; }
[data-bs-theme="dark"] .stat-card.tone-warning .ic { background: rgba(245,158,11,0.15); color: #fcd34d; box-shadow: none; }
[data-bs-theme="dark"] .stat-card.tone-danger  .ic { background: rgba(239,68,68,0.15);  color: #fca5a5; box-shadow: none; }
.stat-card .label { color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.stat-card .value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .trend { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.stat-card .more {
  margin-left: auto; align-self: center;
  color: var(--text-muted); font-size: 12px;
}
.stat-card .more:hover { color: var(--brand-600); }

/* Forms */
.form-control, .form-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-control:focus, .form-select:focus {
  background: var(--surface);
  color: var(--text);
  border-color: var(--brand-400);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}
.form-control::placeholder { color: var(--text-soft); }
.form-control[readonly], .form-control:disabled, .form-select:disabled {
  background: var(--surface-2); color: var(--text-muted);
}
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.input-group { gap: 0; }
.input-group .input-group-text, .input-group .input-group-addon {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  display: inline-flex; align-items: center;
}
.input-group > .form-control,
.input-group > .form-select,
.input-group > .input-group-text,
.input-group > .input-group-addon {
  border-radius: 0;
}
.input-group > :first-child { border-top-left-radius: var(--radius-sm) !important; border-bottom-left-radius: var(--radius-sm) !important; }
.input-group > :last-child  { border-top-right-radius: var(--radius-sm) !important; border-bottom-right-radius: var(--radius-sm) !important; }
.input-group > :not(:first-child) { border-left: 0; }
.input-lg { font-size: 14px; padding: 11px 14px; }

/* Buttons */
.btn { font-weight: 500; border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13px; transition: all .15s; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 8px; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--accent-600) 100%);
  border-color: var(--brand-600); color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,0.20);
  transition: all .18s ease;
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--accent-700) 100%);
  border-color: var(--brand-700); color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,0.28);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface-2); border-color: var(--border); color: var(--text);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.btn-default { /* legacy alias */
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.btn-default:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }
.btn-danger  { background: var(--danger);  border-color: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #dc2626; border-color: #dc2626; }
.btn-info    {
  background: var(--accent-600); border-color: var(--accent-600); color: #fff;
  box-shadow: 0 2px 8px rgba(8,145,178,0.18);
}
.btn-info:hover    {
  background: var(--accent-700); border-color: var(--accent-700); color: #fff;
  box-shadow: 0 4px 14px rgba(8,145,178,0.28);
}
.btn-flat { box-shadow: none !important; }
.btn-block { display: block; width: 100%; }
.btn-group .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.btn-group > .btn:last-child  { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

/* Tables */
.table {
  --bs-table-bg: transparent;
  color: var(--text); font-size: 13.5px;
  margin-bottom: 0;
}
.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table.table-striped tbody tr:nth-of-type(odd) td { background: var(--surface); }
.table.table-striped tbody tr:nth-of-type(even) td { background: var(--surface-2); }
.table-bordered, .table-bordered th, .table-bordered td { border-color: var(--border) !important; }
.table-hover tbody tr:hover td { background: var(--surface-2) !important; }
.table img.img-thumbnail { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; }
.dataTables_wrapper {
  padding: 4px 4px 12px;
  color: var(--text);
}
.dataTables_wrapper label,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_filter { color: var(--text-muted); font-size: 12.5px; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; margin-left: 6px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  background: var(--surface) !important; border: 1px solid var(--border) !important;
  color: var(--text) !important; border-radius: var(--radius-sm) !important;
  margin: 0 2px !important; padding: 5px 10px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--surface-2) !important; border-color: var(--border-strong) !important;
  color: var(--text) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--brand-600) !important; border-color: var(--brand-600) !important;
  color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  opacity: 0.5; background: var(--surface) !important; color: var(--text-muted) !important;
}

/* Badges */
.badge {
  font-weight: 500;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  letter-spacing: 0.01em;
}
.badge.bg-success, .label.label-success { background: var(--success-soft) !important; color: #047857 !important; }
.badge.bg-warning, .label.label-warning { background: var(--warning-soft) !important; color: #b45309 !important; }
.badge.bg-danger, .label.label-danger { background: var(--danger-soft) !important; color: #b91c1c !important; }
.badge.bg-info, .label.label-info { background: var(--info-soft) !important; color: #0369a1 !important; }
[data-bs-theme="dark"] .badge.bg-success, [data-bs-theme="dark"] .label.label-success { background: rgba(16,185,129,0.18) !important; color: #6ee7b7 !important; }
[data-bs-theme="dark"] .badge.bg-warning, [data-bs-theme="dark"] .label.label-warning { background: rgba(245,158,11,0.18) !important; color: #fcd34d !important; }
[data-bs-theme="dark"] .badge.bg-danger,  [data-bs-theme="dark"] .label.label-danger  { background: rgba(239,68,68,0.18) !important; color: #fca5a5 !important; }
[data-bs-theme="dark"] .badge.bg-info,    [data-bs-theme="dark"] .label.label-info    { background: rgba(14,165,233,0.18) !important; color: #7dd3fc !important; }

/* Modals */
.modal-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}
.modal-header .modal-title { font-weight: 600; font-size: 15px; color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex; justify-content: flex-end; gap: 8px;
}
.btn-close { filter: invert(0); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }
.modal-backdrop { background: #0f172a; }
.modal-backdrop.show { opacity: .5; }

/* Login */
.login-page {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% 0%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(14,165,233,0.18), transparent 60%),
    var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-card .logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; margin-bottom: 20px;
  box-shadow: 0 8px 20px rgba(79,70,229,0.25);
}
.login-card h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; }
.login-card .lead { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; }

/* Misc legacy aliases used in views */
.pull-right { float: right !important; }
.pull-left  { float: left !important; }
.text-uppercase { text-transform: uppercase; }
.img-responsive { max-width: 100%; height: auto; }
.help-block { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.box        { /* legacy alias for card */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.box-header.with-border { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.box-header h3, .box-header .box-title { margin: 0; font-size: 15px; font-weight: 600; }
.box-body   { padding: 20px; }
.box-footer { padding: 14px 20px; border-top: 1px solid var(--border); }
.box-success { border-top: 3px solid var(--success); }
.box-warning { border-top: 3px solid var(--warning); }
.box-primary { border-top: 3px solid var(--brand-600); }

/* Content wrapper compatibility */
.content-wrapper { padding: 0; }
.content-wrapper > section.content-header { padding: 0 0 12px; }
.content-wrapper > section.content-header h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.content-wrapper > section.content { padding: 0; }
.breadcrumb {
  background: transparent; padding: 0; margin: 0;
  display: flex; align-items: center; gap: 8px;
  list-style: none; font-size: 12.5px; color: var(--text-muted);
}
.breadcrumb > li + li::before {
  content: "/"; padding: 0 6px; color: var(--text-soft);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-600); }
.breadcrumb .active { color: var(--text); }

/* Products list (dashboard widget) */
.products-list { list-style: none; padding: 0; margin: 0; }
.products-list .item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.products-list .item:last-child { border-bottom: 0; }
.products-list .product-img img {
  width: 48px; height: 48px; object-fit: cover; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.products-list .product-info { flex: 1; min-width: 0; }
.products-list .product-title {
  color: var(--text); font-weight: 500; font-size: 13.5px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.products-list .product-title .label { font-weight: 600; color: var(--brand-700); }

/* Daterange button */
#daterange-btn, #daterange-btn2, #daterange-btn3, #dateRangeBtn {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 14px !important; font-weight: 500; font-size: 13px;
}
#daterange-btn:hover, #daterange-btn2:hover, #daterange-btn3:hover, #dateRangeBtn:hover {
  background: var(--surface-2) !important; border-color: var(--border-strong) !important;
}

/* Select2 alignment with new look */
.select2-container--default .select2-selection--single {
  height: 38px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px !important; color: var(--text) !important; padding-left: 12px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px !important; }
.select2-dropdown {
  background: var(--surface) !important; border-color: var(--border) !important;
  color: var(--text) !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--brand-600) !important;
}
.select2-search--dropdown .select2-search__field {
  background: var(--surface) !important; color: var(--text) !important;
  border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important;
}

/* Login legacy compatibility */
.login-box, .login-box-body { background: transparent; box-shadow: none; border: 0; }

/* Error page (404) */
.error-page {
  display: flex; align-items: center; justify-content: center; gap: 40px;
  padding: 40px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); flex-wrap: wrap;
}
.error-page .headline {
  font-size: 100px; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.error-page .error-content h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.error-page .error-content p { color: var(--text-muted); font-size: 14px; }

/* Hidden helpers (BS3 → BS5) */
.hidden-xs { }
.hidden-sm { }
.hidden-md { }
.hidden-lg { }
@media (max-width: 575.98px) { .hidden-xs { display: none !important; } }
@media (min-width: 576px) and (max-width: 767.98px) { .hidden-sm { display: none !important; } }
@media (min-width: 768px) and (max-width: 991.98px) { .hidden-md { display: none !important; } }
@media (min-width: 992px) { .hidden-lg { display: none !important; } }

/* BS3 col-xs-* → emulate as col-* */
[class*="col-xs-"] { padding-right: var(--bs-gutter-x, 0.75rem); padding-left: var(--bs-gutter-x, 0.75rem); }
.col-xs-1 { flex: 0 0 8.3333%; max-width: 8.3333%; }
.col-xs-2 { flex: 0 0 16.6667%; max-width: 16.6667%; }
.col-xs-3 { flex: 0 0 25%; max-width: 25%; }
.col-xs-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
.col-xs-5 { flex: 0 0 41.6667%; max-width: 41.6667%; }
.col-xs-6 { flex: 0 0 50%; max-width: 50%; }
.col-xs-7 { flex: 0 0 58.3333%; max-width: 58.3333%; }
.col-xs-8 { flex: 0 0 66.6667%; max-width: 66.6667%; }
.col-xs-9 { flex: 0 0 75%; max-width: 75%; }
.col-xs-10 { flex: 0 0 83.3333%; max-width: 83.3333%; }
.col-xs-11 { flex: 0 0 91.6667%; max-width: 91.6667%; }
.col-xs-12 { flex: 0 0 100%; max-width: 100%; }

/* =========================================================
   RESPONSIVE — refuerzo para móvil, tablet y desktop
   ========================================================= */

/* Evita scroll horizontal accidental por contenido ancho */
html, body { overflow-x: hidden; }
.app-shell { width: 100%; max-width: 100vw; }
.app-content { min-width: 0; max-width: 100%; }

/* Sidebar responsive */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    z-index: 1039; opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

/* Topbar ajuste */
@media (max-width: 575.98px) {
  .app-topbar { padding: 0 12px; gap: 8px; }
  .app-topbar .user-chip { padding: 4px; }
  .app-topbar .user-chip img, .app-topbar .user-chip .avatar { width: 28px; height: 28px; }
}

/* Padding del contenido */
@media (max-width: 767.98px) {
  .app-content { padding: 16px 12px; }
  .app-footer  { padding: 14px 12px; font-size: 11.5px; }
}

/* Page header en móvil: stack vertical */
@media (max-width: 575.98px) {
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-header h1 { font-size: 20px; }
  .page-header .breadcrumb { font-size: 11.5px; }
}

/* Card header: que los botones se acomoden en varias líneas */
.card-header { row-gap: 8px; }
@media (max-width: 575.98px) {
  .card-header { padding: 12px 14px; }
  .card-header h3, .card-header .card-title { font-size: 14px; }
  .card-body  { padding: 14px; }
}

/* Stat-card más compacta en móvil */
@media (max-width: 575.98px) {
  .stat-card { padding: 14px; gap: 10px; }
  .stat-card .ic { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
  .stat-card .value { font-size: 18px; }
  .stat-card .label { font-size: 11.5px; }
}

/* Tablas: scroll horizontal forzado en pantallas pequeñas */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table { min-width: 480px; }
@media (max-width: 575.98px) {
  .table thead th { font-size: 10.5px; padding: 8px 10px; }
  .table tbody td { padding: 9px 10px; font-size: 12.5px; }
}

/* DataTables botones de export y filtros en móvil: que no se desborden */
.dataTables_wrapper .dt-buttons { flex-wrap: wrap; gap: 6px; }
.dataTables_wrapper .dataTables_filter input { max-width: 100%; }
/* La paginación debe caber en SU CONTENEDOR, no en la ventana.
   En pantallas partidas (crear venta, confirmar factura) el panel mide unos
   440px aunque el navegador sea de 1280: las media queries por ancho de
   ventana no se activan y la barra se desbordaba, recortando «Anterior» y
   «Siguiente». Envolviendo, se adapta a cualquier ancho de contenedor. */
.dataTables_wrapper .dataTables_paginate .pagination {
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  margin: 0 !important;
}

@media (max-width: 575.98px) {
  .dataTables_wrapper .dataTables_paginate .paginate_button { padding: 4px 8px !important; font-size: 11px; }
  .dataTables_wrapper .dataTables_info { font-size: 11px; }
}

/* Modales: full-screen en móvil para mejor UX */
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-fullscreen) {
    margin: 0;
    max-width: 100%;
    min-height: 100%;
  }
  .modal-content { border-radius: 0; min-height: 100vh; }
  .modal-body  { padding: 14px; }
  .modal-header, .modal-footer { padding: 12px 14px; }
  .modal-header .modal-title { font-size: 14px; }
}

/* Modales medianos: convertir a modal-lg en tablet */
@media (max-width: 991.98px) {
  .modal-xl { max-width: 95%; }
}

/* Formularios: en móvil los grupos input-group con muchos addons se ajustan */
@media (max-width: 575.98px) {
  .form-control, .form-select { font-size: 14px; padding: 8px 10px; }
  .input-group .input-group-text { padding: 6px 10px; }
  .form-label { font-size: 12px; }
}

/* Botones más compactos en móvil */
@media (max-width: 575.98px) {
  .btn       { padding: 7px 12px; font-size: 12.5px; }
  .btn-icon  { padding: 5px 8px; }
  .btn-group .btn { padding: 5px 9px; }
  .btn-sm    { padding: 4px 8px; font-size: 11px; }
}

/* Login: ajustar padding en móvil */
@media (max-width: 575.98px) {
  .login-page { padding: 12px; }
  .login-card { padding: 22px 18px; border-radius: 14px; }
  .login-card h1 { font-size: 19px; }
}

/* Hero / KPIs / sections del dashboard */
@media (max-width: 575.98px) {
  .row.g-3 > [class*="col-"] { padding-left: 0.5rem; padding-right: 0.5rem; }
}

/* Crear/Editar venta: el split 5/7 se vuelve una columna en tablet */
@media (max-width: 991.98px) {
  .col-lg-5, .col-lg-7 { flex: 0 0 100%; max-width: 100%; }
}

/* Filas de tiras / productos en abono: scrollable en móvil si no caben */
@media (max-width: 575.98px) {
  .eliminarTira, .eliminar-producto-abono { flex-wrap: wrap; }
  .eliminarTira > input[type="number"],
  .eliminar-producto-abono input[type="number"] {
    flex: 1 1 100% !important;
  }
}

/* Tabs (en abonos) con scroll horizontal cuando hay muchos */
.nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nav-tabs .nav-link { white-space: nowrap; }

/* Tooltip/hint: que no se desborden */
.tooltip-inner { max-width: 90vw; }

/* WhatsApp flotante: ya se ve bien pero pequeño en móvil pequeño */
@media (max-width: 575.98px) {
  .wa-float { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 24px; }
}

/* Imagenes de producto en tablas: shrink */
@media (max-width: 575.98px) {
  table img { max-width: 32px !important; }
}

/* Page header con KPIs verticales en móvil */
@media (max-width: 575.98px) {
  .row.mb-3.g-3 .stat-card .value { font-size: 16px; }
}

/* Asegurar que el dropdown del usuario en topbar quepa en móvil */
.app-topbar .dropdown-menu { right: 0; left: auto !important; min-width: 200px; }

/* Charts: contenedor con altura fija sin desbordar */
canvas { max-width: 100% !important; }

/* Inicio (dashboard) gráfico altura adaptativa */
@media (max-width: 575.98px) {
  .card-body[style*="height"] { height: 240px !important; }
}

/* Caja Hoy section banners (cartera) */
.section-banner {
  padding: 14px 18px; color: #fff; border-radius: var(--radius);
  font-weight: 600; letter-spacing: -0.01em; font-size: 14px;
  margin: 18px 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.section-banner.tone-danger  { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.section-banner.tone-warning { background: linear-gradient(135deg, #f59e0b, #b45309); }
.section-banner.tone-success { background: linear-gradient(135deg, #10b981, #047857); }

/* Mini buttons */
.btn-icon { padding: 6px 9px; border-radius: 9px; }
.btn-icon i { font-size: 14px; }

/* Print-friendly resumen */
@media print {
  .app-sidebar, .app-topbar, .app-footer, .no-print { display: none !important; }
  .app-main { margin-left: 0 !important; }
}

/* Login feedback icons (legacy) */
.has-feedback .form-control-feedback { display: none; }

/* Panel legacy alias */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.panel-body { padding: 0; }
.panel a img { display: block; max-width: 100%; height: auto; border-radius: 10px; }

/* Acerca page tweaks */
.about-tech {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .15s, box-shadow .15s;
}
.about-tech:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.about-tech img { height: 56px; width: auto; object-fit: contain; }
.about-tech h5 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }

/* Kardex producto */
.item-img { width: 220px; height: 220px; object-fit: contain; }
.item-title { font-size: 20px; font-weight: 700; color: var(--text); }
.item-number {
  display: inline-block; background: var(--surface-2); color: var(--text-muted);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; margin-top: 6px;
}
.current-stock { font-size: 12px; color: var(--text-muted); }
.item-quantity { font-size: 28px; font-weight: 700; color: var(--text); }
.item-price    { font-size: 22px; font-weight: 700; color: var(--success); }

/* SweetAlert tweaks */
.swal2-popup { border-radius: var(--radius) !important; font-family: inherit !important; }

/* Dropdowns */
.dropdown-menu {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: 6px;
}
.dropdown-item {
  border-radius: 8px; font-size: 13px; padding: 7px 10px; color: var(--text);
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--surface-2); color: var(--text);
}
.dropdown-divider { border-color: var(--border); }

/* ===========================================================================
   Tutoriales guiados
   El oscurecido lo produce la sombra enorme del propio foco, así no hay que
   sincronizar dos capas. Todo va por encima de los modales de Bootstrap
   (z-index 1055), porque hay guías que explican cosas dentro de un modal.
   =========================================================================== */
.tut-capa {
  position: fixed; inset: 0; z-index: 20000; background: transparent;
}
.tut-foco {
  position: fixed; z-index: 20001; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .62), 0 0 0 3px var(--brand-500);
  transition: top .22s ease, left .22s ease, width .22s ease, height .22s ease;
}
.tut-foco--vacio { box-shadow: 0 0 0 9999px rgba(15, 23, 42, .62); }

.tut-globo {
  position: fixed; z-index: 20002;
  width: min(380px, calc(100vw - 24px));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .35);
  padding: 14px 16px 12px;
}
.tut-globo-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tut-globo-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand-600);
}
.tut-cerrar {
  border: 0; background: transparent; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; line-height: 1;
}
.tut-cerrar:hover { background: var(--surface-2); color: var(--text); }

.tut-titulo { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.tut-texto  { font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }
.tut-texto b { color: var(--text); }

.tut-pie { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.tut-progreso { display: flex; flex-direction: column; gap: 4px; min-width: 78px; }
.tut-cuenta { font-size: 11px; color: var(--text-muted); }
.tut-barra { display: block; height: 3px; width: 70px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.tut-barra i { display: block; height: 100%; background: var(--brand-600); transition: width .25s ease; }
.tut-botones { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.tut-btn {
  border-radius: 9px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; line-height: 1.2;
  text-decoration: none; display: inline-flex; align-items: center;
}
.tut-btn-sm { padding: 5px 11px; font-size: 12.5px; }
.tut-btn-lleno { background: var(--brand-600); color: #fff; }
.tut-btn-lleno:hover { background: var(--brand-700); color: #fff; }
.tut-btn-plano { background: transparent; color: var(--text-muted); border-color: var(--border); }
.tut-btn-plano:hover { background: var(--surface-2); color: var(--text); }

/* --- Centro de tutoriales (botón "?" de la barra superior) --- */
.tut-centro { position: fixed; inset: 0; z-index: 20050; display: flex; align-items: center; justify-content: center; }
.tut-centro-fondo { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.tut-centro-panel {
  position: relative; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  overflow-y: auto; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, .4);
}
.tut-centro-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tut-centro-cab h3 { margin: 0; font-size: 18px; font-weight: 700; }

.tut-switch {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
}
.tut-switch input { margin-top: 2px; flex: 0 0 auto; width: 16px; height: 16px; }
.tut-switch span { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.tut-switch small { color: var(--text-muted); font-size: 12px; line-height: 1.45; }

.tut-grupo { margin-bottom: 14px; }
.tut-grupo-tit {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}
.tut-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tut-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px;
}
.tut-item-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tut-item-tit { font-size: 13.5px; font-weight: 600; }
.tut-item-des { font-size: 12px; color: var(--text-muted); }
.tut-ok { color: #16a34a; font-size: 12px; }
.tut-centro-pie { display: flex; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 12px; }

@media (max-width: 575.98px) {
  .tut-globo { width: calc(100vw - 20px); }
  .tut-item { flex-direction: column; align-items: stretch; }
  .tut-item .tut-btn { justify-content: center; }
}
