/* ==========================================================================
   ERPGEST v2 · Sistema de diseño
   ========================================================================== */
:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f3f4f9;
  --surface-3: #eceef6;
  --border: #e5e7f0;
  --border-strong: #d4d7e3;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8a94a8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-text: #3f37c9;
  --violet: #7c3aed;
  --success: #15803d; --success-soft: #e8f7ee;
  --warning: #b45309; --warning-soft: #fdf3e2;
  --danger: #c62828;  --danger-soft: #fdecec;
  --info: #0369a1;    --info-soft: #e6f3fb;
  --neutral-soft: #eef0f5;
  --teal: #0f766e; --amber: #b45309; --green: #15803d; --red: #c62828;
  --ring: 0 0 0 3px rgba(79, 70, 229, .22);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
  --sidebar-mini: 78px;
  --topbar-h: 64px;
  --sidebar-bg: linear-gradient(180deg, #0f1430 0%, #141a3d 55%, #1b1650 100%);
  --sidebar-text: #c7cbe0;
  --sidebar-muted: #7d84a6;
  --sidebar-active: rgba(129, 140, 248, .16);
  /* Paleta de gráficos (validada para daltonismo, orden fijo) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --chart-grid: #e8eaf1; --chart-text: #64748b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e1a; --surface: #111827; --surface-2: #162032; --surface-3: #1c283d;
    --border: #233049; --border-strong: #31405e; --text: #e8ecf4; --text-2: #a7b2c7; --muted: #6f7d96;
    --primary: #818cf8; --primary-hover: #a5b4fc; --primary-soft: rgba(129, 140, 248, .14); --primary-text: #a5b4fc;
    --success: #4ade80; --success-soft: rgba(74, 222, 128, .12); --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .12); --info: #38bdf8; --info-soft: rgba(56, 189, 248, .12);
    --neutral-soft: rgba(148, 163, 184, .12); --teal: #2dd4bf; --amber: #fbbf24; --green: #4ade80; --red: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --chart-grid: #233049; --chart-text: #94a3b8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e1a; --surface: #111827; --surface-2: #162032; --surface-3: #1c283d;
  --border: #233049; --border-strong: #31405e; --text: #e8ecf4; --text-2: #a7b2c7; --muted: #6f7d96;
  --primary: #818cf8; --primary-hover: #a5b4fc; --primary-soft: rgba(129, 140, 248, .14); --primary-text: #a5b4fc;
  --success: #4ade80; --success-soft: rgba(74, 222, 128, .12); --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12);
  --danger: #f87171; --danger-soft: rgba(248, 113, 113, .12); --info: #38bdf8; --info-soft: rgba(56, 189, 248, .12);
  --neutral-soft: rgba(148, 163, 184, .12); --teal: #2dd4bf; --amber: #fbbf24; --green: #4ade80; --red: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --chart-grid: #233049; --chart-text: #94a3b8;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
code, .mono { font-family: var(--mono); font-size: .85em; }
[x-cloak] { display: none !important; }
::selection { background: var(--primary-soft); }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 60; transition: width .2s ease, transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.25rem; height: var(--topbar-h); }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff;
  background: linear-gradient(135deg, #6366f1, #a855f7); box-shadow: 0 8px 20px -8px rgba(139, 92, 246, .8); font-weight: 800;
}
.brand-name { font-weight: 800; font-size: 1.05rem; color: #fff; letter-spacing: -.02em; white-space: nowrap; }
.brand-name small { display: block; font-size: .68rem; font-weight: 600; color: var(--sidebar-muted); letter-spacing: .04em; }
.sidebar-empresa {
  margin: .25rem .9rem .75rem; padding: .65rem .75rem; border-radius: 12px; background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .07); font-size: .78rem; white-space: nowrap; overflow: hidden;
}
.sidebar-empresa strong { display: block; color: #fff; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .65rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-section { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--sidebar-muted);
  padding: 1rem .7rem .4rem; white-space: nowrap; }
.nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .58rem .7rem; border-radius: 10px; color: var(--sidebar-text);
  font-weight: 550; white-space: nowrap; cursor: pointer; border: 0; background: none; width: 100%; font: inherit; text-align: left;
}
.nav-link i { font-size: 1.05rem; width: 22px; text-align: center; flex: none; opacity: .9; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.nav-link .chev { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.nav-link[aria-expanded="true"] .chev { transform: rotate(90deg); }
.nav-sub { padding: .15rem 0 .35rem 2.15rem; }
.nav-sub a { display: block; padding: .38rem .65rem; border-radius: 8px; color: var(--sidebar-muted); font-size: .84rem; white-space: nowrap; }
.nav-sub a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav-sub a.active { color: #fff; background: rgba(255, 255, 255, .08); }
.mod-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sidebar-footer { padding: .9rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.plan-pill { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, rgba(99,102,241,.35), rgba(168,85,247,.28)); font-size: .8rem; white-space: nowrap; overflow: hidden; }
.plan-pill:hover { color: #fff; filter: brightness(1.1); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin .2s ease; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: .75rem;
  padding: 0 1.5rem; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-spacer { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: .6rem; height: 40px; padding: 0 .8rem; min-width: 260px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; font: inherit;
}
.search-trigger kbd { margin-left: auto; font-family: var(--mono); font-size: .7rem; padding: .1rem .4rem; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.content { padding: 1.5rem; flex: 1; width: 100%; max-width: 1560px; margin: 0 auto; }
.content-wide { max-width: none; }

/* Menú recogido (solo escritorio): iconos, y cada submenú se abre como panel flotante junto al icono */
@media (min-width: 1025px) {
  body.sidebar-mini .sidebar { width: var(--sidebar-mini); }
  body.sidebar-mini .main { margin-left: var(--sidebar-mini); }
  body.sidebar-mini .brand-name, body.sidebar-mini .sidebar-empresa, body.sidebar-mini .nav-section,
  body.sidebar-mini .nav-link span, body.sidebar-mini .nav-link .chev, body.sidebar-mini .plan-pill span { display: none; }
  body.sidebar-mini .nav-link { justify-content: center; }
  body.sidebar-mini .sidebar-brand { justify-content: center; padding: 1rem .5rem; }
  body.sidebar-mini .nav-sub { position: fixed; left: calc(var(--sidebar-mini) + 6px); z-index: 70; min-width: 220px; max-height: calc(100vh - 16px);
    overflow-y: auto; padding: .45rem; border-radius: 14px; background: #1b1f47; border: 1px solid rgba(255, 255, 255, .1); box-shadow: var(--shadow-lg); }
  body.sidebar-mini .nav-sub::before { content: attr(data-titulo); display: block; padding: .35rem .65rem .45rem; font-size: .68rem; font-weight: 700;
    letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-muted); }
  body.sidebar-mini .nav-sub a { color: var(--sidebar-text); }
  body.sidebar-mini .nav-sub a:hover, body.sidebar-mini .nav-sub a.active { color: #fff; background: rgba(255, 255, 255, .1); }
}

.backdrop { display: none; position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 55; backdrop-filter: blur(2px); }
.bottom-nav { display: none; }

/* ---------- Encabezado de página ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header .titles { min-width: 0; }
.page-header p { color: var(--text-2); margin: .3rem 0 0; max-width: 760px; }
.page-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 1.25rem; flex: none;
  background: var(--primary-soft); color: var(--primary-text); }
.page-header .head { display: flex; gap: .9rem; align-items: center; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.breadcrumb { display: flex; gap: .4rem; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 40px; padding: 0 1rem;
  border-radius: 11px; border: 1px solid transparent; font: inherit; font-weight: 650; font-size: .875rem; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; user-select: none;
  color: var(--text); background: var(--surface); border-color: var(--border);
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, #5b50f0, #4f46e5); border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -8px rgba(79, 70, 229, .8); }
.btn-primary:hover { background: linear-gradient(135deg, #5046e5, #4338ca); color: #fff; border-color: transparent; }
.btn-success { background: #16a34a; color: #fff; border-color: transparent; }
.btn-success:hover { background: #15803d; color: #fff; border-color: transparent; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: #dc2626; color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.btn-soft:hover { background: var(--primary); color: #fff; border-color: transparent; }
.btn-whatsapp { background: #16a34a; color: #fff; border-color: transparent; }
.btn-sm { height: 32px; padding: 0 .7rem; font-size: .8rem; border-radius: 9px; }
.btn-lg { height: 48px; padding: 0 1.4rem; font-size: .95rem; border-radius: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.icon-btn .dot-count { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: #ef4444; color: #fff; font-size: .62rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h3 { display: flex; align-items: center; gap: .5rem; }
.card-header .sub { color: var(--muted); font-size: .8rem; font-weight: 500; }
.card-body { padding: 1.15rem; }
.card-footer { padding: .9rem 1.15rem; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius); }
.card-flush .card-body { padding: 0; }
/* Subtítulo que separa bloques dentro de una tarjeta (a la derecha: una nota o una acción) */
.card-section { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .55rem 1.15rem; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .72rem;
  font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card-section small { font-size: .74rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.card-section .btn { letter-spacing: 0; text-transform: none; }
.list-row + .card-section { border-top: 0; }
.card-gradient { background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%); color: #fff; border: 0;
  box-shadow: 0 20px 40px -20px rgba(91, 33, 182, .7); }
.card-gradient .muted, .card-gradient p { color: rgba(255, 255, 255, .8); }

.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-12 { grid-column: span 12; } .col-9 { grid-column: span 9; } .col-8 { grid-column: span 8; } .col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; } .col-5 { grid-column: span 5; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.cards-auto { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.muted { color: var(--muted); } .text-2 { color: var(--text-2); } .small { font-size: .8rem; } .xsmall { font-size: .72rem; }
.right { text-align: right; } .center { text-align: center; } .bold { font-weight: 700; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.text-primary { color: var(--primary-text); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide { display: none !important; }

/* ---------- KPIs ---------- */
.kpis { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 1.25rem; }
.kpi { position: relative; overflow: hidden; padding: 1.05rem 1.15rem; display: flex; gap: .9rem; align-items: flex-start; color: inherit; }
a.kpi:hover { border-color: var(--border-strong); color: inherit; box-shadow: var(--shadow); }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; flex: none; }
.kpi-label { color: var(--text-2); font-size: .8rem; font-weight: 600; }
.kpi-value { font-size: 1.45rem; font-weight: 780; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: .1rem; }
.kpi-sub { font-size: .76rem; color: var(--muted); margin-top: .15rem; }
.kpi.alerta .kpi-sub { color: var(--danger); font-weight: 600; }
.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.tone-violet { background: rgba(124, 58, 237, .12); color: #7c3aed; }
.tone-teal { background: rgba(13, 148, 136, .12); color: var(--teal); }
.tone-amber { background: var(--warning-soft); color: var(--amber); }
.tone-green { background: var(--success-soft); color: var(--green); }
.tone-red { background: var(--danger-soft); color: var(--red); }
.trend { display: inline-flex; align-items: center; gap: .2rem; font-size: .75rem; font-weight: 700; padding: .05rem .4rem; border-radius: 6px; }
.trend.up { color: var(--success); background: var(--success-soft); }
.trend.down { color: var(--danger); background: var(--danger-soft); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 700;
  white-space: nowrap; line-height: 1.4; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-plain::before { display: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.dot-success { background: #16a34a; } .dot-neutral { background: var(--muted); } .dot-danger { background: #dc2626; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); font-size: .8rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tag { display: inline-block; padding: .1rem .45rem; border-radius: 6px; background: var(--surface-3); font-size: .72rem; color: var(--text-2); font-weight: 600; }

/* ---------- Tablas ---------- */
.toolbar { display: flex; gap: .6rem; padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 2.2rem; }
.toolbar .form-select, .toolbar input[type=date] { width: auto; min-width: 140px; height: 38px; }
.toolbar .form-select.is-active { border-color: var(--primary); background-color: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
/* fecha con su rótulo ("Desde" / "Hasta") dentro del mismo campo */
.date-field { display: inline-flex; align-items: center; gap: .5rem; height: 38px; padding: 0 .35rem 0 .8rem; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface); cursor: text; transition: border-color .15s, box-shadow .15s; }
.date-field > span { font-size: .68rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.toolbar .date-field input[type=date] { width: auto; min-width: 0; height: 34px; padding: 0 .3rem; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: .88rem; }
.toolbar .date-field input[type=date]:focus { outline: none; }
.date-field:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.date-field.is-active { border-color: var(--primary); background: var(--primary-soft); }
.date-field.is-active > span { color: var(--primary-text); }
.list-summary { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .5rem 1.15rem; min-height: 46px;
  font-size: .8rem; color: var(--text-2); border-bottom: 1px solid var(--border); }
.list-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.list-summary.plano { padding: 0 .15rem .6rem; border-bottom: 0; min-height: 0; }  /* sobre listas de tarjetas, sin marco */
.card > .pagination:first-child { border-top: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }
.table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 750;
  padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th a { color: inherit; display: inline-flex; gap: .3rem; align-items: center; }
.table th a:hover { color: var(--primary-text); }
.table th.sorted, .table th.sorted a { color: var(--primary-text); }
.table th .sort-hint { font-size: .68rem; opacity: .4; }
.table th a:hover .sort-hint { opacity: .9; }
/* el encabezado hereda la alineación de su columna (más específico que `.table th`) */
.table th.right, .doc-lines th.right { text-align: right; }
.table th.center, .doc-lines th.center { text-align: center; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table .acciones { text-align: right; white-space: nowrap; width: 1%; }
.table .acciones .btn-ghost { color: var(--text-2); }
.table .acciones .btn-ghost:hover { background: var(--primary-soft); color: var(--primary-text); }
.table .acciones form[data-confirm] .btn-ghost:hover { background: var(--danger-soft); }
@media (hover: hover) {
  .table tbody tr .acciones .btn { opacity: .65; transition: opacity .12s, background .15s; }
  .table tbody tr:hover .acciones .btn, .table .acciones .btn:focus-visible { opacity: 1; }
}
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table-compact td, .table-compact th { padding: .5rem .75rem; }
.cell-main { font-weight: 650; color: var(--text); }
a.cell-main { display: inline-block; }
a.cell-main:hover, a.cell-link:hover { color: var(--primary-text); text-decoration: underline; }
a.cell-link { color: inherit; }
.cell-stack { min-width: 0; }  /* título + subtítulo de una celda, siempre juntos */
.cell-sub { font-size: .76rem; color: var(--muted); }
.table .cell-sub { color: color-mix(in srgb, var(--muted) 70%, var(--text)); }  /* más legible sobre blanco */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1.15rem;
  border-top: 1px solid var(--border); flex-wrap: wrap; font-size: .82rem; color: var(--text-2); }
.pagination .pages { display: flex; gap: .3rem; align-items: center; }
.pagination .pages .btn { min-width: 32px; padding: 0 .55rem; font-variant-numeric: tabular-nums; }
.pagination .pages .btn-primary { cursor: default; pointer-events: none; }
.pagination .pages .gap { padding: 0 .25rem; color: var(--muted); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.4rem; display: block; margin-bottom: .6rem; color: var(--border-strong); }
.empty h3 { color: var(--text); margin-bottom: .3rem; }
.htmx-request .table-wrap, .htmx-request.table-wrap { opacity: .55; transition: opacity .2s; }
.list-row { display: flex; align-items: center; gap: .8rem; padding: .7rem 1.15rem; border-bottom: 1px solid var(--border); color: inherit; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); color: inherit; }
.list-row .grow { flex: 1; min-width: 0; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field label, .label { font-size: .8rem; font-weight: 650; color: var(--text-2); }
.field .req { color: var(--danger); }
.help { font-size: .74rem; color: var(--muted); }
.error, .errorlist { color: var(--danger); font-size: .76rem; font-weight: 600; margin: 0; padding: 0; list-style: none; }
.form-control, .form-select {
  width: 100%; height: 42px; padding: 0 .85rem; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: .9rem; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea.form-control { height: auto; padding: .65rem .85rem; resize: vertical; min-height: 84px; }
.form-control:focus, .form-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.form-control::placeholder { color: var(--muted); }
.form-select { appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%238a94a8'%3E%3Cpath d='M1.6 5.2a.75.75 0 0 1 1.06 0L8 10.5l5.34-5.3a.75.75 0 1 1 1.06 1.06l-5.87 5.83a.75.75 0 0 1-1.06 0L1.6 6.27a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; }
select[multiple].form-select { height: auto; min-height: 120px; padding: .5rem; background-image: none; }
.form-control.is-invalid, .is-invalid .form-control, .is-invalid .form-select { border-color: var(--danger); }
input[type=color].form-control { padding: .25rem; width: 64px; }
.form-file { padding: .45rem .6rem; }
.input-group { display: flex; align-items: stretch; }
.input-group > .form-control, .input-group > .form-select { border-radius: 11px 0 0 11px; }
.input-group > .btn { border-radius: 0 11px 11px 0; height: auto; }
.input-group-text { display: flex; align-items: center; padding: 0 .75rem; border: 1px solid var(--border-strong); border-right: 0;
  border-radius: 11px 0 0 11px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.input-group-text + .form-control { border-radius: 0 11px 11px 0; }
.switch { display: inline-flex; align-items: center; gap: .65rem; cursor: pointer; font-weight: 600; color: var(--text); font-size: .86rem; }
.switch-input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--border-strong); position: relative;
  cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch-input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch-input:checked { background: var(--primary); }
.switch-input:checked::after { transform: translateX(18px); }
.switch-input:focus-visible { box-shadow: var(--ring); outline: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.checks label { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px;
  font-weight: 600; cursor: pointer; font-size: .84rem; }
.checks label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.checks ul { list-style: none; padding: 0; margin: 0; display: contents; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem; }
.form-section-title { grid-column: span 12; font-size: .75rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); padding-top: .5rem; border-top: 1px dashed var(--border); margin-top: .25rem; }
.form-section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* Selector de imagen con vista previa (ImagenInput) */
.img-input { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.img-input-preview { display: flex; align-items: center; gap: .85rem; padding: .6rem; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface-2); }
.img-input-preview[hidden] { display: none; }
.img-input-thumb { width: 76px; height: 76px; flex: none; object-fit: contain; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--border); transition: opacity .2s, filter .2s; }
.img-input-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.img-input-name { font-size: .84rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-input.is-eliminada .img-input-thumb { opacity: .35; filter: grayscale(1); }
.img-input.is-eliminada .img-input-name { text-decoration: line-through; color: var(--muted); }

/* ---------- Alertas y toasts ---------- */
.alert { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; font-size: .86rem; margin-bottom: 1rem;
  border: 1px solid transparent; }
.alert i { font-size: 1.05rem; margin-top: .05rem; }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert b, .alert strong { color: inherit; }
.toasts { position: fixed; top: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .6rem; width: min(380px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 13px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: .86rem; animation: toast-in .25s ease; }
.toast .t-icon { font-size: 1.1rem; }
.toast.success .t-icon { color: var(--success); } .toast.danger .t-icon { color: var(--danger); }
.toast.warning .t-icon { color: var(--warning); } .toast.info .t-icon { color: var(--info); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font-size: 1rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Dropdown / modal ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: .4rem; z-index: 80; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: 9px;
  color: var(--text); font: inherit; font-size: .86rem; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: .35rem 0; }
.dropdown-head { padding: .6rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.modal-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(2, 6, 23, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 2rem); overflow: auto; background: var(--surface); border-radius: 18px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: toast-in .2s ease; }
.modal-lg { width: min(860px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-body { padding: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

.menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.menu-list li { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.menu-list .ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--text-2); }

/* ---------- Paleta de comandos ---------- */
.cmdk { position: fixed; inset: 0; z-index: 180; background: rgba(2, 6, 23, .55); backdrop-filter: blur(4px); display: flex;
  justify-content: center; align-items: flex-start; padding: 12vh 1rem 1rem; }
.cmdk-box { width: min(640px, 100%); background: var(--surface); border-radius: 18px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk-input { display: flex; align-items: center; gap: .7rem; padding: 0 1.1rem; border-bottom: 1px solid var(--border); }
.cmdk-input input { flex: 1; height: 56px; border: 0; background: transparent; font: inherit; font-size: 1rem; color: var(--text); outline: none; }
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: .4rem; }
.cmdk-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: 10px; color: var(--text); }
.cmdk-item i { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--primary-soft); color: var(--text); }
.cmdk-item .tipo { margin-left: auto; font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* ---------- Avatares, tabs, progreso ---------- */
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 750; font-size: .8rem; color: #fff; flex: none;
  background: var(--primary); }
.avatar-sm { width: 28px; height: 28px; border-radius: 8px; font-size: .68rem; }
.avatar-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.1rem; }
.user-btn { display: flex; align-items: center; gap: .6rem; padding: .25rem .4rem .25rem .25rem; border-radius: 12px; border: 1px solid transparent;
  background: none; cursor: pointer; font: inherit; color: var(--text); }
.user-btn:hover { background: var(--surface); border-color: var(--border); }
.user-btn .meta { text-align: left; line-height: 1.2; }
.user-btn .meta small { display: block; color: var(--muted); font-size: .72rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: .7rem .95rem; color: var(--text-2); font-weight: 650; border: 0; background: none; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: .4rem; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs .active { color: var(--primary-text); border-bottom-color: var(--primary); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.progress.warn > span { background: #f59e0b; } .progress.full > span { background: #ef4444; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; font-size: .86rem; margin: 0; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.totals { margin-left: auto; width: min(340px, 100%); font-size: .9rem; }
.totals div { display: flex; justify-content: space-between; padding: .35rem 0; }
.totals .grand { font-size: 1.15rem; font-weight: 800; border-top: 2px solid var(--border); margin-top: .35rem; padding-top: .6rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: .75rem; padding: .6rem 0; position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 42px; bottom: -6px; width: 2px; background: var(--border); }
.timeline .ti { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.timeline .tc { min-width: 0; font-size: .84rem; }
.timeline .tc small { display: block; color: var(--muted); font-size: .74rem; }

/* ---------- Módulos / planes ---------- */
.mod-card { display: flex; flex-direction: column; gap: .75rem; padding: 1.15rem; height: 100%; }
.mod-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 1.3rem; color: #fff; flex: none; }
.mod-card ul, .plan-card ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; font-size: .84rem; color: var(--text-2); }
.mod-card li::before, .plan-card li::before { content: "\F26A"; font-family: "bootstrap-icons"; color: var(--success); margin-right: .45rem; }
.mod-card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .75rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
.price { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.price small { font-size: .78rem; color: var(--muted); font-weight: 600; }
.plan-card { padding: 1.4rem; display: flex; flex-direction: column; gap: 1rem; position: relative; height: 100%; }
.plan-card.destacado { border: 2px solid var(--primary); box-shadow: 0 24px 50px -28px rgba(79, 70, 229, .7); }
.plan-card .ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; padding: .2rem .8rem; border-radius: 99px; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.plan-card .big-price { font-size: 2.2rem; font-weight: 820; letter-spacing: -.03em; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-3); gap: 2px; }
.segmented a, .segmented button { padding: .45rem .9rem; border-radius: 9px; font-weight: 650; color: var(--text-2); border: 0; background: none; cursor: pointer; font: inherit; }
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Integraciones ---------- */
.int-card { padding: 1.15rem; display: flex; flex-direction: column; gap: .7rem; height: 100%; }
.int-card .head { display: flex; gap: .8rem; align-items: center; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: start; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban-col header { padding: .85rem 1rem; display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.kanban-list { padding: .65rem; display: flex; flex-direction: column; gap: .6rem; overflow-y: auto; min-height: 120px; flex: 1; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .85rem; cursor: grab;
  box-shadow: var(--shadow-sm); border-left: 3px solid var(--etapa, var(--primary)); }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.sortable-ghost { opacity: .4; }
.kanban-card.sortable-chosen { cursor: grabbing; }

/* ---------- Chat WhatsApp ---------- */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - var(--topbar-h) - 3rem); min-height: 520px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .items { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); color: inherit; align-items: flex-start; }
.conv:hover { background: var(--surface-2); color: inherit; }
.conv.active { background: var(--primary-soft); }
.conv .grow { flex: 1; min-width: 0; }
.unread { min-width: 20px; height: 20px; border-radius: 99px; background: #16a34a; color: #fff; font-size: .68rem; font-weight: 750; display: grid; place-items: center; padding: 0 5px; }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-body { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .5rem;
  background-color: var(--surface-2);
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--border) 70%, transparent) 1px, transparent 0); background-size: 22px 22px; }
.bubble { max-width: min(560px, 82%); padding: .55rem .8rem .4rem; border-radius: 14px; font-size: .88rem; box-shadow: var(--shadow-sm);
  white-space: pre-wrap; overflow-wrap: anywhere; position: relative; }
.bubble.in { align-self: flex-start; background: var(--surface); border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #dcf8c6; color: #0f2a12; border-top-right-radius: 4px; }
:root[data-theme="dark"] .bubble.out { background: #134d37; color: #e7fbe9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble.out { background: #134d37; color: #e7fbe9; } }
.bubble .meta { display: flex; gap: .35rem; justify-content: flex-end; align-items: center; font-size: .68rem; opacity: .65; margin-top: .15rem; }
.bubble .ia { font-weight: 750; color: #7c3aed; }
.chat-input { border-top: 1px solid var(--border); padding: .75rem; display: flex; gap: .5rem; align-items: flex-end; background: var(--surface); }
.chat-input textarea { min-height: 44px; max-height: 160px; height: 44px; resize: none; }
.chat-day { align-self: center; font-size: .72rem; background: var(--surface); padding: .2rem .7rem; border-radius: 99px; color: var(--muted); box-shadow: var(--shadow-sm); }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 410px; gap: 1rem; height: calc(100vh - var(--topbar-h) - 3rem); min-height: 560px; }
.pos-catalog { display: flex; flex-direction: column; min-height: 0; }
.pos-products { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .65rem; padding: .25rem; align-content: start; }
/* Ficha compacta: miniatura cuadrada junto al nombre y, debajo, stock y precio en una sola línea */
.pos-prod { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .6rem; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: .5rem .6rem; font: inherit; color: var(--text);
  transition: border-color .15s, transform .1s, box-shadow .15s; }
.pos-prod:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.pos-prod:active { transform: scale(.98); }
.pos-prod .thumb { width: 44px; height: 44px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; font-size: .95rem; font-weight: 800; color: #fff; }
.pos-prod .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pos-prod .name { font-weight: 650; font-size: .8rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pos-prod .meta { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.pos-prod .p { font-weight: 800; color: var(--primary-text); }
.pos-prod .s { font-size: .7rem; color: var(--muted); }
.pos-prod.agotado { opacity: .55; }
.pos-cart { display: flex; flex-direction: column; min-height: 0; }
.pos-cart .items { flex: 1; overflow-y: auto; }
.cart-item { display: grid; grid-template-columns: 1fr auto; gap: .35rem .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.qty button { width: 30px; height: 30px; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 1rem; }
.qty input { width: 52px; height: 30px; border: 0; text-align: center; background: var(--surface); color: var(--text); font: inherit; font-weight: 700; }
.disc-edit { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.disc-edit input { width: 110px; height: 34px; }
.segmented.sm { padding: 2px; border-radius: 10px; }
.segmented.sm button { padding: .25rem .65rem; font-size: .8rem; }
.pos-total { padding: 1rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.pos-total .grand { font-size: 1.7rem; font-weight: 850; letter-spacing: -.02em; }
/* Cobro: total, medios de pago, teclado y resultado */
.cobro { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.cobro-total { padding: 1rem 1.15rem; border-radius: 14px; background: var(--primary-soft); color: var(--primary-text); }
.cobro-total .monto { font-size: 2.2rem; font-weight: 850; letter-spacing: -.02em; line-height: 1.1; color: var(--text); margin: .1rem 0 .2rem; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.pay-methods button { position: relative; padding: .7rem .4rem .6rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font: inherit; font-weight: 650; font-size: .8rem; line-height: 1.2; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: .4rem;
  transition: border-color .15s, background .15s, box-shadow .15s; }
.pay-methods button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pay-methods button:focus-visible { outline: none; box-shadow: var(--ring); }
.pay-methods button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); box-shadow: 0 0 0 1px var(--primary) inset; }
.pay-methods button.active::after { content: "\F26A"; font-family: "bootstrap-icons"; position: absolute; top: 6px; right: 8px; font-size: .95rem; color: var(--primary); }
.pay-ico { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 1.15rem; color: var(--mc, var(--primary));
  background: color-mix(in srgb, var(--mc, var(--primary)) 14%, transparent); }
.cobro-input { height: 58px; font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cobro-chips { gap: .35rem; }
.cobro-chips .chip { padding: .42rem .85rem; font-weight: 700; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.keypad button { height: 50px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 1.15rem; font-weight: 700;
  cursor: pointer; color: var(--text); transition: background .1s, transform .05s; }
.keypad button:hover { background: var(--surface-2); border-color: var(--border-strong); }
.keypad button:active { transform: scale(.97); background: var(--primary-soft); }
.cobro-resultado { display: flex; align-items: center; justify-content: space-between; padding: .65rem .95rem; border-radius: 12px; font-weight: 700; }
.cobro-resultado b { font-size: 1.5rem; }
.cobro-resultado.ok { background: var(--success-soft); color: var(--success); }
.cobro-resultado.falta { background: var(--danger-soft); color: var(--danger); }
.cobro-medio { display: flex; flex-direction: column; gap: .8rem; padding: 1.1rem; border: 1px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2); }
.cobro-medio .monto { font-size: 2rem; font-weight: 850; letter-spacing: -.02em; }
.pago-row { display: grid; grid-template-columns: 1fr 110px auto auto; gap: .4rem; align-items: center; }
.mobile-cart-btn { display: none; }

/* ---------- Documento (venta/compra) ---------- */
.doc-lines { width: 100%; border-collapse: collapse; }
.doc-lines th { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: .5rem .4rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.doc-lines td { padding: .4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc-lines .form-control, .doc-lines .form-select { height: 38px; font-size: .85rem; padding: 0 .55rem; }
.autocomplete { position: relative; }
.ac-list { position: absolute; z-index: 70; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; padding: .3rem; min-width: 280px; }
.ac-item { display: flex; justify-content: space-between; gap: .75rem; padding: .5rem .65rem; border-radius: 8px; cursor: pointer; font-size: .84rem; }
.ac-item:hover, .ac-item.sel { background: var(--primary-soft); }
.ac-item .cell-prod { flex: 1; }
/* Selector con búsqueda (select[data-buscar], ver erpgest.js) */
.sel-buscar { position: relative; min-width: 0; }
.sel-buscar > select { display: none; }
.sel-buscar-boton { display: block; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-buscar-boton:disabled { opacity: .6; cursor: not-allowed; }
.sel-buscar-panel { display: flex; flex-direction: column; gap: .3rem; overflow: hidden; max-height: 340px; }
.sel-buscar-panel[hidden] { display: none; }
.sel-buscar-panel [role="listbox"] { overflow-y: auto; min-height: 0; }
.sel-buscar-filtro { flex: none; height: 38px; border-radius: 9px; }
.sel-buscar-panel .ac-item[aria-selected="true"] { font-weight: 700; color: var(--primary-text); }
.sel-buscar-nota { padding: .45rem .65rem; }
/* Miniatura de producto (listas y buscadores): foto cuadrada o, sin foto, las iniciales */
.cell-prod { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.mini-thumb { width: 36px; height: 36px; flex: none; overflow: hidden; border-radius: 9px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-text); font-size: .72rem; font-weight: 800; }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-thumb.sm { width: 30px; height: 30px; border-radius: 8px; font-size: .65rem; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-brand { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -10%, #6366f1 0%, transparent 55%), radial-gradient(900px 600px at 110% 110%, #a855f7 0%, transparent 50%), #0f1430; }
.auth-brand h1 { font-size: 2.4rem; font-weight: 820; letter-spacing: -.03em; max-width: 520px; }
.auth-brand .feat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; max-width: 560px; }
.auth-brand .feat div { padding: .9rem; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); font-size: .85rem; }
.auth-brand .feat i { display: block; font-size: 1.2rem; margin-bottom: .3rem; color: #c4b5fd; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--surface); }
.auth-card { width: min(410px, 100%); }

/* ---------- Impresión ---------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .toasts { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .col-xl-12 { grid-column: span 12; }
  .pos { grid-template-columns: 1fr 360px; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .backdrop { display: block; }
  .main { margin-left: 0; }
  .search-trigger { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .col-lg-12 { grid-column: span 12; }
  .col-lg-6 { grid-column: span 6; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.has-chat .inbox-list { display: none; }
  .inbox:not(.has-chat) .chat { display: none; }
  .pos { grid-template-columns: 1fr; height: auto; }
  .pos-catalog { min-height: 60vh; }
  .pos-cart { position: fixed; inset: auto 0 0 0; z-index: 90; max-height: 88vh; border-radius: 20px 20px 0 0; transform: translateY(105%);
    transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .pos-cart.open { transform: none; }
  .mobile-cart-btn { display: flex; position: fixed; left: 1rem; right: 1rem; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 85;
    height: 54px; border-radius: 16px; align-items: center; justify-content: space-between; padding: 0 1.1rem; font-weight: 750; font-size: 1rem; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}
@media (max-width: 768px) {
  body { font-size: 14px; }
  .content { padding: 1rem 1rem calc(88px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 1rem; }
  .user-btn .meta { display: none; }
  .grid > [class*="col-"] { grid-column: span 12; }
  .form-grid > .field { grid-column: span 12 !important; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1 1 auto; }
  h1 { font-size: 1.25rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .kpi { padding: .85rem; gap: .6rem; flex-direction: column; }
  .kpi-icon { width: 36px; height: 36px; font-size: 1rem; }
  .kpi-value { font-size: 1.15rem; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar .form-select, .toolbar input[type=date] { flex: 1 1 140px; }
  .toolbar .date-field { flex: 1 1 150px; }
  .toolbar .date-field input[type=date] { flex: 1; }
  /* tablas responsivas → tarjetas */
  .table-responsive thead { display: none; }
  .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
  .table-responsive tr { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
  .table-responsive td { border: 0; padding: .2rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table-responsive td::before { content: attr(data-label); font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
    letter-spacing: .04em; text-align: left; flex: none; }
  .table-responsive td:first-child { justify-content: flex-start; text-align: left; }
  .table-responsive td:first-child::before { display: none; }
  .table-responsive td.acciones { justify-content: flex-end; padding-top: .5rem; width: 100%; }
  .table-responsive td.acciones::before { display: none; }
  .bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; z-index: 70; height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 .5rem env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); justify-content: space-around; align-items: center; }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .66rem; font-weight: 650;
    color: var(--muted); padding: .35rem .6rem; border: 0; background: none; font-family: inherit; cursor: pointer; min-width: 58px; }
  .bottom-nav i { font-size: 1.25rem; }
  .bottom-nav .active { color: var(--primary-text); }
  .bottom-nav .fab { width: 50px; height: 50px; border-radius: 16px; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
    display: grid; place-items: center; margin-top: -26px; box-shadow: 0 12px 24px -10px rgba(124, 58, 237, .8); padding: 0; min-width: 0; }
  .bottom-nav .fab i { font-size: 1.35rem; }
  .doc-lines thead { display: none; }
  .doc-lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
  .doc-lines td { border: 0; padding: 0; }
  .doc-lines td.desc { grid-column: span 2; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .dl { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
  .auth-form { align-items: flex-start; padding-top: 3rem; }
  .pay-methods { grid-template-columns: repeat(2, 1fr); }
  .cobro { grid-template-columns: 1fr; }
  .pago-row { grid-template-columns: 1fr 96px auto auto; }
  .modal-footer { position: sticky; bottom: 0; background: var(--surface); }  /* los botones siempre visibles al desplazar */
}

/* Etiquetas de acciones por fila: solo icono en anchos intermedios */
@media (max-width: 1400px) and (min-width: 769px) { .hide-sm { display: none; } }
