/* =========================================================
   Acceso — Mobile-first + Offline
   ========================================================= */

:root {
  --bg: #0D1533;
  --bg-2: #111C46;
  --primary: #3D5AFE;
  --primary-600: #304FFE;
  --primary-050: #EEF1FF;
  --accent: #FF4081;
  --yellow: #FFD54F;
  --ink: #1B2140;
  --muted: #7A819E;
  --line: #E3E7F3;
  --danger: #E53935;
  --ok: #2E7D32;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(13, 21, 51, .18);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 60%, #1A1030 100%);
  min-height: 100dvh;
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }

/* ---------- Offline bar ---------- */
.offline-bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  font-size: 13px; color: #fff;
  background: #B71C1C;
}
.offline-bar .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #FFCDD2; animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: .25; } }

/* ---------- Layout base (móvil) ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

/* ---------- Marca / hero ---------- */
.brand {
  position: relative;
  padding: 28px 20px 32px;
  color: #fff;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 85% 10%, rgba(61,90,254,.55), transparent 60%),
    radial-gradient(90% 70% at 10% 90%, rgba(255,64,129,.35), transparent 60%);
}

.brand__art {
  position: relative;
  margin-top: 0;
  height: 210px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #2F80ED, #3D5AFE 55%, #7C4DFF);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.blob { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .55; }
.blob--1 { width: 140px; height: 140px; background: #FF4081; top: -40px; left: -30px; }
.blob--2 { width: 110px; height: 110px; background: #FFD54F; bottom: -35px; right: -20px; opacity: .45; }
.blob--3 { width: 70px;  height: 70px;  background: #00E5FF; top: 45%; right: 25%; opacity: .4; }

/* Escena del local comercial */
.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  animation: sceneIn .7s ease both;
}
@keyframes sceneIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
}

/* Etiqueta de precio oscilando */
.scene__tag {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: swing 3.4s ease-in-out infinite;
}
@keyframes swing {
  0%, 100% { transform: rotate(-7deg); }
  50%      { transform: rotate(7deg); }
}

/* Cajas respirando */
.scene__boxes {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob {
  50% { transform: translateY(-5px); }
}

/* Letrero "ABIERTO" parpadeando */
.scene__sign-glow {
  animation: signGlow 2.6s ease-in-out infinite;
}
@keyframes signGlow {
  0%, 100% { opacity: .25; }
  50%      { opacity: 1; }
}

/* ---------- Tarjeta de auth ---------- */
.auth { padding: 0 14px calc(28px + var(--safe-b)); margin-top: -14px; }

.auth__card {
  position: relative;
  background: #fff;
  border-radius: 22px;
  padding: 6px 18px 20px;
  box-shadow: var(--shadow);
}

/* Tabs */
.tabs {
  position: relative;
  display: flex;
  gap: 6px;
  padding-top: 10px;
}
.tab {
  flex: 1;
  padding: 14px 6px;
  border: 0;
  background: none;
  font-size: 17px;
  font-weight: 600;
  color: var(--muted);
  transition: color .2s;
}
.tab.is-active { color: var(--ink); }
.tabs__ink {
  position: absolute; bottom: 0; left: 6px;
  width: calc(50% - 6px); height: 3px;
  border-radius: 3px;
  background: var(--primary);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.tabs.is-signin .tabs__ink { transform: translateX(100%); }

/* Formularios */
.form { display: none; padding-top: 18px; animation: fade .3s ease; }
.form.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}
.field input {
  width: 100%;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  font-size: 16px;            /* 16px evita zoom automático en iOS */
  color: var(--ink);
  background: transparent;
  outline: none;
  transition: border-color .2s;
}
.field input::placeholder { color: #B6BCD0; }
.field input:focus { border-bottom-color: var(--primary); }
.field.is-invalid input { border-bottom-color: var(--danger); }

.err {
  display: block; min-height: 14px;
  margin-top: 4px;
  font-size: 12px; color: var(--danger);
}

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 34px; }
.eye {
  position: absolute; right: 0; top: 6px;
  border: 0; background: none; font-size: 16px;
  opacity: .55;
}

/* Fuerza de contraseña */
.meter { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .25s, background .25s; }

/* Botones */
.btn {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(61,90,254,.35);
  transition: transform .12s, background .2s;
}
.btn:active { transform: scale(.98); background: var(--primary-600); }
.btn:disabled { opacity: .7; }
.btn--ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}

.alt { text-align: center; margin: 14px 0 4px; }
.link {
  border: 0; background: none;
  color: var(--accent);
  font-size: 14px; font-weight: 600;
}
.link--sm { font-size: 12.5px; color: var(--muted); }
.link:active { text-decoration: underline; }

.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
}
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* Toast */
.toast {
  position: fixed;
  left: 50%; bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%) translateY(16px);
  z-index: 90;
  padding: 12px 18px;
  border-radius: 12px;
  background: #10153A;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .25s, transform .25s;
  max-width: min(92vw, 420px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-ok { background: var(--ok); }
.toast.is-err { background: var(--danger); }

/* =========================================================
   TABLET ≥ 700px
   ========================================================= */
@media (min-width: 700px) {
  body { padding: 26px; }
  .app {
    max-width: 1040px;
    margin: 0 auto;
    grid-template-columns: 1.05fr 1fr;
    background: #fff;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 30px 70px rgba(0,0,0,.4);
    min-height: min(720px, calc(100dvh - 52px));
  }
  .brand { padding: 34px 30px; display: flex; flex-direction: column; }
  .brand__art { height: 320px; flex: 1; }
  .auth { margin-top: 0; padding: 40px 34px; align-self: center; }
  .auth__card { box-shadow: none; padding: 0; }
  .tabs.is-signin .tabs__ink { transform: translateX(100%); }
}

/* =========================================================
   DESKTOP ≥ 1100px
   ========================================================= */
@media (min-width: 1100px) {
  .app { grid-template-columns: 1.15fr 1fr; }
  .brand__art { height: 380px; }
  .auth { padding: 56px 56px; }
  .tab { font-size: 18px; }
}

/* Accesibilidad: movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* =========================================================
   APP (post-login) — shell lateral tipo dashboard
   ========================================================= */
[hidden] { display: none !important; }

.pos {
  --p-bg: #EEF1F7;
  --p-card: #FFFFFF;
  --p-card2: #F1F4F9;
  --p-tx: #0E1A2B;
  --p-mu: #6B7A90;
  --p-bd: #E6EBF3;
  --p-ac: #2563EB;
  --p-soft: #E0ECFF;
  --p-ok: #16A34A;
  --p-ok-soft: #DCFCE7;
  --p-bad: #E11D48;
  --p-bad-soft: #FFE4EA;
  --p-lime: #C6F24E;
  --p-lime-ink: #12210A;
  --p-violet: #7C3AED;
  --p-violet-soft: #EDE9FE;
  --p-side: #0E1A2B;
  --p-side-ink: #DBE4F0;
  --p-side-mut: #8494AD;

  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--p-bg);
  background-image: radial-gradient(1200px 600px at 70% -20%, #E3EBFB 0%, transparent 60%);
  color: var(--p-tx);
}
.pos[data-theme="dark"] {
  --p-bg: #0B1220;
  --p-card: #121B2E;
  --p-card2: #16203A;
  --p-tx: #E8EEFC;
  --p-mu: #93A1BD;
  --p-bd: #1F2B45;
  --p-ac: #60A5FA;
  --p-soft: #172A54;
  --p-ok: #4ADE80;
  --p-ok-soft: #12291C;
  --p-bad: #FB7185;
  --p-bad-soft: #2C1220;
  --p-lime: #BEF264;
  --p-lime-ink: #0A1226;
  --p-violet: #A78BFA;
  --p-violet-soft: #2A1E58;
  --p-side: #0A1122;
  --p-side-ink: #D7E0F2;
  --p-side-mut: #7E8DA8;
}
/* Tema automático: sigue al sistema salvo que elijas claro/oscuro */
@media (prefers-color-scheme: dark) {
  .pos:not([data-theme="light"]) {
    --p-bg: #0B1220;
    --p-card: #121B2E;
    --p-card2: #16203A;
    --p-tx: #E8EEFC;
    --p-mu: #93A1BD;
    --p-bd: #1F2B45;
    --p-ac: #60A5FA;
    --p-soft: #172A54;
    --p-ok: #4ADE80;
    --p-ok-soft: #12291C;
    --p-bad: #FB7185;
    --p-bad-soft: #2C1220;
    --p-lime: #BEF264;
    --p-lime-ink: #0A1226;
    --p-violet: #A78BFA;
    --p-violet-soft: #2A1E58;
    --p-side: #0A1122;
    --p-side-ink: #D7E0F2;
    --p-side-mut: #7E8DA8;
  }
}

/* ---------- Shell ---------- */
.shell {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- Menú lateral ---------- */
.side {
  position: fixed; z-index: 80; top: 0; bottom: 0; left: 0;
  width: 264px; max-width: 86vw;
  display: flex; flex-direction: column;
  background: var(--p-side);
  color: var(--p-side-ink);
  transform: translateX(-102%);
  transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  box-shadow: 14px 0 40px rgba(0, 0, 0, .35);
}
.side.is-open { transform: none; }
.side__bd {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(6, 10, 24, .55);
  backdrop-filter: blur(2px);
  animation: fade .2s ease;
}
.side__bd[hidden] { display: none !important; }

.sbrand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 14px;
  font-weight: 800; font-size: 16px; letter-spacing: .2px;
}
.blogo {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(140deg, var(--p-lime), #8FD51A);
  color: var(--p-lime-ink);
  box-shadow: 0 8px 18px rgba(198, 242, 78, .25);
}
.blogo svg { width: 20px; height: 20px; }

.nav {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 4px 12px 14px;
}
.nav__group {
  margin: 16px 10px 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--p-side-mut);
}
.side__btn {
  position: relative;
  display: flex; align-items: center; gap: 11px; width: 100%;
  border: 0; background: none; color: rgba(219, 228, 240, .82);
  padding: 11px 12px; border-radius: 12px;
  font-size: 14.5px; font-weight: 600; text-align: left;
  transition: background .18s, color .18s, transform .18s;
}
.side__btn svg { width: 19px; height: 19px; flex-shrink: 0; transition: transform .3s ease; }
.side__btn:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side__btn.is-active {
  background: var(--p-lime);
  color: var(--p-lime-ink);
  box-shadow: 0 6px 18px rgba(198, 242, 78, .28);
}
.side__btn.is-active svg { transform: scale(1.06); }
.navcnt {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--p-bad); color: #fff;
  font-size: 11px; font-weight: 800; font-style: normal;
}
.side__btn.is-active .navcnt { background: var(--p-side); color: var(--p-lime); }

.side-foot {
  padding: 12px 14px calc(14px + var(--safe-b));
  border-top: 1px solid rgba(255, 255, 255, .09);
  display: grid; gap: 9px;
}
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px;
  padding: 12px; font-size: 14px; font-weight: 800;
  transition: transform .12s, filter .2s;
}
.cta svg { width: 17px; height: 17px; }
.cta:active { transform: scale(.96); }
.cta.lime { background: var(--p-lime); color: var(--p-lime-ink); box-shadow: 0 8px 20px rgba(198, 242, 78, .25); }
.cta.violet { background: var(--p-violet); color: #fff; box-shadow: 0 8px 20px rgba(124, 58, 237, .3); }
.side__out {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid rgba(255, 255, 255, .16); background: none;
  color: #FF8A80; padding: 10px; border-radius: 12px;
  font-size: 13.5px; font-weight: 700;
}
.side__out:active { background: rgba(255, 138, 128, .12); }

/* ---------- Barra superior ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 40;
  background: var(--p-card);
  border-bottom: 1px solid var(--p-bd);
  box-shadow: 0 1px 2px rgba(16, 30, 54, .04);
}
.hdr {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  max-width: 1320px; margin: 0 auto; width: 100%;
}
.burger {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid var(--p-bd); border-radius: 12px;
  background: var(--p-card); color: var(--p-tx);
}
.burger svg { width: 21px; height: 21px; }
.burger:active { background: var(--p-soft); }
.titles { flex: 1; min-width: 0; line-height: 1.2; }
.titles h1 { margin: 0; font-size: 16.5px; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles small { display: block; font-size: 11.5px; color: var(--p-mu); margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }

.pos__net { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--p-ok); }
.pos__net i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pos__net.is-off { color: var(--p-bad); }

.themebtn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--p-bd); border-radius: 12px;
  background: var(--p-card); color: var(--p-tx);
}
.themebtn svg { width: 19px; height: 19px; grid-area: 1 / 1; transition: opacity .2s, transform .3s; }
.themebtn .moon { opacity: 0; transform: rotate(-60deg) scale(.5); }
.pos[data-theme="dark"] .themebtn .sun { opacity: 0; transform: rotate(60deg) scale(.5); }
.pos[data-theme="dark"] .themebtn .moon { opacity: 1; transform: none; }
.themebtn:active { background: var(--p-soft); }

.userwrap { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--p-ac), var(--p-violet));
}
.userchip { display: none; line-height: 1.2; min-width: 0; }
.userchip strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 150px; }

/* ---------- Contenido / vistas ---------- */
.content {
  flex: 1; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 14px 46px;
  max-width: 1320px; width: 100%; margin: 0 auto;
}
.view { display: none; }
.view.is-active { display: block; animation: fade .3s ease; }
.view__title { margin: 4px 0 2px; font-size: 20px; }
.view__sub { margin: 0 0 16px; color: var(--p-mu); font-size: 13.5px; }

/* (barra superior y vistas definidas arriba, junto al shell) */

/* ---------- Tarjetas y bloques ---------- */
.card {
  background: var(--p-card); border: 1px solid var(--p-bd);
  border-radius: 16px; padding: 14px; margin-bottom: 14px;
  box-shadow: 0 8px 20px rgba(13, 21, 51, .05);
}
.block { margin-top: 22px; }
.block__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.block__head h2 { margin: 0; font-size: 15.5px; }
.pill {
  font-size: 10.5px; font-weight: 800;
  color: var(--p-ac); background: var(--p-soft);
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.muted2 { display: block; color: var(--p-mu); font-size: 12.5px; margin: 6px 0 10px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--p-card); border: 1px solid var(--p-bd);
  border-radius: 16px; padding: 13px 13px 13px 17px;
  box-shadow: 0 8px 20px rgba(13, 21, 51, .05);
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--p-ac); }
.stat--green::before { background: #2E7D32; }
.stat--pink::before  { background: #FF4081; }
.stat--yellow::before{ background: #FB8C00; }
.stat__num { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.4px; }
.stat__lbl { display: block; font-size: 11.5px; color: var(--p-mu); margin-top: 3px; }

/* Accesos rápidos */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 10px; }
.quick button {
  display: grid; gap: 5px; justify-items: center;
  padding: 13px 8px; font-size: 20px;
  border: 1px solid var(--p-bd); border-radius: 14px;
  background: var(--p-card); color: var(--p-tx);
}
.quick button:active { background: var(--p-soft); }
.quick button svg { width: 23px; height: 23px; color: var(--p-ac); }
.quick span { font-size: 12.5px; font-weight: 700; }

/* Barra de meta */
.prog { height: 11px; border-radius: 11px; background: var(--p-bg); border: 1px solid var(--p-bd); overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3D5AFE, #7C4DFF); transition: width .6s ease; }
.prog__row { display: flex; justify-content: space-between; font-size: 13px; margin-top: 8px; color: var(--p-mu); }

/* Top productos */
.toplist { display: grid; gap: 8px; }
.toprow {
  display: grid; grid-template-columns: 22px 40px 1fr auto;
  align-items: center; gap: 10px;
  background: var(--p-card); border: 1px solid var(--p-bd);
  border-radius: 14px; padding: 9px 12px;
}
.toprow__rank { font-size: 13px; font-weight: 800; color: var(--p-mu); }
.toprow__ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 19px; }
.toprow__name { font-size: 13.5px; font-weight: 600; }
.toprow__bar { display: block; height: 6px; background: var(--p-bg); border-radius: 6px; margin-top: 6px; overflow: hidden; }
.toprow__bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--primary), #7C4DFF); }
.toprow__qty { font-size: 13px; font-weight: 800; color: var(--p-ac); }
.empty {
  background: var(--p-card); border: 1px dashed var(--p-bd);
  border-radius: 14px; padding: 24px 12px;
  text-align: center; color: var(--p-mu); font-size: 13.5px;
}

/* Feed estilo redes sociales */
.feed { display: grid; gap: 12px; }
.post {
  background: var(--p-card); border: 1px solid var(--p-bd);
  border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 8px 20px rgba(13, 21, 51, .05);
}
.post__head { display: flex; align-items: center; gap: 10px; }
.post__av {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
  background: linear-gradient(135deg, #FF4081, #FF80AB);
}
.post__t { font-size: 13.5px; font-weight: 700; }
.post__time { font-size: 11.5px; color: var(--p-mu); }
.post__mode {
  margin-left: auto; flex-shrink: 0;
  font-size: 10px; font-weight: 800; letter-spacing: .3px;
  padding: 4px 8px; border-radius: 999px;
  background: #FFF3E0; color: #E65100;
}
.post__mode.is-mayoreo { background: #E8F5E9; color: #2E7D32; }
.post__items { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--p-tx); }
.post__items li { display: flex; justify-content: space-between; gap: 10px; }
.post__more { font-size: 12px; color: var(--p-mu); margin-top: 4px; }
.post__total {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--p-bd); font-size: 13.5px; color: var(--p-mu);
}
.post__total strong { font-size: 17px; color: var(--p-ac); }

/* ---------- Formularios ---------- */
.frm-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.frm { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 145px; }
.frm small { font-size: 11.5px; font-weight: 700; color: var(--p-mu); letter-spacing: .2px; }
.frm input, .frm select {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--p-bd); border-radius: 10px;
  background: var(--p-card); color: var(--p-tx);
  font-size: 15px; outline: none;
}
.frm input:focus, .frm select:focus { border-color: var(--p-ac); }
.frm--sm { max-width: 110px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }
.btn--sm {
  width: auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 17px; font-size: 14px; box-shadow: none; margin-top: 0;
}
.btn--ghost { background: transparent; color: var(--p-ac); border: 1.5px solid var(--p-ac); box-shadow: none; }
.btn--danger { background: var(--p-bad); box-shadow: none; margin-top: 14px; }
.filebtn { cursor: pointer; border: 1.5px solid var(--p-ac); border-radius: 10px; }

