/* ── Variables ───────────────────────────────────────── */
/* Paleta base: modo oscuro (default). El modo claro y los temas de color
   se aplican con atributos en <html> (data-modo, data-tema) — ver theme.js. */
:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #22263a;
  --border:    #2e3250;
  --accent:    #4f8ef7;
  --accent-h:  #3a7ce0;
  /* Tono aparte para fondo de botón primario con texto blanco: --accent solo
     da 3.2:1 de contraste ahí (falla WCAG AA, que pide 4.5:1) — se usa tal
     cual para texto/enlaces sobre fondo oscuro, donde sí contrasta bien. */
  --accent-btn:   #1d6fe0;
  --accent-btn-h: #1857b3;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #eab308;
  --orange:    #f97316;
  --purple:    #a855f7;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  /* 224px (antes 200px): con encabezados de sección y etiquetas largas como
     "Actividad por sucursal" dejaba de sobrar aire; el modo compacto no usa
     esta variable (queda fijo en 64px, ver bloque @media min-width:1025px). */
  --sidebar-w: 224px;
}

/* ── Modo claro ──────────────────────────────────────── */
:root[data-modo="claro"] {
  --bg:     #f4f6fb;
  --bg2:    #ffffff;
  --bg3:    #eef1f8;
  --border: #dbe2f0;
  --text:   #1e293b;
  --muted:  #64748b;
  --fondo-overlay: rgba(244,246,251,.88);
}
:root { --fondo-overlay: rgba(15,17,23,.88); }

/* ── Temas de color (independientes del modo claro/oscuro) ──
   "azul" es el default ya definido arriba, no necesita override. */
