/* Control de Ventas · Hoja de estilos principal
   Diseño responsive 400–1440px+, tema claro/oscuro automático, sin dependencias externas. */

:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #eef1f7;
  --border: #e3e7ef; --border-strong: #cfd5e1;
  --text: #0f172a; --text-2: #334155; --muted: #64748b; --muted-2: #94a3b8;
  --primary: #4f46e5; --primary-hover: #4338ca; --primary-soft: #eef2ff; --primary-text: #3730a3;
  --success: #059669; --success-soft: #ecfdf5; --success-text: #047857;
  --warning: #d97706; --warning-soft: #fffbeb; --warning-text: #b45309;
  --danger: #dc2626; --danger-soft: #fef2f2; --danger-text: #b91c1c;
  --info: #0284c7; --info-soft: #f0f9ff; --info-text: #0369a1;
  --neutral-soft: #f1f5f9; --neutral-text: #475569;
  --radius: 14px; --radius-sm: 9px; --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, .25);
  --sidebar-w: 260px; --topbar-h: 64px; --bottomnav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --focus: 0 0 0 3px rgba(79, 70, 229, .35);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --surface: #121a2b; --surface-2: #162034; --surface-3: #1c2740;
    --border: #243049; --border-strong: #33415e;
    --text: #e6eaf2; --text-2: #c3cad8; --muted: #8b97ad; --muted-2: #66728a;
    --primary: #818cf8; --primary-hover: #a5b4fc; --primary-soft: rgba(129, 140, 248, .14); --primary-text: #c7d2fe;
    --success: #34d399; --success-soft: rgba(52, 211, 153, .12); --success-text: #6ee7b7;
    --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12); --warning-text: #fcd34d;
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .12); --danger-text: #fca5a5;
    --info: #38bdf8; --info-soft: rgba(56, 189, 248, .12); --info-text: #7dd3fc;
    --neutral-soft: rgba(148, 163, 184, .12); --neutral-text: #cbd5e1;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4); --shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; } h4 { font-size: .92rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-3); padding: .1em .4em; border-radius: 5px; overflow-wrap: anywhere; }