.banner {
  padding: 11px 13px; border-radius: 12px; margin-bottom: 12px;
  font-size: 14px; font-weight: 700;
  background: var(--p-soft); color: var(--p-ac);
}
.banner.is-bad { background: rgba(229, 57, 53, .12); color: #E53935; }
.pos[data-theme="dark"] .banner.is-bad { background: rgba(255, 138, 128, .14); color: #FF8A80; }

/* ---------- Tablas ---------- */
.w { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--p-bd); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--p-mu); }
td input, td select {
  padding: 6px 8px; width: 82px;
  border: 1px solid var(--p-bd); border-radius: 8px;
  background: var(--p-card); color: var(--p-tx); font-size: 13.5px;
}
td input:focus { outline: none; border-color: var(--p-ac); }
.bad { color: var(--p-bad); font-weight: 700; }
.ok { color: var(--p-ok); font-weight: 700; }
.g { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; }
.k { background: var(--p-bg); border: 1px solid var(--p-bd); border-radius: 12px; padding: 11px 12px; }
.k span { display: block; font-size: 11.5px; color: var(--p-mu); }
.k b { display: block; font-size: 17px; margin-top: 3px; letter-spacing: -.3px; }

/* ---------- Barra de herramientas ---------- */
.toolbar { display: grid; gap: 10px; margin-bottom: 14px; }
.toolbar input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--p-bd); border-radius: 12px;
  background: var(--p-card); color: var(--p-tx); font-size: 16px; outline: none;
}
.toolbar input:focus { border-color: var(--p-ac); }
.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--p-card); padding: 5px; border-radius: 12px;
  border: 1px solid var(--p-bd);
}
.modes--auto { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); width: fit-content; }
.mode {
  border: 0; background: none; padding: 10px 14px;
  border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--p-mu);
  transition: background .18s, color .18s;
}
.mode.is-active { background: var(--p-ac); color: #fff; box-shadow: 0 6px 14px rgba(37, 99, 235, .3); }

/* Botones/links dentro de la app heredan la paleta del panel */
.pos .btn {
  margin-top: 0;
  background: var(--p-ac);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .3);
}
.pos .btn:active { background: var(--p-ac); filter: brightness(.94); }
.pos .btn--ghost { background: transparent; color: var(--p-ac); border: 1.5px solid var(--p-ac); box-shadow: none; }
.pos .btn--danger { background: var(--p-bad); box-shadow: none; }
.pos .link { color: var(--p-ac); }
.pos .link--sm { color: var(--p-mu); }
.pos .check input { accent-color: var(--p-ac); }
.pos .field label { color: var(--p-ac); }

