/* Demo Ventas y caja — JS CHÁVEZ. Base visual compartida con las demás demos (copia autónoma). */
:root {
  --bg: #050b1a;
  --bg-2: #081226;
  --surface: #0b1630;
  --surface-2: #10204a;
  --line: rgba(120, 160, 255, 0.16);
  --line-strong: rgba(120, 170, 255, 0.32);
  --text: #eaf2ff;
  --muted: #a8b6d3;
  --blue: #2f6bff;
  --blue-deep: #1e4fd8;
  --cyan: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --focus: #67e8f9;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: 'Segoe UI', Inter, Roboto, 'Helvetica Neue', Arial, system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden;
  background: radial-gradient(900px 500px at 10% -10%, rgba(47, 107, 255, 0.18), transparent 60%), var(--bg);
  color: var(--text); font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--cyan); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 1160px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 768px) { .wrap { padding-inline: 28px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; border-radius: 10px; background: var(--cyan); color: var(--bg); font-weight: 700; }
.skip-link:focus { top: 10px; }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(5, 11, 26, 0.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.back { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--text); }
.back b { color: var(--text); letter-spacing: 0.04em; }
.demo-badge {
  padding: 6px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--warn); border: 1px solid currentColor; background: rgba(251, 191, 36, 0.1);
}

/* Introducción */
.intro { display: grid; gap: 16px; padding-block: 28px 20px; }
@media (min-width: 900px) { .intro { grid-template-columns: 1fr 1.1fr; align-items: end; } }
.kicker { color: var(--cyan); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; }
h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); margin-top: 6px; }
.notice { padding: 12px 14px; border-radius: 12px; font-size: 0.9rem; color: var(--muted); border: 1px dashed var(--line-strong); background: rgba(11, 22, 48, 0.6); }
.notice strong, #storage-warning { color: var(--warn); }

/* KPIs */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(180deg, rgba(16, 32, 74, 0.6), rgba(11, 22, 48, 0.8)); }
.kpi small { display: block; color: var(--muted); font-size: 0.78rem; }
.kpi strong { display: block; font-size: clamp(1.15rem, 4vw, 1.5rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-warn strong { color: var(--warn); }
.kpi strong.bump { animation: bump 0.45s var(--ease); }
@keyframes bump { 40% { transform: scale(1.08); color: var(--cyan); } }

.alert { margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.08); color: var(--text); font-size: 0.92rem; }
.alert b { color: var(--warn); }

/* Pestañas */
.tabs { display: flex; gap: 4px; margin-top: 22px; padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); overflow-x: auto; }
.tab { flex: 1; min-height: 44px; padding: 8px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; white-space: nowrap; transition: background-color 0.25s, color 0.25s; }
.tab[aria-selected='true'] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.panel { padding-block: 18px 32px; animation: fade-in 0.35s var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }

/* Formularios */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.field { display: grid; gap: 4px; min-width: 0; }
.field.grow { flex: 1 1 220px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input:not([type='checkbox']):not([type='radio']), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  background: rgba(5, 11, 26, 0.75); border: 1px solid var(--line-strong);
}
textarea { resize: vertical; }
select option { background: var(--surface); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--cyan); }
input[aria-invalid='true'] { border-color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }

