/* COVEXS — herramienta operativa de inventario/POS.
   Mundo visual "Carbón & Azul": sidebar carbón casi-negro, superficie clara con
   mucho aire, un acento azul eléctrico y semántica calma. Elegante, no saturado.
   Números tabulares para precios/stock; la marca vive en los detalles. */
:root {
  /* Superficie clara (área de trabajo) */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e7e9ef;
  --border-strong: #d9dce4;
  --text: #15171c;
  --muted: #6b7280;
  --muted-2: #9aa0ac;

  /* Acento azul eléctrico */
  --brand: #2f6bff;
  --brand-ink: #1f4fd6;
  --brand-wash: #eaf0ff;

  /* Carbón (sidebar y superficies oscuras) */
  --ink: #16181d;
  --ink-2: #1d2027;
  --ink-line: #2a2e37;
  --ink-text: #e7e9ee;
  --ink-muted: #9298a6;

  /* Semántica */
  --ok: #157f4a;
  --warn: #b45309;
  --danger: #d23f31;
  --low-bg: #fff4e5;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(18,24,40,.05), 0 1px 3px rgba(18,24,40,.04);
  --shadow-md: 0 4px 14px rgba(18,24,40,.07), 0 1px 3px rgba(18,24,40,.05);
  --shadow-lg: 0 18px 50px rgba(18,24,40,.14);
  --ease: cubic-bezier(.22,.61,.36,1);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); letter-spacing: -0.01em; }