/* ---------- Catálogo ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pcard {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--p-card); border: 1px solid var(--p-bd);
  border-radius: 16px; padding: 10px;
  animation: fade .3s ease both;
}
.pcard__img { height: 84px; border-radius: 12px; display: grid; place-items: center; font-size: 38px; }
.pcard__name { font-size: 13px; font-weight: 600; line-height: 1.3; min-height: 34px; }
.pcard__stock { font-size: 11px; font-weight: 700; color: var(--p-mu); }
.pcard__stock.is-low { color: var(--p-bad); }
.pcard__price { font-size: 16px; font-weight: 800; color: var(--p-ac); }
.pcard__price small { display: block; font-size: 10.5px; font-weight: 600; color: var(--p-mu); }
.pcard__add {
  border: 0; border-radius: 10px; padding: 10px;
  background: var(--p-soft); color: var(--p-ac);
  font-size: 13.5px; font-weight: 800;
}
.pcard__add:active { background: var(--p-ac); color: #fff; }
.pcard__add:disabled { opacity: .45; }
.pcard--empty { grid-column: 1 / -1; }

/* ---------- Venta: catálogo + carrito SIEMPRE visible ---------- */
.venta { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.venta__cat { min-width: 0; }

.cartp {
  order: -1;
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--p-card); border: 1px solid var(--p-bd);
  border-radius: 18px; padding: 12px;
  box-shadow: 0 12px 28px rgba(16, 30, 54, .09);
}
.cartp__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-bottom: 9px; border-bottom: 1px solid var(--p-bd);
}
.cartp__head h2 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.cartp__foot {
  display: grid; gap: 7px;
  border-top: 2px dashed var(--p-bd); padding-top: 11px;
}
.cartp__foot .frm { margin-bottom: 3px; }
.cartp__foot .btn { margin-top: 4px; }
#checkout:not(:disabled) {
  background: var(--p-lime); color: var(--p-lime-ink);
  box-shadow: 0 10px 22px rgba(198, 242, 78, .35);
}
#checkout:not(:disabled):active { background: #B6E33F; }