:root[data-tema="verde"]   { --accent: #22c55e; --accent-h: #16a34a; --accent-btn: #15803d; --accent-btn-h: #116830; }
:root[data-tema="purpura"] { --accent: #a855f7; --accent-h: #9333ea; --accent-btn: #9333ea; --accent-btn-h: #7e22ce; }
:root[data-tema="naranja"] { --accent: #f97316; --accent-h: #ea580c; --accent-btn: #c2410c; --accent-btn-h: #9a3412; }

/* ── Ajustes de contraste en modo claro para elementos que en oscuro
   usan colores oscuros translúcidos como fondo (chips, toasts, botones
   de estado): en un lienzo blanco esos mismos tonos oscuros se ven sucios,
   así que se invierten a fondo claro + texto oscuro saturado. */
:root[data-modo="claro"] {
  --chip-green-bg: #dcfce7;  --chip-green-fg: #15803d;  --chip-green-bd: #86efac;
  --chip-red-bg:   #fee2e2;  --chip-red-fg:   #b91c1c;  --chip-red-bd:   #fca5a5;
  --chip-yellow-bg:#fef9c3;  --chip-yellow-fg:#a16207;  --chip-yellow-bd:#fde047;
  --chip-blue-bg:  #dbeafe;  --chip-blue-fg:  #1d4ed8;  --chip-blue-bd:  #93c5fd;
  --chip-purple-bg:#f3e8ff;  --chip-purple-fg:#7e22ce;  --chip-purple-bd:#d8b4fe;
  --chip-orange-bg:#ffedd5;  --chip-orange-fg:#c2410c;  --chip-orange-bd:#fdba74;
  --hover-tint: #00000008;
  --banner-warn-bg:   #fef3c7;  --banner-warn-fg:   #92400e;
  --banner-danger-bg: #fee2e2;  --banner-danger-fg: #991b1b;
}
:root {
  --chip-green-bg: #14532d44;  --chip-green-fg: #4ade80;  --chip-green-bd: #4ade8033;
  --chip-red-bg:   #7f1d1d44;  --chip-red-fg:   #f87171;  --chip-red-bd:   #f8717133;
  --chip-yellow-bg:#78350f44;  --chip-yellow-fg:#fbbf24;  --chip-yellow-bd:#fbbf2433;
  --chip-blue-bg:  #1e3a8a44;  --chip-blue-fg:  #60a5fa;  --chip-blue-bd:  #60a5fa33;
  --chip-purple-bg:#4c1d9544;  --chip-purple-fg:#c4b5fd;  --chip-purple-bd:#c4b5fd33;
  --hover-tint: #ffffff05;
  --banner-warn-bg:   #78350f88;  --banner-warn-fg:   #fde68a;
  --banner-danger-bg: #7f1d1d88;  --banner-danger-fg: #fecaca;
  --chip-orange-bg:#7c2d1244;  --chip-orange-fg:#fb923c;  --chip-orange-bd:#fb923c33;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 13px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.mb-2 { margin-bottom: 8px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.font-bold { font-weight: 700; }

/* ── Íconos (SVG en línea, ver js/icons.js) ─────────────
   1em × 1em: hereda el font-size del contenedor (botón, ítem de nav, etc.),
   así que no hace falta una regla de tamaño distinta por cada lugar donde
   se usa — el mismo comportamiento que tenían los emoji que reemplazan. */
.icon { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.15em; }
.icon-sm { width: .85em; height: .85em; }
.icon-lg { width: 1.3em; height: 1.3em; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Toast ───────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; min-width: 240px; max-width: 360px; box-shadow: 0 4px 16px #0006; animation: slideIn .25s ease; pointer-events: auto; display: flex; align-items: center; gap: 10px; }
.toast.hide { animation: slideOut .25s ease forwards; }
.toast-success { background: #14532d; border: 1px solid var(--green); color: #bbf7d0; }
.toast-error   { background: #7f1d1d; border: 1px solid var(--red);   color: #fecaca; }
.toast-info    { background: #1e3a8a; border: 1px solid var(--accent); color: #bfdbfe; }
.toast-warn    { background: #78350f; border: 1px solid var(--yellow); color: #fde68a; }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOut { to { opacity: 0; transform: translateX(30px); } }

/* ── Modal ───────────────────────────────────────────── */
#modal-overlay { position: fixed; inset: 0; background: #000a; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
#modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
#modal-box.modal-wide { max-width: 820px; }
#modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
#modal-title { font-size: 16px; font-weight: 700; }
#modal-close { background: none; border: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 4px; transition: .15s; }
#modal-close:hover { background: var(--bg3); color: var(--text); }
#modal-body { padding: 14px; }

/* ── Confirm ─────────────────────────────────────────── */
#confirm-overlay { position: fixed; inset: 0; background: #000a; z-index: 1100; display: flex; align-items: center; justify-content: center; }
#confirm-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 28px 24px; max-width: 360px; width: 100%; }
#confirm-msg { margin-bottom: 20px; font-size: 14px; line-height: 1.6; }
.confirm-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Login ───────────────────────────────────────────── */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.login-layout { width: min(1120px, 100%); min-height: 660px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); overflow: hidden; background: var(--bg2); border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 28px 80px #0008; }
.login-layout-wide { grid-template-columns: minmax(0, .9fr) minmax(520px, 1.1fr); }
.login-layout-wide .login-form-panel { padding: 36px; }
.login-visual { position: relative; min-height: 660px; overflow: hidden; isolation: isolate; background: #101725; }
.login-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 48% center; transition: transform .7s ease; }
.login-layout:hover .login-visual img { transform: scale(1.015); }
.login-form-panel { display: flex; align-items: center; justify-content: center; padding: 48px; }
.login-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 40px 36px; width: 100%; max-width: 380px; }
.login-form-panel .login-card { border: 0; border-radius: 0; padding: 0; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .login-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto; border-radius: 18px; background: linear-gradient(145deg, var(--accent), var(--accent-btn)); color: #fff; font-size: 30px; box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 30%, transparent); }
.login-logo h1 { font-size: 25px; font-weight: 750; margin-top: 16px; letter-spacing: -.025em; }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 5px; }
.login-error { background: var(--chip-red-bg); border: 1px solid var(--red); color: var(--chip-red-fg); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.login-ok { background: var(--chip-green-bg); border: 1px solid var(--green); color: var(--chip-green-fg); padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.login-card-wide { max-width: 460px; }
.login-forgot { text-align: right; margin-top: -8px; }
.login-forgot a { font-size: 12px; }
.login-switch { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

@media (max-width: 860px) {
  #login-screen { padding: 0; }
  .login-layout { min-height: 100vh; grid-template-columns: minmax(0, 1fr) minmax(380px, .95fr); border: 0; border-radius: 0; }
  .login-visual { min-height: 100vh; }
  .login-form-panel { padding: 36px 28px; }
}

@media (max-width: 680px) {
  #login-screen { align-items: stretch; }
  .login-layout { display: block; background: var(--bg); }
  .login-visual { min-height: 220px; height: 30vh; max-height: 280px; }
  .login-visual img { object-position: center 53%; }
  .login-form-panel { min-height: 70vh; align-items: flex-start; padding: 34px 24px 40px; }
  .login-logo { margin-bottom: 24px; }
  .login-logo .login-icon { width: 50px; height: 50px; border-radius: 15px; font-size: 26px; }
  .login-logo h1 { margin-top: 12px; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .login-visual img { transition: none; }
}

/* ── App Shell ───────────────────────────────────────── */
#app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────── */
/* overflow NO va acá: #sidebar-footer vive dentro de este contenedor y sus
   menús desplegables (notificaciones/cuenta) necesitan poder salirse del
   recuadro del sidebar sin recortarse — el scroll interno del menú de
   navegación vive en #sidebar-nav en su lugar (mismo patrón que Market). */
#sidebar { width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo-text { flex: 1; min-width: 0; }
.logo-icon { font-size: 22px; }
.logo-title { font-weight: 700; font-size: 14px; }
.logo-sub { font-size: 11px; color: var(--accent); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
#sidebar-compact-toggle { background: none; border: none; color: var(--muted); font-size: 15px; padding: 4px 6px; border-radius: 6px; flex-shrink: 0; }
#sidebar-compact-toggle:hover { background: var(--bg3); color: var(--text); }
#sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 0; }

/* ── Pie del sidebar: tema, notificaciones y cuenta (estilo Discord/Slack,
   igual que 1000tonMarket) — antes vivían en el topbar. */
#sidebar-footer { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 8px; flex-shrink: 0; border-top: 1px solid var(--border); }
#sidebar-footer #notif-wrap { width: 100%; }
#sidebar-footer #notif-btn, #sidebar-footer #theme-toggle-btn {
  width: 100%; min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px; font-size: 17px;
}
#sidebar-footer #notif-btn:hover, #sidebar-footer #theme-toggle-btn:hover { background: var(--bg3); }
#sidebar-footer .sidebar-footer-label { font-size: 13px; font-weight: 600; color: var(--text); }
#sidebar-footer .notif-badge { position: static; margin-left: auto; transform: none; }
#sidebar-footer .user-avatar { width: 30px; height: 30px; font-size: 12px; }
/* .nav-item es un <button>, no un <div>: se resetea el estilo nativo (fondo,
   borde, tipografía, alineación) para que se vea igual que antes, y se fuerza
   width:100% porque un botón no ocupa todo el ancho del contenedor por
   default como sí lo hacía el <div>. */
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 14px;
  background: none; border: none; border-left: 3px solid transparent; margin: 0;
  color: var(--muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
  transition: .15s; user-select: none; position: relative;
}
.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active { color: var(--text); background: var(--bg3); border-left-color: var(--accent); font-weight: 600; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 1; }
.nav-item .nav-icon { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }

/* Encabezados de sección: solo texto, no son navegables. Tono apagado
   (var(--muted)) para no competir visualmente con los ítems. */
.nav-section-label {
  padding: 14px 14px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); opacity: .8; user-select: none;
}
.nav-section-label:first-child { padding-top: 8px; }

/* Tooltip del ítem en modo compacto: oculto por default, ver el bloque
   @media (min-width:1025px) más abajo donde se activa solo con
   #app-shell.sidebar-compact — en expandido y en móvil nunca se muestra. */
.nav-tooltip-global {
  position: fixed; transform: translateY(-50%);
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 5px 9px; border-radius: 6px; font-size: 12px; font-weight: 600;
  white-space: nowrap; box-shadow: 0 4px 14px #0004;
  pointer-events: none; z-index: 9999;
}

/* ── Main wrap ───────────────────────────────────────── */
#main-wrap { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
#topbar { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 18px; height: 46px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 40; }
#page-title { font-size: 15px; font-weight: 700; }
#page-content { padding: 14px 18px; flex: 1; min-width: 0; }
#page-content.fondo-sucursal { background-size: cover; background-position: center; background-attachment: fixed; }
#sidebar-toggle { display: none; background: none; border: none; color: var(--text); font-size: 20px; padding: 4px 6px; border-radius: 6px; }
#sidebar-toggle:hover { background: var(--bg3); }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: #000a; z-index: 45; }
#sidebar-overlay.show { display: block; }

/* ── Selector rápido de modo claro/oscuro ─────────────── */
#theme-toggle-btn { background: none; border: none; color: var(--text); font-size: 18px; padding: 6px 8px; border-radius: 6px; line-height: 1; }
#theme-toggle-btn:hover { background: var(--bg3); }

/* ── Apariencia (modal) ────────────────────────────────── */
.tema-modo-switch { display: flex; gap: 8px; }
.tema-modo-btn { flex: 1; background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: 7px; font-size: 13px; font-weight: 600; transition: .15s; }
.tema-modo-btn:hover { border-color: var(--accent); }
.tema-modo-btn.active { border-color: var(--accent); background: var(--bg2); color: var(--accent); }
.tema-swatch-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tema-swatch { display: flex; align-items: center; gap: 8px; background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; transition: .15s; }
.tema-swatch:hover { border-color: var(--accent); }
.tema-swatch.active { border-color: var(--accent); background: var(--bg2); }
.tema-swatch-color { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 2px #ffffff33; }

/* ── Notificaciones ──────────────────────────────────── */
#notif-wrap { position: relative; }
#notif-btn { position: relative; background: none; border: none; color: var(--text); font-size: 18px; padding: 6px 8px; border-radius: 6px; line-height: 1; }
#notif-btn:hover { background: var(--bg3); }
.notif-badge { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px; transform: translate(35%, -35%); animation: notif-badge-pulse 1.6s ease-in-out infinite; }
@keyframes notif-badge-pulse { 0%, 100% { box-shadow: 0 0 0 0 #ff4d4f80; } 50% { box-shadow: 0 0 0 5px #ff4d4f00; } }
@keyframes notif-shake { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(18deg); } 30% { transform: rotate(-16deg); } 45% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 75% { transform: rotate(4deg); } }
.notif-shake { animation: notif-shake 0.6s ease-in-out; }
/* bottom (no top): el botón vive al pie del sidebar, el panel se abre hacia
   arriba para no salirse de la pantalla por abajo. */
.notif-panel { position: absolute; bottom: calc(100% + 8px); top: auto; left: 0; right: auto; width: 340px; max-height: 420px; overflow-y: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px #0008; z-index: 60; }
.notif-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; position: sticky; top: 0; background: var(--bg2); }
.notif-panel-body { padding: 4px 0; }
.notif-loading { display: flex; justify-content: center; padding: 24px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: .15s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg3); }
.notif-item.unread { background: #4f8ef712; border-left: 3px solid var(--accent); }
.notif-item-titulo { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.notif-item-msg { font-size: 12px; color: var(--muted); margin-bottom: 4px; white-space: pre-wrap; }
.notif-item-meta { font-size: 11px; color: var(--muted); }

/* ── Menú de usuario (pie del sidebar, estilo Discord/Slack) ─────────── */
#user-menu-wrap { position: relative; width: 100%; min-width: 0; }
#user-menu-btn { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; color: var(--text); padding: 5px 6px 5px 4px; border-radius: 8px; }
#user-menu-btn:hover { background: var(--bg3); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-btn); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-menu-name { font-size: 13px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { font-size: 10px; color: var(--muted); margin-left: auto; }
.user-menu-panel { position: absolute; bottom: calc(100% + 8px); top: auto; left: 0; right: auto; width: 240px; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px #0008; z-index: 60; overflow: hidden; }
.user-menu-header { padding: 14px; border-bottom: 1px solid var(--border); }
.user-menu-item { display: block; padding: 10px 14px; font-size: 13px; color: var(--text); transition: .15s; }
.user-menu-item:hover { background: var(--bg3); }
.user-menu-item-danger:hover { color: var(--red); }

@media (max-width: 480px) {
  .user-menu-name { display: none; }
}

/* ── Page header ─────────────────────────────────────── */
/* El <h2> repite el mismo texto que ya se ve en #page-title (arriba, en el
   topbar), así que se oculta para no gastar una fila entera dos veces — el
   hijo que sigue al <h2> (los botones de acción) se corre a la derecha en su
   lugar. El selector solo aplica cuando hay un <h2> justo antes: los <h3> de
   subtítulo dentro de la misma página (ej. "Últimas ventas") no tienen <h2>
   al lado y quedan intactos, alineados a la izquierda como siempre. */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { display: none; }
.page-header h2 + * { margin-left: auto; }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; border: none; transition: .15s; white-space: nowrap; }
.btn-primary { background: var(--accent-btn); color: #fff; }
.btn-primary:hover { background: var(--accent-btn-h); }
.btn-danger { background: #7f1d1d; color: #fca5a5; border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: #14532d; color: #4ade80; border: 1px solid #4ade8033; }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn-icon { padding: 6px 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Form ────────────────────────────────────────────── */
.form-group { margin-bottom: 8px; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; letter-spacing: .3px; text-transform: uppercase; }
.input { width: 100%; background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 6px 10px; outline: none; transition: border-color .15s; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
select.input { cursor: pointer; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.usr-empresa-checks { max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; background: var(--bg3); display: flex; flex-direction: column; gap: 8px; }
.usr-check-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* ── Compras/Ventas: buscador con autocompletado + carrito ───── */
.buscador-wrap { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; margin-top: 4px; max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.autocomplete-item { padding: 9px 12px; font-size: 13px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg3); }
.autocomplete-price { color: var(--muted); font-size: 12px; white-space: nowrap; }
.autocomplete-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.autocomplete-crear { color: var(--accent); font-weight: 600; }
.selected-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: 6px 8px 6px 14px; font-size: 13px; }
.chip-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 50%; }
.chip-remove:hover { background: var(--red); color: #fff; }
.carrito-input { max-width: 100px; }
.carrito-lote-row td { padding-top: 0; border-top: none; }
.carrito-lote-input { max-width: 220px; }
.carrito-fila-error td { background: var(--chip-red-bg); border-top-color: var(--chip-red-bd); }
.doc-total-row { text-align: right; font-size: 16px; margin: 14px 0; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Pestañas de categoría (selector táctil por categoría) ──────── */
.categoria-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 6px; margin-top: 4px; -webkit-overflow-scrolling: touch; }
.categoria-tab { flex: 0 0 auto; min-height: 30px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; transition: .15s; white-space: nowrap; }
.categoria-tab:hover { border-color: var(--accent); color: var(--text); }
.categoria-tab.active { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }

/* ── Nueva Venta: vista de página completa (no modal), estructura y
   densidad iguales a 1000tonMarket — catálogo en grilla + carrito en la
   barra lateral (angosta, tarjetas compactas en vez de tabla ancha). ──── */
.venta-page { display: flex; flex-direction: column; min-height: calc(100vh - 90px); }
.venta-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 26vw, 420px); gap: 14px; align-items: start; }
.venta-main { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.venta-main > .form-group:first-child { flex: 0 0 auto; }
#venta-categoria-tabs { flex: 0 0 auto; }
#venta-productos-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.venta-sidebar {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  position: sticky; top: 8px;
  display: flex; flex-direction: column;
  /* Seguro para pantallas bajas (ej. laptops 1280x720): en vez de empujar el botón
     "Registrar Venta" fuera de la vista, la barra lateral scrollea internamente. */
  max-height: calc(100vh - 16px); overflow-y: auto;
}
.venta-carrito-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex: 0 0 auto; }
.venta-carrito-header h3 { font-size: 13px; margin: 0; }
#venta-carrito { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#venta-form { flex: 0 0 auto; }
.venta-total-box { text-align: center; background: var(--bg3); border: 1px solid var(--accent); border-radius: 10px; padding: 7px; margin: 7px 0; }
.venta-total-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-bottom: 2px; }
.venta-total-monto { font-size: 21px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.input-monto-grande { font-size: 20px; font-weight: 800; text-align: center; padding: 8px; color: var(--accent); }

/* ── Configuración de comprobantes: formulario + vista previa en vivo en un
   panel lateral (mismo criterio de layout que .venta-layout/.venta-sidebar:
   grid de 2 columnas, panel lateral angosto y sticky con scroll interno). ── */
.cc-layout { display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 440px); gap: 14px; align-items: start; }
.cc-main { min-width: 0; }
.cc-preview {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  position: sticky; top: 8px;
  display: flex; flex-direction: column;
  /* height (no solo max-height): así el panel ocupa todo el alto visible
     disponible y el iframe (flex:1 abajo) puede estirarse a ocuparlo, en vez
     de quedar del alto mínimo de su contenido. */
  height: calc(100vh - 16px);
  max-height: calc(100vh - 16px);
}
.cc-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex: 0 0 auto; }
.cc-preview-header h3 { font-size: 13px; margin: 0; }
.cc-preview-status { font-size: 11px; color: var(--muted); }
.cc-preview-frame-wrap {
  flex: 1 1 auto; min-height: 0; border-radius: 10px; overflow: hidden; background: #fff;
  border: 1px solid var(--border); box-shadow: 0 8px 24px -14px rgba(0,0,0,.5);
}
.cc-preview-frame { width: 100%; height: 100%; min-height: 480px; border: none; display: block; }
@media (max-width: 1024px) {
  .cc-layout { grid-template-columns: 1fr; }
  .cc-preview { position: static; height: auto; max-height: none; }
  .cc-preview-frame { min-height: 600px; }
}

/* ── Comprobantes: rediseño del formulario (tarjetas con más aire/profundidad,
   controles a medida en vez del look nativo del navegador) — todo escopeado
   bajo .cc-main para no tocar .card/.input/checkbox del resto de la app. ──── */
.cc-main .card {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg2) 100%, white 2%), var(--bg2));
  border-radius: 14px; padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 12px 28px -18px rgba(0,0,0,.45);
  transition: border-color .2s, box-shadow .2s;
}
.cc-main .card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: .8;
}
.cc-main .card:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.cc-main .card-title {
  font-size: 13px; letter-spacing: .2px; padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.cc-main .card-title .icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; padding: 6px; box-sizing: content-box;
  border-radius: 9px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.cc-main .form-group label { font-size: 10.5px; letter-spacing: .5px; }
.cc-main select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
  padding-right: 34px; border-radius: 9px;
}
.cc-main select.input:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.cc-main .card p.text-muted { line-height: 1.5; }

/* Checkboxes a medida (el navegador los dibuja como cuadraditos planos que
   desentonan con el resto del panel) — check de tilde puro en CSS, sin JS. */
.cc-main .usr-check-item { padding: 3px 0; }
.cc-main input[type=checkbox] {
  appearance: none; flex-shrink: 0;
  width: 18px; height: 18px; border-radius: 6px;
  border: 1.5px solid var(--border); background: var(--bg3);
  cursor: pointer; position: relative;
  transition: background .15s, border-color .15s;
}
.cc-main input[type=checkbox]:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.cc-main input[type=checkbox]:checked { background: var(--accent-btn); border-color: var(--accent-btn); }
.cc-main input[type=checkbox]:checked::after {
  content: ''; position: absolute; left: 5px; top: 1px;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Selectores de color: swatch grande y redondeado en vez del rectángulo
   angosto por defecto del navegador. */
.cc-main input[type=color] {
  width: 52px; height: 34px; padding: 3px; border-radius: 9px;
  border: 1.5px solid var(--border); background: var(--bg3); cursor: pointer;
}
.cc-main input[type=color]:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.cc-main input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.cc-main input[type=color]::-webkit-color-swatch { border: none; border-radius: 6px; }
.cc-main input[type=color]::-moz-color-swatch { border: none; border-radius: 6px; }

/* Selector de archivo: el <input type=file> nativo (botón "Elegir archivo" +
   texto "Sin archivos seleccionados") desentona con el resto — queda oculto
   y en su lugar un <label> hace de botón (dispara el picker sin JS) + un
   span propio muestra el nombre elegido. */
.cc-file-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cc-file-picker-nombre { font-size: 12px; }

/* ── Catálogo de productos (selector rápido con imágenes, tocable) ──
   La imagen/placeholder tenía aspect-ratio:1 (cuadrada, ligada al ancho de
   columna) — en pantallas bajas (ej. 1366x768) eso dejaba cada fila de ~186px
   y apenas 2 filas visibles sin scroll. Con una altura fija y más chica caben
   4-5 filas en la misma área, sin tocar el ancho/cantidad de columnas. */
.producto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; margin-bottom: 8px; }
.producto-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 7px; cursor: pointer; transition: .15s; text-align: center; }
.producto-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px -8px rgba(0,0,0,.35); }
.producto-card-img { width: 100%; height: 56px; object-fit: cover; border-radius: 8px; margin-bottom: 4px; }
.producto-card-placeholder { display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--bg2); opacity: .4; }
.producto-card-nombre { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.producto-card-precio { font-size: 12px; color: var(--accent); font-weight: 700; line-height: 1.3; }

/* ── Carrito de venta: fila compacta por producto (2 líneas), no tabla ── */
.carrito-lista { display: flex; flex-direction: column; gap: 6px; }
.carrito-vacio { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 24px 10px; color: var(--muted); }
.carrito-vacio-icon { font-size: 30px; opacity: .5; margin-bottom: 6px; }
.carrito-vacio p { margin: 0; font-size: 12px; }
.carrito-vacio p:first-of-type { font-weight: 700; color: var(--text); font-size: 13px; }
.carrito-item { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.carrito-item.carrito-fila-error { border-color: var(--red); background: var(--chip-red-bg); }
.carrito-item-row { display: flex; align-items: center; gap: 6px; }
.carrito-item-nombre { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.carrito-item-total { font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap; flex-shrink: 0; min-width: 50px; text-align: right; }
.carrito-input-mini { width: 40px; flex-shrink: 0; padding: 4px 3px; font-size: 11px; text-align: center; background: var(--bg2); border: 1px solid var(--border); border-radius: 5px; color: var(--text); }
.carrito-item-precio-fijo { flex-shrink: 0; min-width: 40px; text-align: center; font-size: 11px; color: var(--muted); }
.carrito-item-x { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.carrito-quitar-btn { min-width: 32px; min-height: 32px; font-size: 13px; }
/* Ícono de ubicación por línea — chico, no un badge con texto, para no
   desarmar la tarjeta compacta de 2 líneas del carrito. */
.carrito-ubic-btn { flex-shrink: 0; min-width: 26px; min-height: 26px; padding: 4px; display: inline-flex; align-items: center; justify-content: center; }
.carrito-ubic-btn .icon { width: 14px; height: 14px; }
.carrito-ubic-btn-vacio { color: var(--muted); opacity: .4; cursor: default; }

/* ── Método de pago: botones grandes de un toque, no <select> ───── */
.metodo-pago-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.metodo-pago-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 48px; border-radius: 10px; border: 2px solid transparent; cursor: pointer;
  font-size: 17px; color: #fff; opacity: .55; transition: .15s; padding: 6px 3px;
}
.metodo-pago-btn span { font-size: 10px; font-weight: 700; }
.metodo-pago-btn.active { opacity: 1; border-color: rgba(255,255,255,.6); transform: translateY(-1px); }
.metodo-efectivo { background: #16a34a; }
.metodo-qr { background: #7c3aed; }
.metodo-tarjeta { background: #2563eb; }
.metodo-mixto { background: #0d9488; }

/* ── Pago mixto: 3 montos (efectivo/QR/tarjeta) en vez de uno solo ─── */
.venta-mixto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.venta-mixto-item label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.venta-mixto-item .input { text-align: center; font-weight: 700; padding: 6px 4px; }

.btn-lg { padding: 8px; font-size: 13px; }
.section-subtitle { font-size: 13px; font-weight: 700; color: var(--text); margin: 0; }
.atajos-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; margin-bottom: 8px; font-size: 11px; color: var(--muted); }
.atajos-bar kbd { background: var(--bg3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; font-family: inherit; font-size: 11px; font-weight: 700; color: var(--text); }
.atajos-tutorial-link { margin-left: auto; color: var(--accent); font-weight: 600; }
.atajos-bar-footer { margin-top: auto; margin-bottom: 0; }
/* Sucursal vive en la barra de atajos (no en el form de cobro): es contexto
   fijo de la sesión, casi nunca cambia mientras se vende. */
.atajos-sucursal { display: flex; align-items: center; gap: 6px; padding-right: 10px; border-right: 1px solid var(--border); }
.atajos-sucursal #venta-sucursal-slot { display: flex; }
.atajos-sucursal .input { width: auto; min-width: 140px; padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 36px; }
.search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ── Password toggle (ojito) ────────────────────────── */
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 40px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); padding: 6px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: .15s; }
.password-toggle:hover { color: var(--text); background: var(--bg3); }
.password-toggle svg { width: 16px; height: 16px; display: block; }

/* ── Filters bar ─────────────────────────────────────── */
.filters { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters .input { width: auto; flex: 1; min-width: 160px; max-width: 260px; }
.inv-search-wrap { position: relative; flex: 1 1 280px; max-width: 440px; }
.inv-search-wrap .input { width: 100%; padding-left: 36px; }
.inv-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: flex; }
.inv-search-icon .icon { width: 16px; height: 16px; }

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--bg3); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; padding: 5px 10px; text-align: left; white-space: nowrap; }
thead th.th-sortable { cursor: pointer; user-select: none; transition: color .15s; }
thead th.th-sortable:hover { color: var(--text); }
tbody td { padding: 4px 10px; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
tbody tr:hover td { background: var(--hover-tint); }
.td-actions { display: flex; gap: 6px; }
.empty-row td { text-align: center; padding: 32px; color: var(--muted); font-size: 13px; }

/* ── Table pagination ───────────────────────────────────── */
.table-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.table-pagination-size { display: flex; align-items: center; gap: 6px; }
.table-pagination-size select { width: auto; padding: 4px 8px; font-size: 12px; }
.table-pagination-nav { display: flex; align-items: center; gap: 10px; }
.table-pagination-page { white-space: nowrap; }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; gap: 4px; }
.badge-green  { background: var(--chip-green-bg);  color: var(--chip-green-fg);  border: 1px solid var(--chip-green-bd); }
.badge-red    { background: var(--chip-red-bg);    color: var(--chip-red-fg);    border: 1px solid var(--chip-red-bd); }
.badge-yellow { background: var(--chip-yellow-bg); color: var(--chip-yellow-fg); border: 1px solid var(--chip-yellow-bd); }
.badge-blue   { background: var(--chip-blue-bg);   color: var(--chip-blue-fg);   border: 1px solid var(--chip-blue-bd); }
.badge-purple { background: var(--chip-purple-bg); color: var(--chip-purple-fg); border: 1px solid var(--chip-purple-bd); }
.badge-gray   { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }
.badge-orange { background: var(--chip-orange-bg); color: var(--chip-orange-fg); border: 1px solid var(--chip-orange-bd); }

/* ── Stats cards ─────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat-card .stat-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 22px; font-weight: 800; margin: 4px 0; }
.stat-card .stat-sub { font-size: 11px; color: var(--muted); }
.stat-card.green { border-color: #4ade8033; }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red { border-color: #f8717133; }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.yellow { border-color: #fbbf2433; }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.blue { border-color: #60a5fa33; }
.stat-card.blue .stat-value { color: var(--accent); }

/* ── Section card ────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

/* ── Spinner ─────────────────────────────────────────── */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: flex; align-items: center; justify-content: center; height: 200px; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

/* ── Inventario specific ─────────────────────────────── */
.inv-select-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.inv-select-bar .input { max-width: 240px; }
.inv-select-bar .inv-search-wrap .input { width: 100%; max-width: none; }
.permission-toolbar { display:flex; gap:14px; flex-wrap:wrap; align-items:end; }
.permission-toolbar .form-group { min-width:240px; margin-bottom:8px; }
.permission-help { padding:10px 12px; margin:8px 0 14px; border:1px solid var(--border); border-radius:8px; color:var(--muted); font-size:12px; }
.permission-matrix { min-width:850px; width:100%; border-collapse:collapse; }
.permission-matrix th, .permission-matrix td { padding:8px; border-bottom:1px solid var(--border); text-align:left; }
.permission-matrix thead th { font-size:12px; color:var(--muted); }
.permission-matrix tbody th { min-width:190px; font-size:13px; }
.permission-select { min-width:118px; font-size:12px; padding:7px; }
.soft-deleted-icon { display:inline-flex; vertical-align:middle; margin-right:7px; color:var(--danger); }
.soft-deleted-icon .icon { width:16px; height:16px; }
.stock-ok   { color: var(--green); font-weight: 700; }
.stock-low  { color: var(--yellow); font-weight: 700; }
.stock-zero { color: var(--red); font-weight: 700; }

/* ── Gráfico de distribución del almacén (barras horizontales, un solo valor
   por ubicación: unidades totales) ─────────────────────────────────────── */
.almacen-chart { display: flex; flex-direction: column; gap: 12px; }
.almacen-bar-row { display: flex; align-items: center; gap: 12px; }
.almacen-bar-label { width: 160px; flex-shrink: 0; overflow: hidden; }
.almacen-bar-codigo { font-size: 13px; font-weight: 700; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.almacen-bar-sub { font-size: 11px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.almacen-bar-track { flex: 1; height: 20px; background: var(--bg3); border-radius: 4px; min-width: 60px; }
.almacen-bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); transition: width .3s ease; }
.almacen-bar-fill.almacen-bar-sinubicacion { background: var(--muted); opacity: .55; }
.almacen-bar-value { width: 70px; flex-shrink: 0; text-align: right; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Estantes del almacén: plano cenital + vista frontal Piso × Cuadrante ─── */
.almacen-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }

/* Selector de sucursal arriba a la derecha del panel — es lo único que queda
   en esa fila (el resto se sacó para no ocupar espacio de más). */
.almacen-mapa-header { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.almacen-mapa-header select { max-width: 240px; }

/* Controles de zoom flotando en la esquina superior derecha del plano mismo
   (no en la barra de arriba, que queda lejos del mapa) — patrón típico de
   editores de mapa/plano (ej. Google Maps). */
.almacen-zoom-controls {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  display: flex; align-items: center; gap: 2px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 3px; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.almacen-zoom-label { font-size: 12px; color: var(--muted); min-width: 38px; text-align: center; }
.almacen-zoom-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }

/* "Nuevo estante" como botón circular flotando en la esquina opuesta al
   zoom — icono solo, sin texto, para no restarle espacio al plano. */
.almacen-fab-nuevo {
  position: absolute; top: 8px; left: 8px; z-index: 10;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-btn); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3); transition: .15s;
}
.almacen-fab-nuevo:hover { background: var(--accent-btn-h); }
.almacen-fab-nuevo .icon { width: 18px; height: 18px; }

/* Plano (izquierda) + detalle del estante seleccionado (derecha) — todo en el
   mismo panel, sin navegar a otra pantalla. En pantallas angostas se apilan. */
.almacen-split { display: flex; gap: 16px; align-items: flex-start; }
.almacen-plano-col { flex: 1 1 55%; min-width: 0; }
.almacen-frontal-col { flex: 1 1 45%; min-width: 260px; overflow-y: auto; }
@media (max-width: 860px) {
  .almacen-split { flex-direction: column; }
  .almacen-plano-col, .almacen-frontal-col { flex-basis: auto; width: 100%; max-height: none !important; }
}

/* El "marco" (viewport) tiene SIEMPRE el mismo tamaño en pantalla — la altura
   la fija _ajustarAlturaMapa() (inventario.js) en base al espacio real
   disponible hasta el borde de la ventana, así no queda un colchón de espacio
   vacío abajo; min-height acá es solo el piso antes de que corra ese JS. El
   canvas de adentro llena siempre el marco entero (nada de transform:scale) —
   lo que cambia con el zoom es a cuántas unidades lógicas (0–100/zoom)
   equivale ese 100% del marco: alejar agranda el espacio lógico disponible
   (más lugar real para seguir agregando estantes, no solo un dibujo más
   chico), acercar lo achica para trabajar con más precisión (lo que no entra
   se ve con scroll, igual que cualquier área más grande que su contenedor).
   Ver el comentario en _renderMapaSplit() sobre el valor lógico vs. renderizado. */
.almacen-plano-viewport {
  position: relative;
  width: 100%;
  min-height: 360px;
  background-color: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  touch-action: none;
}
.almacen-plano-canvas {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 5% 5%;
  touch-action: none;
}
.almacen-plano-rect {
  position: absolute;
  border: 2px solid;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: box-shadow .15s;
}
/* Candado cerrado: no se puede mover/redimensionar, el cursor lo aclara
   (puntero de "clic para ver" en vez de "agarrar para mover"). */
.almacen-plano-viewport.locked .almacen-plano-rect { cursor: pointer; }
.almacen-plano-rect.dragging { cursor: grabbing; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.almacen-plano-rect.resizing { z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.almacen-plano-rect.selected { outline: 3px solid var(--accent); outline-offset: 1px; z-index: 4; }
.almacen-plano-rect.highlight { animation: almacen-plano-pulso 1.3s ease-in-out infinite; }
.almacen-plano-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  touch-action: none;
}
.almacen-plano-resize::before {
  content: '';
  position: absolute;
  right: 3px; bottom: 3px;
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: .55;
}
.almacen-plano-rect:hover .almacen-plano-resize::before,
.almacen-plano-resize:hover::before { opacity: 1; }
@keyframes almacen-plano-pulso {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

/* Panel derecho sin estante seleccionado todavía. */
.almacen-frontal-placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px; text-align: center; padding: 24px;
  border: 2px dashed var(--border); border-radius: 8px;
  color: var(--muted);
}
.almacen-frontal-placeholder .icon { opacity: .5; width: 28px; height: 28px; }

/* Form de edición del estante (nombre/pisos/ancho/alto), inline arriba de la
   grilla de cuadrantes — reusa .form-grid-2/.form-group/.form-actions, los
   mismos estilos de los forms en modal, solo con menos margen inferior para
   no separarse tanto de la grilla que sigue debajo. */
.almacen-edit-form { margin-bottom: 12px; }
.almacen-edit-form .form-actions { margin-top: 8px; }

/* Vista frontal de un estante: filas = pisos (el más alto arriba, como se ve un
   estante real de frente), cada fila con sus 4 cuadrantes lado a lado. */
.almacen-frontal { display: flex; flex-direction: column; gap: 6px; max-width: 420px; }
.almacen-frontal-fila { display: flex; align-items: center; gap: 8px; }
.almacen-frontal-piso-num { font-size: 12px; font-weight: 700; color: var(--muted); width: 24px; flex-shrink: 0; text-align: center; }
.almacen-frontal-cuadrantes { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.almacen-cuadrante {
  aspect-ratio: 1 / 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.almacen-cuadrante:hover { background: var(--bg); border-color: var(--accent); }
.almacen-cuadrante.ocupado { background: var(--chip-green-bg); color: var(--chip-green-fg); border-color: var(--chip-green-bd); font-weight: 700; }
.almacen-cuadrante.highlight { animation: almacen-celda-pulso 1.2s ease-in-out infinite; }
@keyframes almacen-celda-pulso {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent); }
  50%      { box-shadow: 0 0 0 4px transparent; }
}

/* Ventanita de "ver ubicación" (badge de Ventas/Inventario) — mismas dos
   vistas que Empresas → Mapa del almacén, pero read-only y en un modal, sin
   compartir DOM/estado con esa pestaña. */
.almacen-ubic-modal { display: flex; gap: 18px; flex-wrap: wrap; }
/* El plano manda acá (es lo que ubica "dónde" antes que el detalle piso por
   piso) — más ancho y más alto que la vista frontal, que va compacta. */
.almacen-ubic-modal-plano { flex: 1.6 1 380px; min-width: 300px; }
.almacen-ubic-modal-frontal { flex: 1 1 200px; max-width: 230px; min-width: 190px; }
.almacen-ubic-modal-viewport { min-height: 380px; max-height: 460px; }
/* editarUbicacion() reusa este mismo layout pero es clickeable (elegir
   estante/cuadrante) — el cursor "default" es solo para la versión de solo
   lectura de irAlMapa(), marcada con esta clase extra. */
.almacen-ubic-modal.readonly .almacen-plano-rect,
.almacen-ubic-modal.readonly .almacen-cuadrante { cursor: default; }

/* ── Reportes ────────────────────────────────────────── */
.report-grid, .reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.report-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.report-card h4 { font-size: 14px; font-weight: 700; }
.report-card p { font-size: 12px; color: var(--muted); flex: 1; }

/* Reportes: listado horizontal compacto. El filtro común queda arriba y cada
   reporte ocupa una sola fila para aprovechar mejor el ancho disponible. */
.reports-grid { grid-template-columns: 1fr; gap: 6px; }
.reports-grid > .card:not(#rep-resumen-card) {
  display: grid; grid-template-columns: minmax(180px, .65fr) minmax(260px, 1.5fr) auto auto;
  align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 0;
}
.reports-grid > .card:not(#rep-resumen-card) .card-title { margin: 0; font-size: 13px; }
.reports-grid > .card:not(#rep-resumen-card) > p { margin: 0; font-size: 12px !important; line-height: 1.35; }
.reports-grid > .card:not(#rep-resumen-card) > .form-group { margin: 0; min-width: 78px; max-width: 90px !important; }
.reports-grid > .card:not(#rep-resumen-card) > .form-actions { margin: 0; justify-content: flex-end; }
#rep-resumen-card { margin-top: 8px; }
#rep-resumen-card .stats-grid { grid-template-columns: repeat(4,1fr) !important; gap: 8px !important; margin-bottom: 0; }
@media (min-width: 1400px) {
  .reports-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .reports-grid > .card:not(#rep-resumen-card) { grid-template-columns: minmax(0,1fr) auto; gap: 4px 10px; }
  .reports-grid > .card:not(#rep-resumen-card) > p { grid-column: 1 / -1; }
  .reports-grid > .card:not(#rep-resumen-card) > .form-group { grid-column: 1; grid-row: 3; }
  .reports-grid > .card:not(#rep-resumen-card) > .form-actions { grid-column: 2; grid-row: 1; }
  #rep-resumen-card { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .reports-grid > .card:not(#rep-resumen-card) { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .reports-grid > .card:not(#rep-resumen-card) > p { grid-column: 1 / -1; }
  .reports-grid > .card:not(#rep-resumen-card) > .form-group { grid-column: 1; }
  .reports-grid > .card:not(#rep-resumen-card) > .form-actions { grid-column: 2; grid-row: 1; }
  #rep-resumen-card .stats-grid { grid-template-columns: repeat(2,1fr) !important; }
}
.mb-3 { margin-bottom: 12px; }
.stat-value.ok     { color: var(--green); }
.stat-value.warn   { color: var(--yellow); }
.stat-value.danger { color: var(--red); }

/* ── Plan banner ─────────────────────────────────────── */
.plan-banner { padding: 10px 24px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.plan-banner-warn   { background: var(--banner-warn-bg); border-bottom: 1px solid var(--yellow); color: var(--banner-warn-fg); }
.plan-banner-danger { background: var(--banner-danger-bg); border-bottom: 1px solid var(--red);    color: var(--banner-danger-fg); }
.impersonation-banner { padding: 9px 18px; background: var(--chip-purple-bg); border-bottom: 1px solid var(--chip-purple-bd); color: var(--chip-purple-fg); display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 13px; font-weight: 600; }
.impersonation-banner .btn { padding: 4px 10px; font-size: 12px; }

/* ── Plan modal ──────────────────────────────────────── */
.plan-status-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 18px; }
.plan-info-row { display: flex; gap: 10px; font-size: 12px; margin-top: 5px; color: var(--muted); }
.plan-info-row span { min-width: 110px; }
.plan-info-row strong { color: var(--text); }
.plan-section { padding: 14px 0; border-top: 1px solid var(--border); }
.plan-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 10px; }
.plan-danger-section { padding-top: 16px; border-top: 1px solid #f8717133; }

/* ── Import Excel ────────────────────────────────────── */
.import-drop-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 36px 24px; text-align: center; cursor: pointer; transition: .2s; color: var(--muted); }
.import-drop-zone:hover, .import-drop-zone.drag-over { border-color: var(--accent); background: #4f8ef710; color: var(--text); }
.import-summary { display: flex; gap: 12px; justify-content: center; margin-bottom: 4px; }
.import-stat { flex: 1; text-align: center; padding: 16px 8px; border-radius: 8px; border: 1px solid var(--border); }
.import-stat-ok  { border-color: var(--chip-green-bd); background: var(--chip-green-bg); }
.import-stat-skip { border-color: var(--border); background: var(--bg3); }
.import-stat-err { border-color: var(--chip-red-bd); background: var(--chip-red-bg); }
.import-stat-num   { font-size: 28px; font-weight: 800; }
.import-stat-ok  .import-stat-num  { color: var(--green); }
.import-stat-err .import-stat-num  { color: var(--red); }
.import-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 600; margin-top: 2px; }

/* ── Tabs ────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.tab-btn { background: none; border: none; padding: 8px 18px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 6px 6px 0 0; transition: .15s; }
.tab-btn:hover { color: var(--text); background: var(--bg3); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: none; }
.tab-panel { padding-top: 20px; }

/* ── Badges extra ────────────────────────────────────── */
.badge-ok     { background: #d1fae5; color: #065f46; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-danger { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-warn   { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.req { color: var(--red); }

/* ── Responsive (tablets y móviles) ───────────────────── */
@media (max-width: 1024px) {
  #sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 4px 0 24px #0008; }
  #sidebar.open { transform: translateX(0); }
  #main-wrap { margin-left: 0; }
  #sidebar-toggle { display: block; }
  .venta-layout { grid-template-columns: 1fr; }
  .venta-sidebar { position: static; }
}

@media (max-width: 768px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 769px) and (max-width: 900px) {
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ── Sidebar compacto (solo íconos) ─────────────────────
   Solo aplica en desktop: en móvil el sidebar ya es un overlay a ancho completo
   (ver bloque @media max-width:1024px arriba) y no tiene sentido combinarlo. */
@media (min-width: 1025px) {
  #sidebar-compact-toggle { display: block; }
  #app-shell.sidebar-compact #sidebar { width: 64px; min-width: 64px; }
  #app-shell.sidebar-compact #main-wrap { margin-left: 64px; }
  #app-shell.sidebar-compact .sidebar-logo { justify-content: center; padding: 16px 4px; gap: 4px; }
  #app-shell.sidebar-compact .logo-icon { font-size: 20px; }
  #app-shell.sidebar-compact .sidebar-logo-text,
  #app-shell.sidebar-compact .nav-label,
  #app-shell.sidebar-compact .nav-section-label,
  #app-shell.sidebar-compact #empresa-selector-wrap { display: none; }
  #app-shell.sidebar-compact #sidebar-compact-toggle { transform: rotate(180deg); }
  #app-shell.sidebar-compact .nav-item { justify-content: center; padding: 8px 4px; gap: 0; }

  /* Tooltip accesible del ítem en modo compacto: reemplaza al .nav-label
     oculto arriba. Aparece con hover Y con :focus-visible (navegación por
     teclado), a la derecha del ítem — nunca en expandido ni en móvil, porque
     este bloque entero solo aplica a #app-shell.sidebar-compact en desktop. */
  /* Mismo tamaño fijo en los 3 (tema, notif, cuenta): si cada uno se achica a
     su propio contenido (emoji vs. avatar redondo) quedan "desalineados" en
     la columna aunque estén centrados — con una caja igual para los tres,
     quedan en fila prolija. */
  #app-shell.sidebar-compact #sidebar-footer { align-items: center; padding: 6px 4px; gap: 6px; }
  #app-shell.sidebar-compact #user-menu-btn,
  #app-shell.sidebar-compact #notif-btn,
  #app-shell.sidebar-compact #theme-toggle-btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  #app-shell.sidebar-compact .user-menu-name,
  #app-shell.sidebar-compact .user-menu-caret,
  #app-shell.sidebar-compact .sidebar-footer-label { display: none; }

  /* El topbar de arriba de cada página solo servía para 2 cosas: el botón ☰
     (ya oculto en desktop, es solo para abrir el sidebar en móvil) y el
     título de la página — que ya se repite como <h2> en cada .page-header
     (oculto por CSS, ver más arriba), así que quedaba vacío/redundante en
     desktop. Se oculta acá para recuperar esos ~46px de alto (mismo criterio
     que 1000tonMarket) — en móvil sigue visible porque ahí sí hace falta el
     botón ☰ (ver @media max-width:1024px). */
  #topbar { display: none; }

  /* Ventas debe entrar entera en la pantalla, sin scrollear la página: con
     .venta-sidebar en position:sticky + max-height:calc(100vh - Npx), ese
     cálculo asume que el panel ya está pegado arriba del viewport — pero antes
     de scrollear no lo está (las pestañas "Nueva Venta/Historial" arriba de
     .venta-layout ocupan su propio espacio), así que el panel terminaba más
     abajo del borde inferior real de la pantalla, tapando la barra de atajos.
     Con .venta-page a una altura real (no min-height) y #ventas-tab-nueva/
     .venta-layout como flex/grid que reparten ese alto exacto entre header,
     catálogo y carrito, el sobrante real siempre termina dentro del catálogo
     (#venta-productos-grid) y el carrito (#venta-carrito), que son los que de
     verdad tienen su propio scroll (mismo criterio que 1000tonMarket). */
  .venta-page { height: calc(100vh - 28px); min-height: 0; }
  #ventas-tab-nueva { flex: 1 1 auto; min-height: 0; overflow: hidden; }
  .venta-layout { height: 100%; align-items: stretch; }
  .venta-main, .venta-sidebar { min-height: 0; }
  .venta-sidebar { max-height: none; position: static; }
}
@media (max-width: 1024px) {
  #sidebar-compact-toggle { display: none; }
}