pre.code { background: var(--surface-3); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .xsmall { font-size: .76rem; }
.text-right { text-align: right; } .text-center { text-align: center; } .nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; } .icon-lg { width: 22px; height: 22px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Estructura principal ---------- */
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40; transition: transform .22s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 20px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899); box-shadow: 0 6px 16px -6px rgba(99, 102, 241, .6); letter-spacing: .02em;
}
.sidebar-brand strong { display: block; font-size: .98rem; color: var(--text); }
.sidebar-brand small { display: block; color: var(--muted); font-size: .74rem; }
.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav-section { margin: 16px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0; border-radius: 10px; color: var(--text-2);
  font-weight: 520; min-height: 40px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.nav a.active .icon { color: var(--primary); }
.nav .count { margin-left: auto; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.main { margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 650; font-size: 1.02rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
.content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 24px; flex: 1; }
.nav-overlay { display: none; }
.store-select { max-width: 220px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .66rem; font-weight: 700; display: grid; place-items: center; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.avatar { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; font-size: .78rem; color: #fff; background: linear-gradient(135deg, #6366f1, #0ea5e9); flex: 0 0 auto; }
.user-chip span { font-size: .85rem; font-weight: 560; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottom-nav { display: none; }
.offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 80; padding: 8px 14px; padding-top: calc(8px + env(safe-area-inset-top));
  background: #b45309; color: #fff; text-align: center; font-size: .85rem; font-weight: 600; }

/* ---------- Cabecera de página ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: .84rem; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); } .breadcrumb a:hover { color: var(--text); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-header .muted { font-size: .84rem; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; position: relative; overflow: hidden; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; font-weight: 560; }
.kpi-label .icon { width: 16px; height: 16px; }
.kpi-value { font-size: 1.55rem; font-weight: 720; letter-spacing: -.02em; margin-top: 6px; overflow-wrap: anywhere; line-height: 1.2; }
.kpi-sub { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.kpi-hero { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border: 0; }
.kpi-hero .kpi-label, .kpi-hero .kpi-sub { color: rgba(255, 255, 255, .82); }
.kpi a.kpi-link { position: absolute; inset: 0; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-size: .76rem; padding: 1px 7px; border-radius: 999px; }
.trend.up { color: var(--success-text); background: var(--success-soft); }
.trend.down { color: var(--danger-text); background: var(--danger-soft); }
.kpi-hero .trend { background: rgba(255, 255, 255, .18); color: #fff; }
.status-pills { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.status-pill { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.status-pill strong { font-size: 1.25rem; }
.status-pill:hover { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap; line-height: 1.6; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.badge .icon { width: 13px; height: 13px; }
.store-dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; flex: 0 0 auto; }
.store-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--muted); max-width: 100%; }
.store-tag span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
  cursor: pointer; text-align: center; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger-text); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: .82rem; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field > span, .field-label { font-size: .84rem; font-weight: 600; color: var(--text-2); }
.field small, .help { color: var(--muted); font-size: .78rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=date],
input[type=tel], input[type=color], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
@media (min-width: 768px) { input, select, textarea { font-size: .92rem !important; } }
input[type=color] { padding: 4px; width: 56px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.has-error input, .has-error select, .has-error textarea, input.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger-text); font-size: .8rem; margin: 2px 0 0; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: .9rem; color: var(--text-2); }
.check input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--primary); flex: 0 0 auto; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 40px; height: 23px; min-height: 0; padding: 0; border-radius: 999px; background: var(--border-strong); border: 0; position: relative; cursor: pointer; transition: background .15s; flex: 0 0 auto; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(17px); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.input-group { display: flex; gap: 8px; }
.input-group > input { flex: 1; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 38px; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0; min-width: 0; }
.fieldset legend { padding: 0 6px; font-weight: 650; font-size: .88rem; }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filters .field { min-width: 150px; flex: 1 1 150px; }
.filters .field > span { font-size: .75rem; }
.filters .btn { flex: 0 0 auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: .82rem; font-weight: 560; cursor: pointer; min-height: 34px; }
.chip:hover { background: var(--surface-3); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.range-custom { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-custom input { width: auto; min-width: 150px; }

/* ---------- Tablas ---------- */
/* position: relative → los elementos absolutos internos (p. ej. textos .sr-only) quedan dentro del desplazamiento de la tabla
   y no ensanchan la página. */
.table-wrap { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .check-col { width: 1%; }
.table a.row-link { color: var(--text); font-weight: 650; }
.table a.row-link:hover { color: var(--primary); }
.cell-main { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.cell-sub { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.cell-clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); flex: 0 0 auto; display: grid; place-items: center; color: var(--muted-2); }
.media { display: flex; align-items: center; gap: 12px; min-width: 0; }
.media > div { min-width: 0; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.bulk-bar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--primary-soft); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bulk-bar.visible { display: flex; }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 9px; border: 1px solid var(--border); color: var(--text-2); font-size: .85rem; background: var(--surface); }
.pagination a:hover { background: var(--surface-3); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 650; }
.pagination .disabled { opacity: .45; }

/* ---------- Alertas y avisos ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 14px; font-size: .9rem; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert .icon { margin-top: 1px; }
.alert > div { min-width: 0; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { width: 42px; height: 42px; color: var(--muted-2); margin-bottom: 10px; }
.empty h3 { color: var(--text); }

/* ---------- Modales, menús y avisos flotantes ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); }
.modal-dialog { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; }
.modal-lg .modal-dialog { max-width: 980px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; text-align: left; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font: inherit; font-size: .88rem; background: none; border: 0; cursor: pointer; text-align: left; white-space: nowrap; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); color: var(--text); }
.dropdown-menu .danger { color: var(--danger-text); }
.dropdown-menu hr { margin: 6px 0; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: .88rem; animation: toast-in .2s ease; }
.toast.success { background: #065f46; color: #fff; } .toast.error { background: #991b1b; color: #fff; } .toast.warning { background: #92400e; color: #fff; }
.toast a { color: inherit; text-decoration: underline; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.notif-panel { width: min(380px, calc(100vw - 24px)); padding: 0; }
.notif-panel header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 60vh; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); white-space: normal; }
.notif-item:hover { background: var(--surface-2); color: var(--text); }
.notif-item.unread { background: var(--primary-soft); }
.notif-item strong { display: block; font-size: .88rem; }
.notif-item p { margin: 2px 0 0; font-size: .8rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.notif-item time { font-size: .72rem; color: var(--muted-2); }

/* ---------- Otros componentes ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: inherit; transition: width .4s ease; }
.progress.indeterminate > span { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.dl { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; overflow-wrap: anywhere; font-weight: 520; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: .86rem; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font-size: .74rem; color: var(--muted); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.quick-action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 92px; padding: 14px 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); font-weight: 650; font-size: .9rem; text-align: center; }
.quick-action .qa-icon { font-size: 1.6rem; line-height: 1; }
.quick-action:hover { border-color: var(--primary); color: var(--primary); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 8px; font-size: .88rem; overflow-wrap: anywhere; white-space: pre-line; }
.note.customer { background: var(--info-soft); border-color: transparent; }
.note footer { font-size: .74rem; color: var(--muted); margin-top: 4px; }
.code-box { display: flex; gap: 8px; align-items: center; background: var(--surface-3); border-radius: 10px; padding: 10px 12px; font-family: var(--mono); font-size: .85rem; word-break: break-all; }
.code-box span { flex: 1; min-width: 0; }
.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checklist small { display: block; color: var(--muted); }
.check-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex: 0 0 auto; }
.checklist .ok .check-icon { background: var(--success-soft); color: var(--success-text); }
.checklist .fail .check-icon { background: var(--danger-soft); color: var(--danger-text); }
.checklist .warn .check-icon { background: var(--warning-soft); color: var(--warning-text); }

/* ---------- Gráficos (SVG propios) ---------- */
.chart { position: relative; width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart .label { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .area { fill: url(#chartGradient); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { fill: var(--primary); }
.chart .bar:hover, .chart .point:hover { opacity: .8; }
.chart .point { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart-tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 8px; font-size: .78rem; white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; box-shadow: var(--shadow-lg); }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); font-size: .9rem; text-align: center; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; font-size: .84rem; }
.legend li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.legend .lg-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.legend .lg-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-wrap { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 16px; align-items: center; }
.hbar { display: grid; gap: 10px; }
.hbar-row { display: grid; gap: 4px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .84rem; }
.hbar-top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hbar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #a78bfa); }

/* ---------- Autenticación / instalador ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .18), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(236, 72, 153, .12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-body { padding: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand strong { font-size: 1.1rem; display: block; }
.install-wrap { width: 100%; max-width: 760px; }
.install-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.install-brand strong { display: block; } .install-brand small { color: var(--muted); }
.install-card { padding: 26px; }
.install-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 16px; overflow-x: auto; }
.install-steps li { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.install-steps li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; }
.install-steps li.current span { background: var(--primary); color: #fff; } .install-steps li.current { color: var(--text); font-weight: 650; }
.install-steps li.done span { background: var(--success); color: #fff; }
.install-steps li em { font-style: normal; }
.bullets { padding-left: 20px; } .bullets li { margin-bottom: 6px; }
.summary { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; margin: 0 0 18px; }
.summary dt { color: var(--muted); } .summary dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Estado de conexión ---------- */
.conn-status { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.conn-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); min-width: 0; }
.conn-item .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.conn-item .v { margin-top: 4px; font-weight: 600; overflow-wrap: anywhere; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(5, 150, 105, .5); animation: pulse 2s infinite; display: inline-block; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); } 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); } }

/* ---------- Editor de etiquetas ---------- */
.label-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 16px; align-items: start; }
.label-preview-frame { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 12px; background: #e5e7eb; }
.preview-sticky { position: sticky; top: calc(var(--topbar-h) + 16px); }
.toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }

/* ---------- Dashboard ---------- */
.dash { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  grid-template-areas: "sales sales" "status status" "charts recent" "charts notifs" "charts ."; align-items: start; }
.dash > * { margin: 0 !important; min-width: 0; }
.dash-sales { grid-area: sales; } .dash-status { grid-area: status; } .dash-recent { grid-area: recent; }
.dash-notifs { grid-area: notifs; } .dash-charts { grid-area: charts; } .dash-quick { grid-area: quick; }
.dash-sales .kpi-grid { margin-bottom: 0; }
@media (max-width: 1023px) {
  .dash { display: flex; flex-direction: column; }
  .dash > * { width: 100%; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .label-editor { grid-template-columns: 1fr; }
  .preview-sticky { position: static; }
}
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 35; }
  body.nav-open { overflow: hidden; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
}
@media (max-width: 767px) {
  body { font-size: 15px; }
  .content { padding: 14px 12px calc(var(--bottomnav-h) + 24px); }
  .topbar-title { font-size: .95rem; }
  .user-chip span:not(.avatar), .hide-mobile { display: none !important; }
  /* Periodos en una sola fila deslizable: las ventas quedan arriba del todo en el móvil. */
  .range-form .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .range-form .chips::-webkit-scrollbar { display: none; }
  .range-form .chip { flex: 0 0 auto; }
  .user-chip { padding: 3px; }
  .topbar.has-stores .topbar-title { display: none; }
  .topbar.has-stores .topbar-actions { flex: 1; justify-content: flex-end; min-width: 0; }
  .store-form { min-width: 0; flex: 0 1 auto; }
  .store-select { max-width: 100%; }
  .store-select { max-width: 150px; }
  h1 { font-size: 1.3rem; }
  .page-header { margin-bottom: 14px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .grid-3, .form-grid, .form-grid-3, .toggles { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 1.22rem; }
  .card-header, .card-body { padding: 14px; }
  .filters { padding: 12px; }
  .filters .field { flex: 1 1 100%; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .legend { width: 100%; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .summary { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-dialog { max-height: 92vh; border-radius: 18px 18px 0 0; max-width: none; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--bottomnav-h) + 12px); max-width: none; }
  .label-preview-frame { height: 480px; }
  .hide-desktop { display: initial; }
  /* Tablas convertidas en tarjetas */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border-bottom: 1px solid var(--border); padding: 12px 14px; position: relative; }
  table.cards tbody tr:hover td { background: transparent; }
  table.cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: left; flex: 0 0 auto; }
  table.cards td.card-title { display: block; text-align: left; padding: 0 44px 6px 0; }
  table.cards td.card-title::before, table.cards td.check-col::before, table.cards td.actions::before { display: none; }
  table.cards td.check-col { position: absolute; top: 12px; right: 12px; width: auto; padding: 0; }
  table.cards td.actions { justify-content: flex-end; padding-top: 8px; width: 100%; }
  table.cards td > * { min-width: 0; overflow-wrap: anywhere; }
  table.cards .cell-clip { max-width: 60vw; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; font-weight: 600; color: var(--muted); min-height: 48px; }
  .bottom-nav button { background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .icon { width: 21px; height: 21px; }
}
@media (min-width: 768px) { .hide-desktop { display: none !important; } }
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.1rem; }
  .btn { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Impresión de pantallas del panel ---------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .toasts, .page-actions, .filters, .no-print, .btn, .pagination, .nav-overlay { display: none !important; }
  .main { margin: 0; } .content { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card, .kpi { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