.cart { list-style: none; margin: 10px 0; padding: 0; overflow-y: auto; display: grid; gap: 9px; max-height: 34vh; }
.cart__item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px 10px; align-items: center;
  background: var(--p-card2); border: 1px solid var(--p-bd);
  border-radius: 12px; padding: 9px 11px;
}
.cart__name { font-size: 13.5px; font-weight: 700; }
.cart__price { font-size: 11.5px; color: var(--p-mu); }
.cart__price .is-may { color: var(--p-ok); font-weight: 800; }
.cart__qty { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 8px; }
.cart__sub { grid-column: 2; grid-row: 2; font-size: 14px; font-weight: 800; color: var(--p-ac); text-align: right; }
.qtybtn {
  width: 30px; height: 30px; border-radius: 9px;
  border: 1px solid var(--p-bd); background: var(--p-card);
  font-size: 16px; font-weight: 700; color: var(--p-tx);
}
.qtybtn:active { background: var(--p-soft); }
.cart__num { min-width: 18px; text-align: center; font-weight: 800; font-size: 14px; }
.cart__empty { text-align: center; color: var(--p-mu); font-size: 13.5px; padding: 24px 10px; }

.cart__row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--p-mu); }
.cart__row--total { font-size: 15px; color: var(--p-tx); }
.cart__row--total strong { font-size: 22px; color: var(--p-ac); letter-spacing: -.5px; }
#checkout:disabled { opacity: .45; box-shadow: none; }