/* Botones */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 16px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(16, 32, 74, 0.6); color: var(--text);
  font-weight: 650; font-size: 0.92rem; cursor: pointer; transition: transform 0.2s var(--ease), border-color 0.2s, background-color 0.2s;
}
.btn:hover { border-color: var(--cyan); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--blue-deep)); border-color: transparent; color: #fff; }
.btn-quiet { background: transparent; }
.btn-danger { background: #b91c1c; border-color: transparent; color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.82rem; }
.btn-in { color: var(--ok); }
.btn-out { color: var(--warn); }
.btn-del { color: var(--danger); }
@media (max-width: 479px) { .actions .btn { flex: 1 1 100%; } }

/* Tabla de productos (tarjetas en móvil) */
.count { margin-top: 14px; font-size: 0.85rem; color: var(--muted); }
.table-wrap { margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line-strong); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr { transition: background-color 0.2s; }
.table tbody tr:hover { background: rgba(16, 32, 74, 0.45); }
.code { font-family: Consolas, 'Cascadia Mono', monospace; font-size: 0.85rem; color: var(--cyan); }
.pname { font-weight: 650; }
.pdesc { display: block; font-size: 0.82rem; color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; background: rgba(34, 211, 238, 0.08); border: 1px solid rgba(34, 211, 238, 0.25); color: var(--cyan); }
.stock { font-weight: 700; }
.stock small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.is-low .stock { color: var(--warn); }
.low-pill { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; color: var(--bg); background: var(--warn); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.row-new { animation: row-in 0.6s var(--ease); }
@keyframes row-in { from { opacity: 0; transform: translateY(8px); background: rgba(34, 211, 238, 0.15); } }
.row-flash { animation: flash 0.9s ease-out; }
@keyframes flash { from { background: rgba(34, 211, 238, 0.18); } }

@media (max-width: 759px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 12px; padding: 14px;
    border: 1px solid var(--line); border-radius: var(--radius); background: rgba(11, 22, 48, 0.75);
  }
  .table td { padding: 0; border: 0; }
  .table td.c-code { grid-column: 1 / -1; }
  .table td.c-name { grid-column: 1; }
  .table td.c-cat { grid-column: 1; }
  .table td.c-price { grid-column: 2; grid-row: 2; }
  .table td.c-stock { grid-column: 2; grid-row: 3; }
  .table td.c-actions { grid-column: 1 / -1; margin-top: 8px; }
  .row-actions { justify-content: stretch; }
  .row-actions .btn { flex: 1 1 calc(50% - 6px); min-height: 40px; }
  .table td[data-label]::before { content: attr(data-label) ' '; font-size: 0.72rem; color: var(--muted); }
}

.empty { margin-top: 16px; padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* Historial */
.history { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.history li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(11, 22, 48, 0.7);
}
.mv-type { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font-weight: 800; grid-row: span 2; }
.mv-entrada .mv-type { color: var(--ok); background: rgba(52, 211, 153, 0.12); }
.mv-salida .mv-type { color: var(--warn); background: rgba(251, 191, 36, 0.12); }
.mv-title { font-weight: 650; overflow-wrap: anywhere; }
.mv-meta { font-size: 0.8rem; color: var(--muted); grid-column: 2; overflow-wrap: anywhere; }
.mv-qty { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; grid-row: span 2; }
.mv-entrada .mv-qty { color: var(--ok); }
.mv-salida .mv-qty { color: var(--warn); }
.mv-qty small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }

/* Estadísticas */
.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.card { padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(180deg, rgba(16, 32, 74, 0.55), rgba(11, 22, 48, 0.8)); }
.card h2 { font-size: 1rem; margin-bottom: 14px; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bars li { display: grid; gap: 4px; font-size: 0.88rem; }
.bars .bar-label { display: flex; justify-content: space-between; gap: 8px; }
.bars .bar-label span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.bars .track { height: 8px; border-radius: 99px; background: rgba(120, 160, 255, 0.12); overflow: hidden; }
.bars .fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); transform-origin: left; animation: grow 0.8s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; margin: 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ranking { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.ranking li span { color: var(--muted); }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 12px; }

/* Diálogos */
dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border-radius: 18px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
dialog[open] { animation: dlg-in 0.3s var(--ease); }
dialog::backdrop { background: rgba(2, 6, 16, 0.7); backdrop-filter: blur(3px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog h2 { font-size: 1.2rem; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 479px) { .form-grid { grid-template-columns: 1fr; } }
.form-error { min-height: 1.2em; color: var(--danger); font-size: 0.88rem; }
.form-error:empty { min-height: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.move-product { color: var(--muted); }
.move-product b { color: var(--text); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: grid; place-items: center; min-height: 42px; border-radius: 9px; font-weight: 650; color: var(--muted); transition: background-color 0.2s, color 0.2s; }
.segmented input:checked + span { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Avisos */
.toasts { position: fixed; z-index: 50; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: 12px; font-size: 0.92rem; font-weight: 600;
  background: rgba(11, 22, 48, 0.96); border: 1px solid var(--line-strong); box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.8);
  animation: toast-in 0.35s var(--ease);
}
.toast.ok { border-color: rgba(52, 211, 153, 0.6); }
.toast.warn { border-color: rgba(251, 191, 36, 0.6); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

.foot { padding-block: 24px 40px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