/* Superficies de navegador: que todo lleve la marca, no los defaults del browser. */
::selection { background: var(--brand-wash); color: var(--brand-ink); }
* { scrollbar-width: thin; scrollbar-color: #c7ccd6 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cad0da; border: 3px solid transparent; background-clip: padding-box; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #b2b9c6; background-clip: padding-box; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin: 4px 0 0; }

/* ── Botones ── */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; transition: background .12s, border-color .12s;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(31,79,214,.35), 0 6px 16px rgba(47,107,255,.22); }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; padding: 5px 8px; }
.btn-danger:hover { background: #fdecea; }

/* ── Login ── */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -10%, #eef2fb 0%, transparent 60%),
    var(--bg);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 40px 34px; width: 100%; max-width: 372px;
  display: flex; flex-direction: column; gap: 6px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-box h1 { margin: 16px 0 0; font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.login-box .muted { margin: 2px 0 16px; font-size: 14px; }
.login-box label { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.login-box input { padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 10px; font: inherit; background: var(--surface); }
.login-box .btn { margin-top: 20px; }
/* Marca: el símbolo real de covexs (SVG), hereda color por currentColor. */
.login-logo {
  width: 56px; height: 56px; margin: 0 auto; color: var(--ink);
  display: grid; place-items: center;
}
.login-logo svg, .login-logo .mark { width: 100%; height: 100%; }
.login-logo.sm { width: 26px; height: 26px; margin: 0; }

/* ── App shell ── */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink); color: var(--ink-text);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 20px;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; color: #fff; padding: 4px 6px 0; }
.sidebar-brand .login-logo.sm { color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar nav::before { content: "MENÚ"; font-size: 10px; font-weight: 700; letter-spacing: .12em; color: var(--ink-muted); padding: 4px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: var(--ink-muted);
  font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--ink-2); color: var(--ink-text); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(47,107,255,.32); }
.nav-item.disabled { opacity: .4; cursor: not-allowed; }
.nav-ic { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav-item.active .nav-ic { opacity: 1; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding-top: 14px; border-top: 1px solid var(--ink-line); }

/* ── Menú colapsable ── */
.sidebar-brand { justify-content: space-between; }
.sidebar-collapse, .sidebar-open {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--ink-muted);
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.sidebar-collapse:hover { background: var(--ink-2); color: #fff; }
.sidebar-open { color: var(--muted); }
.sidebar-open:hover { background: var(--surface-2); color: var(--text); }

/* Al colapsar: el sidebar se oculta y el trabajo ocupa todo el ancho. */
.app.sidebar-collapsed { grid-template-columns: 1fr; }
.app.sidebar-collapsed .sidebar { display: none; }

/* Botón flotante para reabrir: fijo arriba a la izquierda, solo visible al colapsar. */
.sidebar-open {
  position: fixed; top: 16px; left: 16px; z-index: 40;
  width: 38px; height: 38px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.app.sidebar-collapsed .work { padding-top: 64px; }

.work { padding: 32px 36px 40px; overflow: auto; }

/* ── Encabezado de vista ── */
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.view-head h1 { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -.025em; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.search { padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: 10px; font: inherit; min-width: 240px; background: var(--surface); box-shadow: var(--shadow-sm); }

/* ── Tabla de catálogo ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.catalog { width: 100%; border-collapse: collapse; font-size: 14px; }
table.catalog th, table.catalog td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
table.catalog th { background: var(--surface-2); font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; }
table.catalog tr:last-child td { border-bottom: none; }
table.catalog tbody tr:hover { background: #fafbfc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.prod-name { font-weight: 600; }
.cat-tag { font-size: 12px; color: var(--muted); }
.stock-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.stock-chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); }
.stock-chip.low { background: var(--low-bg); color: var(--warn); font-weight: 700; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.badge-low { font-size: 11px; font-weight: 700; color: var(--warn); background: var(--low-bg); padding: 2px 7px; border-radius: 999px; margin-left: 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.count-note { font-size: 14px; font-weight: 400; }

/* ── Selector de modo de vista ── */
.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--surface); }
.view-switch button {
  border: none; background: transparent; padding: 8px 10px; cursor: pointer;
  color: var(--muted); display: grid; place-items: center; transition: background .14s, color .14s;
}
.view-switch button + button { border-left: 1px solid var(--border); }
.view-switch button:hover { background: var(--surface-2); color: var(--text); }
.view-switch button.active { background: var(--brand-wash); color: var(--brand-ink); }

/* ── Miniaturas en tabla (vista lista) ── */
.thumb-cell { width: 54px; }
.thumb {
  width: 40px; height: 40px; border-radius: 9px; object-fit: cover;
  display: grid; place-items: center; background: var(--surface-2); font-size: 20px;
}
.thumb-emoji { line-height: 40px; text-align: center; }

/* ── Cuadrícula de tarjetas ── */
.pgrid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.pcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; display: flex; flex-direction: column;
  animation: row-in .42s cubic-bezier(.16,.84,.44,1) both;
  animation-delay: calc(var(--i, 0) * 30ms);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.pcard:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(20,30,60,.1); border-color: #d3d9e6; }
.pcard-media {
  position: relative; aspect-ratio: 16/10; display: grid; place-items: center;
  background: linear-gradient(135deg, #f3f5f9, #e9edf6);
}
.pcard-media img { width: 100%; height: 100%; object-fit: cover; }
.pcard-emoji { font-size: 52px; }
.pcard-badge { position: absolute; top: 10px; left: 10px; }
.pcard-body { padding: 12px 14px 4px; flex: 1; }
.pcard-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.pcard-cat { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pcard-foot { display: flex; align-items: baseline; justify-content: space-between; margin-top: 10px; }
.pcard-price { font-weight: 700; font-size: 17px; color: var(--brand-ink); }
.pcard-stock { font-size: 12px; color: var(--muted); }
.pcard-actions { display: flex; gap: 6px; padding: 10px 14px 14px; }
.pcard-actions .btn { flex: 1; }

/* ── Modal producto ── */
dialog#product-modal {
  border: none; border-radius: 14px; padding: 26px; width: min(560px, 92vw);
  box-shadow: 0 20px 60px rgba(20,30,60,.2);
}
dialog::backdrop { background: rgba(15,20,35,.45); }
#product-modal h2 { margin: 0 0 18px; font-size: 19px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label, .stock-inputs label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select, .stock-inputs input { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); }
.stock-inputs { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stock-inputs .section-label { grid-column: 1/-1; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: -4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ══════════════ Barra inferior + hoja "Más" (teléfono) ══════════════
   En escritorio NO existen: el sidebar manda. Se encienden a ≤720px.
   La tabbar vive fija abajo, respeta el notch (safe-area) y da objetivos
   táctiles grandes. "Más" abre una hoja con el resto de secciones. */
.tabbar, .more-sheet, .sheet-backdrop { display: none; }

@media (max-width: 720px) {
  /* Teléfono: el sidebar se retira; manda la barra inferior. */
  .app { grid-template-columns: 1fr; }
  .sidebar, .sidebar-open { display: none !important; }
  .app.sidebar-collapsed .work { padding-top: 20px; }

  .work { padding: 18px 16px calc(78px + env(safe-area-inset-bottom)); }
  .view-head h1 { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }

  /* Barra inferior fija */
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--ink); border-top: 1px solid var(--ink-line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 20px rgba(0,0,0,.18);
  }
  .tab-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 7px 2px; border: none; background: none; cursor: pointer;
    color: var(--ink-muted); font: inherit; font-size: 10.5px; font-weight: 600;
    letter-spacing: -0.01em; border-radius: 10px; min-height: 52px;
    transition: color .14s ease, background .14s ease;
  }
  .tab-item span { line-height: 1; }
  .tab-ic { width: 22px; height: 22px; opacity: .9; }
  .tab-item.active { color: #fff; }
  .tab-item.active .tab-ic { opacity: 1; }
  .tab-item.active::before {
    content: ""; position: absolute; top: 2px; width: 30px; height: 3px;
    border-radius: 999px; background: var(--brand); box-shadow: 0 0 10px rgba(47,107,255,.6);
  }
  .tab-item { position: relative; }
  .tab-item:active { background: var(--ink-2); }

  /* Hoja "Más": sube desde abajo con backdrop. */
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 60;
    background: rgba(10,12,18,.5); opacity: 0; transition: opacity .2s ease;
  }
  .sheet-backdrop.show { opacity: 1; }
  .more-sheet {
    display: flex; flex-direction: column; gap: 14px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: var(--surface); border-radius: 20px 20px 0 0;
    padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg);
    transform: translateY(100%); transition: transform .26s var(--ease);
  }
  .more-sheet.show { transform: translateY(0); }
  .more-grabber { width: 40px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 2px auto 2px; }
  .more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .more-cell {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 16px 8px; border: 1px solid var(--border); border-radius: 14px;
    background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
    font-size: 12.5px; font-weight: 600; text-align: center;
  }
  .more-cell:active { background: var(--surface-2); }
  .more-cell.active { border-color: var(--brand); background: var(--brand-wash); color: var(--brand-ink); }
  .more-cell svg { width: 24px; height: 24px; }
  .more-logout { color: var(--danger); }
}

/* ════════════════ Movimiento: elegante, mínimo, con propósito ════════════════ */

/* Entrada del login: el recuadro surge con calma. */
.login-box { animation: rise .55s cubic-bezier(.16,.84,.44,1) both; }
.login-logo { animation: pop .6s cubic-bezier(.16,.84,.44,1) .08s both; }

/* Entrada de la app (tras login): fundido ascendente del área de trabajo. */
.app:not([hidden]) .work > * { animation: rise .5s cubic-bezier(.16,.84,.44,1) both; }
.sidebar { animation: slide-in .5s cubic-bezier(.16,.84,.44,1) both; }

/* Filas del catálogo: cascada escalonada muy sutil (la variable --i la fija el JS). */
table.catalog tbody tr {
  animation: row-in .42s cubic-bezier(.16,.84,.44,1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

/* Hover de fila: deslizamiento mínimo, no rebote. */
table.catalog tbody tr { transition: background .14s ease, box-shadow .14s ease; }

/* Botones: respuesta táctil al pulsar. */
.btn { transition: background .14s ease, border-color .14s ease, transform .08s ease; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { box-shadow: 0 1px 2px rgba(31,79,214,.35), 0 6px 16px rgba(47,107,255,.22); }

/* Chips de navegación y acento: transición suave. */
.nav-item { transition: background .14s ease, color .14s ease; }

/* Stock bajo: latido discreto que llama la atención sin gritar. */
.badge-low { animation: pulse-soft 2.4s ease-in-out infinite; }

/* Modal: apertura con escala + fundido del backdrop. */
dialog#product-modal[open] { animation: modal-in .32s cubic-bezier(.16,.84,.44,1) both; }
dialog#product-modal::backdrop { animation: fade .3s ease both; }

/* Buscador y campos: foco con anillo de marca. */
.search, .login-box input, .form-grid input, .form-grid select {
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search:focus, .login-box input:focus, .form-grid input:focus, .form-grid select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47,107,255,.16);
}

.btn-lg { padding: 13px 16px; font-size: 16px; }

/* ══════════════════ Usuarios y roles ══════════════════ */
.user-chip { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-chip-name { font-weight: 600; font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-role { font-size: 11px; color: var(--ink-muted); }
.sidebar-foot .btn-ghost { background: var(--ink-2); border-color: var(--ink-line); color: var(--ink-text); box-shadow: none; }
.sidebar-foot .btn-ghost:hover { background: var(--ink-line); border-color: #3a3f4a; color: #fff; }
.role-chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; display: inline-block; }
.role-owner { background: #eef0ff; color: var(--brand-ink); }
.role-admin { background: #e7f6ee; color: var(--ok); }
.role-cashier { background: var(--surface-2); color: var(--muted); }
.badge-you { font-size: 10px; font-weight: 700; background: var(--brand); color: #fff; border-radius: 5px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.dot-ok, .dot-off { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--ok); }
.dot-off { background: #c3c8d1; }
.row-inactive { opacity: .55; }
.u-active { display: flex; align-items: center; gap: 8px; flex-direction: row !important; font-size: 14px; }
.u-active input { width: auto; }
#user-modal { border: none; border-radius: var(--radius); padding: 22px; width: 460px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.22); animation: modal-in .24s ease both; }
#user-modal::backdrop { background: rgba(15,20,35,.45); animation: fade .25s ease both; }
#user-modal h2 { margin: 0 0 14px; }

/* ══════════════════ Inventario ══════════════════ */
.inv-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.inv-table th, .inv-table td { white-space: nowrap; }
.stock-btn {
  font: inherit; font-variant-numeric: tabular-nums; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 7px; padding: 5px 12px; min-width: 52px; cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}
.stock-btn:hover { border-color: var(--brand); background: var(--surface-2); }
.stock-btn:active { transform: scale(.95); }
.stock-btn.low { background: var(--low-bg); color: var(--warn); border-color: #f0c98a; }

.inv-moves { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; animation: slide-in .26s ease both; position: sticky; top: 0; }
.inv-moves h2 { font-size: 15px; margin: 0 0 10px; }
.moves-list { display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow-y: auto; }
.move-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--surface-2); animation: row-in .2s ease both; }
.move-type { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.move-in { background: #e7f6ee; color: var(--ok); }
.move-out, .move-sale { background: #fdecea; color: var(--danger); }
.move-transfer { background: #eaf0ff; color: var(--brand-ink); }
.move-info { display: flex; flex-direction: column; min-width: 0; }
.move-prod { font-weight: 600; font-size: 13px; }
.move-meta { font-size: 11px; color: var(--muted); }
.move-qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.move-qty.in { color: var(--ok); }
.move-qty.out { color: var(--danger); }

/* Selector segmentado (Entrada/Salida/Fijar) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: 6px 0 14px; }
.seg button { font: inherit; border: none; background: var(--surface); color: var(--muted); padding: 8px 16px; cursor: pointer; border-right: 1px solid var(--border); transition: background .12s, color .12s; }
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--brand); color: #fff; font-weight: 600; }

#inv-modal { border: none; border-radius: var(--radius); padding: 22px; width: 440px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.22); animation: modal-in .24s ease both; }
#inv-modal::backdrop { background: rgba(15,20,35,.45); animation: fade .25s ease both; }
#inv-modal h2 { margin: 0 0 4px; }

@media (max-width: 860px) { .inv-layout { grid-template-columns: 1fr; } .inv-moves { position: static; } }

/* ══════════════════ POS (Vender) ══════════════════ */
.pos {
  display: grid; grid-template-columns: 1fr 360px; gap: 18px;
  align-items: start; height: calc(100vh - 48px);
}
.pos-catalog { min-width: 0; display: flex; flex-direction: column; height: 100%; }
.pos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; overflow-y: auto; padding: 2px 2px 20px; flex: 1;
}
.pos-item {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; position: relative; font: inherit; color: var(--text);
  transition: border-color .12s, box-shadow .12s, transform .08s;
  animation: pop .22s ease both; animation-delay: calc(var(--i) * 18ms);
}
.pos-item:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(47,107,255,.1); }
.pos-item:active { transform: scale(.97); }
.pos-item.out { opacity: .5; cursor: not-allowed; }
.pos-item-media { font-size: 32px; line-height: 1; height: 40px; display: flex; align-items: center; }
.pos-item-media img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.pos-item-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.pos-item-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: auto; }
.pos-item-price { font-weight: 700; color: var(--brand-ink); }
.pos-item-stock { font-size: 11px; color: var(--muted); }
.pos-item-qty {
  position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px;
  background: var(--brand); color: #fff; border-radius: 11px; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 6px;
  animation: pop .18s ease both;
}

/* Carrito */
.pos-cart {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  animation: slide-in .26s ease both;
}
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cart-head h2 { font-size: 16px; margin: 0; }
.cart-lines { flex: 1; overflow-y: auto; padding: 8px 12px; }
.cart-empty { color: var(--muted); text-align: center; padding: 32px 10px; font-size: 14px; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--surface-2); animation: row-in .2s ease both; }
.cart-line-info { display: flex; flex-direction: column; min-width: 0; }
.cart-line-name { font-weight: 600; font-size: 14px; }
.cart-line-price { font-size: 12px; color: var(--muted); }
.cart-line-total { font-weight: 700; min-width: 64px; text-align: right; }
.cart-qty { display: flex; align-items: center; gap: 2px; }
.cart-qty button {
  width: 26px; height: 26px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; font-size: 16px; font-weight: 700; cursor: pointer; color: var(--text);
  line-height: 1; transition: background .12s, border-color .12s;
}
.cart-qty button:hover { background: var(--surface-2); border-color: var(--brand); }
.cart-qty span { min-width: 24px; text-align: center; font-weight: 600; }
.cart-foot { border-top: 1px solid var(--border); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.cart-disc, .cart-pay { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.cart-disc input, .cart-pay select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); }
.cart-totals { font-size: 14px; }
.cart-totals > div { display: flex; justify-content: space-between; padding: 3px 0; }
.cart-total { font-size: 20px; font-weight: 800; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px !important; }

/* ── Recibo (ticket) ── */
#receipt-modal { border: none; border-radius: 14px; padding: 0; width: 340px; background: #f7f8fa; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: modal-in .24s ease both; }
#receipt-modal::backdrop { background: rgba(15,20,35,.45); animation: fade .25s ease both; }
/* La hoja del ticket: papel blanco con borde dentado arriba y abajo. */
.receipt {
  position: relative; margin: 16px; padding: 22px 20px 26px; background: #fff;
  font: 13px/1.5 "Courier New", ui-monospace, monospace; color: #1a1f2b;
  border-radius: 3px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.receipt::before, .receipt::after {
  content: ""; position: absolute; left: 0; right: 0; height: 8px;
  background-image: radial-gradient(circle at 5px 0, transparent 5px, #fff 5px);
  background-size: 12px 8px; background-repeat: repeat-x;
}
.receipt::before { top: -7px; transform: rotate(180deg); }
.receipt::after { bottom: -7px; }
.receipt-head { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.receipt-logo { max-width: 120px; max-height: 70px; object-fit: contain; margin-bottom: 8px; }
.receipt-biz { font-size: 17px; font-weight: 800; letter-spacing: .02em; font-family: system-ui, sans-serif; }
.receipt-sub { font-size: 11px; color: #555; }
.receipt-rule { border-top: 1px dashed #c5cad3; margin: 12px 0; }
.receipt-rule.dashed { border-top-style: dotted; }
.receipt-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.receipt-meta > div { display: flex; justify-content: space-between; gap: 12px; }
.receipt-meta span:first-child { color: #777; }
.receipt-meta span:last-child { text-align: right; font-weight: 600; }
.receipt-items { width: 100%; border-collapse: collapse; }
.receipt-items td { padding: 4px 0; vertical-align: top; }
.ri-qty { white-space: nowrap; padding-right: 8px !important; color: #555; }
.ri-name { width: 100%; }
.ri-unit { display: block; font-size: 10px; color: #999; }
.ri-total { text-align: right; white-space: nowrap; font-weight: 600; }
.receipt-totals { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.receipt-totals > div { display: flex; justify-content: space-between; }
.receipt-totals .disc { color: var(--danger, #c0392b); }
.receipt-total { font-weight: 800; font-size: 17px; margin-top: 4px; padding-top: 8px; border-top: 2px solid #1a1f2b; font-family: system-ui, sans-serif; }
.receipt-pay { text-align: center; margin-top: 12px; }
.receipt-chip { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .03em; font-family: system-ui, sans-serif; }
.receipt-chip.ok { background: #e7f6ed; color: #1b7a43; }
.receipt-chip.pend { background: #fdf0d9; color: #a66a00; }
.receipt-thanks { text-align: center; margin-top: 14px; font-size: 12px; color: #555; font-style: italic; }
#receipt-modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 16px 16px; }

/* La impresión del recibo se hace en un iframe aislado (ver printReceipt en
   pos.js) con su propio CSS, porque imprimir desde el <dialog> (top layer)
   dejaba la hoja casi en blanco. Aquí solo ocultamos lo que no debe salir si
   alguien hace Ctrl+P global por error. */
@media print {
  .no-print { display: none !important; }
}

@media (max-width: 860px) {
  .pos { grid-template-columns: 1fr; height: auto; }
  .pos-cart { height: auto; }
}

/* ── Reportes ── */
.rep-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.rep-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-sm);
  animation: rise .4s both; animation-delay: calc(var(--i) * .05s);
}
.rep-card-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.rep-card-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rep-card.profit .rep-card-value { color: var(--ok); }
.rep-card.warn { background: var(--low-bg); border-color: #f3d9a8; }
.rep-card.warn .rep-card-value { color: var(--warn); }

.rep-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.rep-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm); animation: fade .45s both;
}
.rep-panel h2 { font-size: 15px; font-weight: 600; margin: 0 0 16px; color: var(--text); letter-spacing: -0.01em; }

/* Mini gráfico de barras */
.rep-bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 18px; }
.rep-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.rep-bar {
  width: 100%; max-width: 44px; background: linear-gradient(180deg, var(--brand), #6f93ff);
  border-radius: 6px 6px 0 0; animation: grow-up .5s both; transform-origin: bottom;
  animation-delay: calc(var(--i) * .04s);
}
.rep-bar-val { font-size: 11px; color: #6b7280; font-variant-numeric: tabular-nums; margin-bottom: 4px; min-height: 14px; }
.rep-bar-day { font-size: 11px; color: #9ca3af; margin-top: 6px; text-transform: capitalize; }
@keyframes grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Top productos */
.rep-top { display: flex; flex-direction: column; gap: 10px; }
.rep-top-row { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 10px;
  animation: slide-in .35s both; animation-delay: calc(var(--i) * .05s); }
.rep-top-name { font-size: 13px; }
.rep-top-bar-wrap { background: #eef1f6; border-radius: 6px; height: 8px; overflow: hidden; }
.rep-top-bar { height: 100%; background: var(--brand); border-radius: 6px; animation: grow-x .5s both; transform-origin: left; }
.rep-top-qty { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Tabla sucursal */
.rep-table { width: 100%; border-collapse: collapse; }
.rep-table td { padding: 10px 6px; border-bottom: 1px solid #f0f2f5; font-size: 13px; }
.rep-table tr { animation: row-in .35s both; animation-delay: calc(var(--i) * .05s); }
.rep-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Métodos de pago */
.rep-methods { display: flex; flex-direction: column; gap: 14px; }
.rep-method { animation: slide-in .35s both; animation-delay: calc(var(--i) * .06s); }
.rep-method-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.rep-method-bar-wrap { background: #eef1f6; border-radius: 6px; height: 10px; overflow: hidden; }
.rep-method-bar { height: 100%; border-radius: 6px; background: var(--brand); animation: grow-x .5s both; transform-origin: left; }
.rep-method-bar.m-cash { background: var(--ok); }
.rep-method-bar.m-card { background: var(--brand); }
.rep-method-bar.m-transfer { background: #7c5cfa; }
.rep-method-bar.m-credit { background: var(--warn); }

@media (max-width: 860px) {
  .rep-grid { grid-template-columns: 1fr; }
}

/* ── Clientes y fiado ── */
.cart-cust { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.cart-cust select { font-size: 14px; }

.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn-sm { margin-left: 6px; }
tr.has-debt td { background: linear-gradient(90deg, rgba(180,83,9,.05), transparent 40%); }
.debt-chip {
  display: inline-block; background: var(--low-bg); color: var(--warn);
  font-weight: 700; padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.danger-text { color: var(--danger); }

/* Detalle de cliente */
.cus-detail { min-width: min(480px, 86vw); display: flex; flex-direction: column; gap: 16px; }
.cus-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.cus-detail-head h2 { margin: 0 0 2px; }
.cus-balance { text-align: right; display: flex; flex-direction: column; }
.cus-balance strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.cus-balance.owes strong { color: var(--warn); }
.det-sales td { font-size: 13px; }

.pay-box {
  background: var(--bg); border: 1px solid #e8ebf0; border-radius: var(--radius);
  padding: 16px; animation: rise .3s both;
}
.pay-box h3 { margin: 0 0 12px; font-size: 14px; }

/* ── Foto de producto (modal) ── */
.pf-photo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.pf-photo-preview {
  width: 84px; height: 84px; flex: 0 0 84px; border-radius: var(--radius);
  background: var(--bg); border: 1px dashed #cdd3dd; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.pf-photo-preview img { width: 100%; height: 100%; object-fit: cover; animation: fade .25s both; }
.pf-photo-empty { font-size: 11px; color: #9ca3af; }
.pf-photo-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pf-photo-actions label.btn { cursor: pointer; margin: 0; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180,83,9,0); }
  50% { box-shadow: 0 0 0 4px rgba(180,83,9,.12); }
}

/* ── Campos de giro (chips + modal) ── */
.cf-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cf-chip {
  font-size: .72rem; background: var(--surface-2); color: var(--text);
  padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}
.cf-chip.chip-warn { background: var(--low-bg); color: var(--warn); font-weight: 600; }
.pos-item-cf { font-size: .7rem; color: var(--muted); line-height: 1.2; }
.pos-cf-warn { color: var(--warn); font-weight: 600; }
#pf-giro .section-label { margin-top: 12px; }
#pf-giro .form-grid { margin-top: 6px; }

/* ── Importador de inventario ── */
.import-modal { max-width: 640px; width: 92vw; border: none; border-radius: var(--radius);
  padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.import-modal::backdrop { background: rgba(15,20,35,.45); }
.import-head { display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border); }
.import-head h2 { margin: 0; font-size: 1.15rem; }
.import-body { padding: 20px 22px; max-height: 60vh; overflow-y: auto; }
.import-modal .modal-actions { padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; }

.import-drop { display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 36px 20px; border: 2px dashed var(--border); border-radius: var(--radius);
  cursor: pointer; text-align: center; transition: border-color .15s, background .15s; margin-top: 14px; }
.import-drop:hover, .import-drop.over { border-color: var(--brand); background: var(--surface-2); }
.import-drop-icon { font-size: 1.8rem; color: var(--brand); font-weight: 700; }

.imp-map { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.imp-map-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.imp-map-src { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-map-arrow { color: var(--muted); }
.imp-map-row select { width: 100%; }
.imp-branch { margin: 14px 0; }

.imp-preview { margin-top: 6px; }
.imp-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.imp-table th, .imp-table td { padding: 6px 8px; border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; }
.imp-table th { color: var(--muted); font-weight: 600; }

.imp-result { text-align: center; padding: 20px 0; }
.imp-result-big { font-size: 2.6rem; font-weight: 700; color: var(--ok); line-height: 1; }
.imp-skipped { margin-top: 12px; font-size: .86rem; }
.imp-skipped summary { cursor: pointer; color: var(--warn); }
.imp-skipped ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

/* ── Código / SKU con botón de escaneo ── */
.sku-row { display: flex; gap: 6px; }
.sku-row input { flex: 1; min-width: 0; }
.sku-row .btn { white-space: nowrap; flex: 0 0 auto; }

/* ── Aviso del lector de código de barras (POS) ── */
.search-flash {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(210,63,49,.16) !important;
  animation: shake .3s ease both;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── Estado de venta (historial) ── */
.sale-badge {
  font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  display: inline-block; letter-spacing: .01em;
}
.sale-badge.paid { background: #e7f6ee; color: var(--ok); }
.sale-badge.pending { background: var(--low-bg); color: var(--warn); }
.sale-badge.void { background: #fdecea; color: var(--danger); }
tr.row-void td { opacity: .5; }
tr.row-void .sale-badge.void { opacity: 1; }

/* ── Entrada a la cuenta: secuencia orquestada tras el login ──
   Un solo momento coreografiado: la marca y la navegación se asientan,
   luego el área de trabajo asciende. Nada de efectos dispersos. */
.app:not([hidden]) .sidebar-brand { animation: rise .5s var(--ease) both; }
.app:not([hidden]) .nav-item {
  animation: slide-in .42s var(--ease) both;
  animation-delay: calc(80ms + var(--n, 0) * 45ms);
}
.app:not([hidden]) .sidebar-foot { animation: fade .6s ease .4s both; }

/* ── Configuración del negocio ── */
.banner { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.banner-ok { background: #e7f6ed; color: #1b7a43; border: 1px solid #bfe6cd; }
.banner-error { background: #fdeceb; color: #c0392b; border: 1px solid #f5c6c2; }
.settings-form { max-width: 720px; }
.settings-grid { display: grid; grid-template-columns: 1fr 220px; gap: 28px; align-items: start; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-fields .span-2 { grid-column: 1 / -1; }
.settings-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.settings-fields input { padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: var(--surface); }
.settings-fields input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.16); }
.settings-logo { display: flex; flex-direction: column; gap: 10px; }
.settings-logo .section-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.logo-preview { width: 100%; aspect-ratio: 1; border: 1px dashed var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--surface); overflow: hidden; }
.logo-preview img { max-width: 90%; max-height: 90%; object-fit: contain; }
.logo-actions { display: flex; gap: 8px; }
.logo-hint { font-size: 11px; }

@media (max-width: 720px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-logo { max-width: 220px; }
}

/* Ajustes de corte de caja en Configuración */
.settings-section { max-width: 720px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.settings-section .section-label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 6px; }
.settings-toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); margin-top: 12px; cursor: pointer; }
.settings-toggle input { width: 17px; height: 17px; accent-color: var(--brand); }
.settings-toggle.disabled { opacity: .5; cursor: default; }
.settings-hint { font-size: 12px; margin: 6px 0 0 27px; }

/* Vista Caja (corte de caja) */
.caja-card { max-width: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.caja-state { font-weight: 700; font-size: 14px; padding: 4px 12px; border-radius: 999px; display: inline-block; margin-bottom: 10px; }
.caja-state.closed { background: var(--surface-2); color: var(--muted); }
.caja-state.open { background: #e7f6ed; color: var(--ok); }
.caja-meta { font-size: 12px; margin-bottom: 16px; }
.caja-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-top: 14px; }
.caja-field input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: var(--surface); }
.caja-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.16); }
.btn-block { width: 100%; margin-top: 18px; justify-content: center; }
.caja-lines { display: flex; flex-direction: column; gap: 9px; margin: 6px 0 4px; }
.caja-lines > div { display: flex; justify-content: space-between; font-size: 14px; }
.caja-lines > div.muted span { color: var(--muted); }
.caja-expected { border-top: 1px dashed var(--border); padding-top: 9px; margin-top: 2px; font-weight: 700; }
.caja-close { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 16px; }
.caja-close .section-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.caja-diff { margin-top: 10px; font-size: 13px; font-weight: 700; padding: 8px 12px; border-radius: 8px; }
.caja-diff.ok { background: #e7f6ed; color: var(--ok); }
.caja-diff.warn { background: var(--low-bg); color: var(--warn); }
.caja-diff.bad { background: #fdeceb; color: var(--danger); }
.empty-note { max-width: 480px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.empty-note p { margin: 0 0 8px; }

/* Tabla de historial (reutilizable) */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
.data-table th { background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--muted); }
.data-table td.r, .data-table th.r { text-align: right; }
.data-table tr:last-child td { border-bottom: none; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill.ok { background: #e7f6ed; color: var(--ok); }
.pill.warn { background: var(--low-bg); color: var(--warn); }
.pill.bad { background: #fdeceb; color: var(--danger); }

/* Comprobante del corte al cerrar */
#corte-modal { border: none; border-radius: 14px; padding: 22px; max-width: 380px; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
#corte-modal::backdrop { background: rgba(10,15,25,.45); }
.corte-sheet h2 { margin: 0 0 14px; font-size: 18px; }
.corte-diff { margin-top: 14px; text-align: center; font-weight: 800; font-size: 15px; padding: 10px; border-radius: 10px; letter-spacing: .02em; }
.corte-diff.ok { background: #e7f6ed; color: var(--ok); }
.corte-diff.warn { background: var(--low-bg); color: var(--warn); }
.corte-diff.bad { background: #fdeceb; color: var(--danger); }

/* ════════════════ Movimiento, segunda capa: continuidad y feedback ════════════════
   El momento con autoría es el cambio de espacio de trabajo (View Transitions):
   el contenido se cruza con calma mientras la pastilla activa de la navegación
   se desliza. El resto son microseñales — el cambio mínimo que hace evidente
   causa→efecto — nunca decoración. Todo transform/opacity, compositable. */

/* --- Transición entre vistas (View Transitions API) --- */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .26s;
  animation-timing-function: cubic-bezier(.16,.84,.44,1);
}
::view-transition-old(root) { animation-name: vt-out; }
::view-transition-new(root) { animation-name: vt-in; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* La pastilla activa de navegación es un elemento compartido: se desliza de un
   ítem al siguiente en lugar de parpadear. Nombre estable durante la transición. */
html[data-vt="view"] .nav-item.active { view-transition-name: nav-active; }
::view-transition-group(nav-active) { animation-duration: .3s; animation-timing-function: var(--ease); }

/* --- Pastilla activa: barra de acento que crece desde la izquierda --- */
.nav-item.active::before {
  content: ""; position: absolute; left: 6px; top: 50%; width: 3px; height: 16px;
  background: #fff; border-radius: 2px; transform: translateY(-50%) scaleY(0);
  transform-origin: center; animation: acc-grow .34s var(--ease) .04s both;
}
@keyframes acc-grow { to { transform: translateY(-50%) scaleY(1); } }

/* --- Hover de botón primario: el acento respira (sombra, no movimiento) --- */
.btn-primary { transition: background .14s ease, box-shadow .2s ease, transform .08s ease; }
.btn-primary:hover { box-shadow: 0 2px 4px rgba(31,79,214,.4), 0 10px 26px rgba(47,107,255,.3); }

/* --- Icono de nav: leve avance al pasar el cursor, refuerza "pulsable" --- */
.nav-ic { transition: transform .16s var(--ease), opacity .16s ease; }
.nav-item:hover .nav-ic { transform: translateX(2px); }

/* --- POS: la tarjeta se hunde apenas al tocar; el badge de cantidad salta --- */
.pos-item { transition: border-color .12s, box-shadow .16s, transform .1s var(--ease); }
.pos-item:hover { transform: translateY(-2px); }
.pos-item-qty { animation: badge-bump .26s var(--ease) both; }
@keyframes badge-bump {
  0% { transform: scale(0); } 60% { transform: scale(1.18); } 100% { transform: scale(1); }
}

/* --- El Total del carrito destella al cambiar (lo dispara pos.js) --- */
#cart-total { transition: color .2s ease; }
#cart-total.flash { animation: total-flash .5s var(--ease); }
@keyframes total-flash {
  0% { color: var(--brand); transform: scale(1.06); }
  100% { color: inherit; transform: scale(1); }
}
#cart-total { display: inline-block; transform-origin: right center; }

/* --- Controles +/− del carrito: respuesta táctil --- */
.cart-qty button { transition: background .12s, border-color .12s, transform .08s; }
.cart-qty button:active { transform: scale(.88); }

/* --- Caja: el veredicto (cuadra/sobra/falta) entra con calma al aparecer --- */
.caja-diff:not([hidden]) { animation: rise .3s var(--ease) both; }
.corte-diff { animation: pop .34s var(--ease) both; }

/* --- Banners de guardado (Configuración): deslizan al confirmar --- */
.banner { animation: banner-in .34s var(--ease) both; }
@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; }
}

/* --- Interruptores (toggles) y segmentos: el acento se asienta, no salta --- */
.settings-toggle input { transition: transform .1s var(--ease); }
.settings-toggle input:active { transform: scale(.9); }
.seg button, .view-switch button { transition: background .18s var(--ease), color .18s ease; }

/* --- Chips de estado (pill/role/sale-badge): aparición breve --- */
.pill, .sale-badge, .role-chip, .caja-state { animation: pop .3s var(--ease) both; }

/* --- Spinner reutilizable para estados de carga --- */
.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  animation: spin .7s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════ Intro de bienvenida (al iniciar sesión) ════════════════
   El símbolo covexs se traza por partes sobre fondo carbón: el anillo primero,
   luego los dos lóbulos en espejo; después el relleno sólido aparece y el
   wordmark se asienta. Dura 1.5s y se usa una vez por inicio de sesión. */
.welcome {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(60% 60% at 50% 42%, #1d2230 0%, var(--ink) 70%);
  opacity: 1; transition: opacity .4s ease;
}
.welcome.out { opacity: 0; }
.welcome-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.welcome-mark { width: 120px; height: 120px; }

/* Cada trazo "se dibuja" reduciendo el dashoffset de su longitud a 0. */
.welcome.go .wm-ring { animation: wm-draw .95s var(--ease) forwards; }
.welcome.go .wm-top  { animation: wm-draw .82s var(--ease) .56s forwards; }
.welcome.go .wm-bot  { animation: wm-draw .82s var(--ease) .56s forwards; }
@keyframes wm-draw { to { stroke-dashoffset: 0; } }

/* El relleno sólido entra cuando el trazo ya dibujó el símbolo; el trazo azul
   se desvanece para no duplicar el contorno. */
.wm-fill { opacity: 0; }
.welcome.go .wm-fill { animation: wm-fill .55s var(--ease) 1.3s forwards; }
.welcome.go .wm-stroke { animation: wm-stroke-out .55s ease 1.32s forwards; }
@keyframes wm-fill { from { opacity: 0; transform: scale(.96); transform-origin: center; } to { opacity: 1; transform: none; } }
@keyframes wm-stroke-out { to { opacity: 0; } }

/* El wordmark se asienta bajo el símbolo. */
.welcome-word {
  color: #fff; font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  opacity: 0; transform: translateY(8px);
}
.welcome.go .welcome-word { animation: wm-word .5s var(--ease) 1.5s forwards; }
@keyframes wm-word { to { opacity: 1; transform: none; } }

/* Respeta a quien prefiere menos movimiento: menos y más suave, nunca
   eliminar la señal de que algo cambió. Conservamos fundidos de estado. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .nav-item:hover .nav-ic, .pos-item:hover { transform: none !important; }
}