/* ---------- Modales ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 16px;
  visibility: hidden;
}
.modal.is-open { visibility: visible; }
.modal::before { content: ""; position: absolute; inset: 0; background: rgba(9, 13, 32, .6); opacity: 0; transition: opacity .25s; }
.modal.is-open::before { opacity: 1; }
.modal__card {
  position: relative;
  width: min(430px, 100%); max-height: 88dvh; overflow: auto;
  background: var(--p-card); color: var(--p-tx);
  border-radius: 20px; padding: 18px;
  opacity: 0; transform: translateY(14px) scale(.97);
  transition: opacity .25s, transform .25s;
}
.modal.is-open .modal__card { opacity: 1; transform: none; }

/* ---------- Ticket ---------- */
.modal__card--ticket { font-size: 13px; }
.ticket__head {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; letter-spacing: 1.5px;
  padding-bottom: 8px; border-bottom: 2px dashed var(--p-bd);
}
.ticket__meta { margin: 7px 0 0; font-size: 12px; color: var(--p-mu); }
.ticket__list { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 6px; }
.ticket__list li { display: flex; justify-content: space-between; gap: 12px; }
.ticket__list span:last-child { font-weight: 700; white-space: nowrap; }
.ticket__row { display: flex; justify-content: space-between; padding: 4px 0; }
.ticket__row--total { border-top: 2px dashed var(--p-bd); margin-top: 6px; padding-top: 9px; font-size: 16px; }
.ticket__row--total strong { color: var(--p-ac); font-size: 21px; }
.ticket__thanks { text-align: center; font-size: 12.5px; color: var(--p-mu); margin: 14px 0; }
.ticket__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ticket__actions .btn { margin-top: 0; }

/* =========================================================
   TABLET / ESCRITORIO
   ========================================================= */
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr auto; align-items: center; }
  .content { padding: 24px 24px 52px; }
}

@media (min-width: 980px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr); }
  .side {
    position: static; transform: none;
    width: auto; max-width: none;
    box-shadow: none;
    border-right: 1px solid rgba(255, 255, 255, .07);
  }
  .side__bd { display: none !important; }
  #menuBtn { display: none; }
  .userchip { display: block; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Carrito SIEMPRE visible, ahora fijo a la derecha del catálogo */
  .venta { grid-template-columns: minmax(0, 1fr) 350px; gap: 18px; }
  .cartp { order: 0; top: 12px; max-height: calc(100dvh - 140px); }
  .cart { max-height: calc(100dvh - 430px); }
}

@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* =========================================================
   IMPRESIÓN DE TICKET
   ========================================================= */
@media print {
  body * { visibility: hidden !important; }
  #ticketModal, #ticketModal * { visibility: visible !important; }
  #ticketModal { position: absolute; inset: 0; padding: 0; display: block; }
  #ticketModal::before { display: none; }
  .modal__card--ticket {
    width: 100%; max-height: none; opacity: 1 !important;
    transform: none !important; box-shadow: none; border-radius: 0;
  }
  .ticket__actions { display: none; }
}

/* ===== Gráficos (charts.js) ===== */
.ch { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid { stroke: var(--p-bd); stroke-width: 1; stroke-dasharray: 3 4; }
.ch-t { fill: var(--p-mu); font-size: 9px; }
.ch-bar { fill: var(--p-ac); opacity: .85; transform-box: fill-box; transform-origin: 50% 100%; animation: chGrow .7s cubic-bezier(.2, .8, .2, 1) both; }
.ch-bar.is-hi { fill: var(--p-violet); opacity: 1; }
.ch-line { fill: none; stroke: var(--p-ac); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: chDraw 1.2s ease forwards; }
.ch-dot { fill: var(--p-card); stroke: var(--p-ac); stroke-width: 1.5; }
.ch-fade { animation: chFade .9s ease .3s both; }
.ch-track { stroke: var(--p-bd); fill: none; }
.ch-seg { animation: chFade .6s ease both; }
.ch-gauge { animation: chG 1.1s cubic-bezier(.2, .8, .2, 1) both; }
.ch--donut .ch-c { fill: var(--p-tx); font-size: 5.2px; font-weight: 700; }
.ch--donut .ch-s { fill: var(--p-mu); font-size: 2.6px; }
.ch--gauge .ch-big { fill: var(--p-tx); font-size: 19px; font-weight: 700; }
.ch--gauge .ch-s { fill: var(--p-mu); font-size: 7px; }
.ch-donut { display: grid; grid-template-columns: minmax(120px, 150px) 1fr; gap: 14px; align-items: center; }
.ch-leg { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 12.5px; }
.ch-leg li { display: flex; align-items: center; gap: 8px; }
.ch-leg i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ch-leg span { flex: 1; color: var(--p-mu); }
.ch-h { display: grid; gap: 10px; }
.ch-hr { display: grid; grid-template-columns: minmax(96px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.ch-hl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-ht { height: 10px; border-radius: 99px; background: var(--p-bd); overflow: hidden; }
.ch-ht i { display: block; height: 100%; border-radius: 99px; transform-origin: left; animation: chGrowX .8s cubic-bezier(.2, .8, .2, 1) both; }
.ch-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 12px; margin-bottom: 12px; }
.ch-grid2 > .card, .ch-grid2 > div { margin-bottom: 0; }
.k { position: relative; overflow: hidden; }
.k::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--p-ac); opacity: .7; }
@keyframes chGrow { from { transform: scaleY(0); } }
@keyframes chGrowX { from { transform: scaleX(0); } }
@keyframes chDraw { to { stroke-dashoffset: 0; } }
@keyframes chFade { from { opacity: 0; } }
@keyframes chG { from { stroke-dasharray: 0 var(--len); } }
@media (prefers-reduced-motion: reduce) { .ch *, .ch-ht i { animation: none !important; stroke-dashoffset: 0 !important; } }

/* ===== Roles y cambio ===== */
.side__btn[hidden], [data-goto][hidden] { display: none !important; }
#cashBox { display: grid; gap: 8px; margin: 8px 0; padding: 10px; border: 1px dashed var(--p-bd); border-radius: 12px; }
#cashBox[hidden] { display: none; }
#cashChange { font-size: 22px; }
#cashChange.ok { color: var(--p-ok); } #cashChange.bad { color: var(--p-bad); }
.quickcash { display: flex; flex-wrap: wrap; gap: 6px; }
.quickcash button { border: 1px solid var(--p-bd); background: var(--p-card2, var(--p-card)); color: var(--p-tx); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.quickcash button:active { transform: scale(.96); }
.ticket__row--big strong { font-size: 20px; }
