/* ============================================================
   InventarioScan — CimaTech V1.0
   Paleta: azul-noche industrial + acento cian de escáner + ámbar de alerta
   Display: Space Grotesk · Body: Plus Jakarta Sans
   ============================================================ */

:root {
  /* Tema oscuro (default, ideal para bodega/terminal) */
  --bg:        #0B1120;
  --bg-2:      #111a2e;
  --surface:   #16203a;
  --surface-2: #1e2b4a;
  --border:    #2a3a5f;
  --text:      #e8eefc;
  --text-dim:  #94a3c4;
  --text-mute: #64748b;

  --scan:      #22d3ee;   /* cian escáner — acento primario */
  --scan-deep: #0891b2;
  --scan-glow: rgba(34,211,238,.35);

  --amber:     #f59e0b;   /* alerta / conteo 2 */
  --amber-glow:rgba(245,158,11,.25);
  --green:     #10b981;
  --red:       #ef4444;
  --red-glow:  rgba(239,68,68,.2);

  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-disp: 'Space Grotesk', system-ui, sans-serif;
}

html.light {
  --bg:        #f4f7fc;
  --bg-2:      #e9eff8;
  --surface:   #ffffff;
  --surface-2: #f1f5fb;
  --border:    #d7e0ee;
  --text:      #0f1e38;
  --text-dim:  #4a5c7a;
  --text-mute: #7688a5;
  --scan-glow: rgba(34,211,238,.2);
  --shadow:    0 10px 30px rgba(20,40,80,.12);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .3s;
}

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
#splash.active, #suspended.active, #login.active, #welcome.active { display: flex; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-body); font-weight: 600; font-size: 16px;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  padding: 14px 20px; transition: transform .12s, filter .2s, background .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn-lg { padding: 18px 22px; font-size: 17px; border-radius: var(--radius); }
.btn-block { width: 100%; }

.btn-primary { background: linear-gradient(135deg, var(--scan), var(--scan-deep)); color: #041018; box-shadow: 0 6px 18px var(--scan-glow); font-weight: 700; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--scan); border: 2px solid var(--border); }
.btn-outline:hover { border-color: var(--scan); }
.btn-danger { background: linear-gradient(135deg, var(--red), #b91c1c); color: #fff; box-shadow: 0 6px 18px var(--red-glow); }
.btn-whats { background: #25D366; color: #04140a; font-weight: 700; text-decoration: none; }
.btn-ghost { background: transparent; border: none; color: var(--text-dim); cursor: pointer; padding: 10px; border-radius: 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost svg { width: 22px; height: 22px; }

/* ---------- Scan frame (firma visual) ---------- */
.scan-frame {
  position: relative; width: 96px; height: 96px; border-radius: 22px;
  background: var(--surface); border: 2px solid var(--scan);
  display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 0 40px var(--scan-glow);
}
.scan-frame.small { width: 60px; height: 60px; border-radius: 16px; }
.scan-icon { width: 46px; height: 46px; color: var(--scan); }
.scan-frame.small .scan-icon { width: 30px; height: 30px; }
.scan-beam {
  position: absolute; left: 8%; right: 8%; height: 3px;
  background: linear-gradient(90deg, transparent, var(--scan), transparent);
  box-shadow: 0 0 14px var(--scan); border-radius: 2px;
  animation: beam 2.2s ease-in-out infinite;
}
@keyframes beam { 0%,100% { top: 18%; } 50% { top: 78%; } }
@media (prefers-reduced-motion: reduce) { .scan-beam { animation: none; top: 50%; } }

/* ---------- Splash ---------- */
.splash { flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px; }
.splash-title { font-family: var(--font-disp); font-size: 34px; font-weight: 700; letter-spacing: -1px; margin-top: 8px; }
.splash-sub { color: var(--text-dim); font-size: 15px; }
.splash-loader { display: flex; gap: 8px; margin-top: 12px; }
.splash-loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--scan); animation: bounce 1.2s infinite; }
.splash-loader span:nth-child(2) { animation-delay: .18s; }
.splash-loader span:nth-child(3) { animation-delay: .36s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-12px); opacity: 1; } }

/* ---------- Suspended ---------- */
.suspended { align-items: center; justify-content: center; padding: 24px; }
.suspended-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 28px; text-align: center; max-width: 420px; box-shadow: var(--shadow); }
.suspended-icon { width: 60px; height: 60px; color: var(--amber); margin-bottom: 16px; }
.suspended-card h2 { font-family: var(--font-disp); margin-bottom: 10px; }
.suspended-card p { color: var(--text-dim); margin-bottom: 24px; }

/* ---------- Login ---------- */
.login { align-items: center; justify-content: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 440px; }
.login-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.login-title { font-family: var(--font-disp); font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.login-tag { color: var(--text-dim); font-size: 14px; }
.login-card { display: flex; flex-direction: column; gap: 6px; }
.login-foot { text-align: center; color: var(--text-mute); font-size: 12px; margin-top: 22px; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.foot-logo { height: 16px; vertical-align: middle; }

/* ---------- Welcome ---------- */
.welcome { align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 50% 30%, var(--bg-2), var(--bg)); }
.welcome-inner { text-align: center; animation: welcomeIn .6s cubic-bezier(.2,.9,.3,1.3); }
.welcome-check { width: 90px; height: 90px; border-radius: 50%; background: linear-gradient(135deg, var(--scan), var(--scan-deep)); display: grid; place-items: center; margin: 0 auto 20px; box-shadow: 0 0 40px var(--scan-glow); }
.welcome-check svg { width: 48px; height: 48px; color: #041018; stroke-width: 3; }
.welcome-hi { color: var(--text-dim); font-size: 18px; }
.welcome-name { font-family: var(--font-disp); font-size: 30px; font-weight: 700; margin: 4px 0 10px; }
.welcome-msg { color: var(--text-dim); font-size: 15px; max-width: 300px; margin: 0 auto; }
@keyframes welcomeIn { from { opacity: 0; transform: translateY(20px) scale(.95); } to { opacity: 1; transform: none; } }

/* ---------- App shell ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-l { display: flex; align-items: center; gap: 12px; }
.topbar-badge { width: 40px; height: 40px; padding: 8px; background: var(--surface-2); border-radius: 12px; color: var(--scan); }
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-sub { color: var(--text-dim); font-size: 13px; }

.tabbar { display: flex; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 73px; z-index: 19; overflow-x: auto; }
.tab { flex: 1; min-width: 78px; background: none; border: none; color: var(--text-mute); padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 12px; font-family: var(--font-body); font-weight: 600; border-bottom: 3px solid transparent; transition: color .2s, border-color .2s; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--scan); border-bottom-color: var(--scan); }

.content { padding: 20px 18px 40px; max-width: 640px; margin: 0 auto; }

/* ---------- Panes ---------- */
.tabpane { display: none; }
.tabpane.active { display: block; animation: fadeUp .3s; }
.op-view { display: none; }
.op-view.active { display: block; animation: fadeUp .3s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pane-title { font-family: var(--font-disp); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.pane-hint { color: var(--text-dim); font-size: 14px; margin-bottom: 18px; line-height: 1.5; }

/* ---------- Cards & inputs ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 12px 0 6px; }
.field-help { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.input, .select {
  width: 100%; background: var(--bg-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; color: var(--text); font-size: 16px; font-family: var(--font-body);
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus { outline: none; border-color: var(--scan); box-shadow: 0 0 0 3px var(--scan-glow); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3c4' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 44px; }
.input-big-num { font-size: 28px; text-align: center; font-weight: 700; font-family: var(--font-disp); }

.input-icon { position: relative; margin-bottom: 4px; }
.input-icon svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-mute); }
.input-icon input { width: 100%; background: var(--bg-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px 14px 44px; color: var(--text); font-size: 16px; }
.input-icon input:focus { outline: none; border-color: var(--scan); box-shadow: 0 0 0 3px var(--scan-glow); }
.input-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); left: auto; background: none; border: none; color: var(--text-mute); cursor: pointer; padding: 8px; }
.input-eye svg { position: static; transform: none; }

.input-row { display: flex; gap: 10px; }
.input-row .input { flex: 1; }
.input-row .btn { flex-shrink: 0; padding: 14px 18px; }

.form-error { color: var(--red); font-size: 13px; padding: 8px 0; font-weight: 600; }

/* ---------- Logo uploader ---------- */
.logo-uploader { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.logo-preview { width: 72px; height: 72px; border-radius: 14px; background: var(--bg-2); border: 1.5px dashed var(--border); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.logo-preview svg { width: 28px; height: 28px; color: var(--text-mute); }
.logo-actions { display: flex; flex-direction: column; gap: 6px; }
.logo-hint { font-size: 12px; color: var(--text-mute); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-item-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-item-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.list-item-ic svg { width: 20px; height: 20px; color: var(--scan); }
.list-item-txt { min-width: 0; }
.list-item-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-sub { color: var(--text-dim); font-size: 13px; }
.list-empty { text-align: center; color: var(--text-mute); padding: 30px; font-size: 14px; }
.chip-del { background: var(--red-glow); color: var(--red); border: none; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.chip-del svg { width: 18px; height: 18px; }

/* ---------- Operario: hero ---------- */
.hero-inv { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 24px; text-align: center; margin-bottom: 18px; box-shadow: var(--shadow); }
.hero-inv-icon { width: 52px; height: 52px; color: var(--scan); margin-bottom: 12px; }
.hero-inv h3 { font-family: var(--font-disp); font-size: 22px; margin-bottom: 6px; }
.hero-inv p { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; }

/* ---------- Inventario en curso ---------- */
.inv-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.inv-name { font-family: var(--font-disp); font-size: 20px; font-weight: 700; }
.inv-date { color: var(--text-dim); font-size: 13px; }
.badge-conteo { background: var(--scan-glow); color: var(--scan); font-weight: 700; font-size: 13px; padding: 8px 14px; border-radius: 20px; }

.conteo-switch { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px; margin-bottom: 16px; }
.cs-btn { flex: 1; background: none; border: none; color: var(--text-dim); font-family: var(--font-body); font-weight: 700; font-size: 15px; padding: 12px; border-radius: 10px; cursor: pointer; transition: all .2s; }
.cs-btn.active { background: linear-gradient(135deg, var(--scan), var(--scan-deep)); color: #041018; }
.cs-btn[data-conteo="2"].active { background: linear-gradient(135deg, var(--amber), #d97706); color: #1a1000; }

/* ---------- Contador gigante ---------- */
.counter-big { background: linear-gradient(160deg, var(--surface), var(--surface-2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; margin: 16px 0; position: relative; overflow: hidden; }
.counter-big::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 0%, var(--scan-glow), transparent 60%); pointer-events: none; }
.counter-label { color: var(--text-dim); font-size: 14px; position: relative; }
.counter-num { font-family: var(--font-disp); font-size: 72px; font-weight: 700; line-height: 1; color: var(--scan); margin: 6px 0; position: relative; text-shadow: 0 0 30px var(--scan-glow); }
.counter-num.pulse { animation: pulseNum .3s; }
@keyframes pulseNum { 50% { transform: scale(1.12); } }
.counter-total { color: var(--text-mute); font-size: 13px; position: relative; }

/* ---------- Scan input ---------- */
.scan-input-wrap { position: relative; margin-bottom: 12px; }
.scan-input-wrap svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; color: var(--scan); }
.scan-input { width: 100%; background: var(--bg-2); border: 2px solid var(--scan); border-radius: var(--radius); padding: 18px 18px 18px 52px; color: var(--text); font-size: 18px; font-family: var(--font-disp); letter-spacing: .5px; box-shadow: 0 0 0 3px var(--scan-glow); }
.scan-input:focus { outline: none; }
.scan-input::placeholder { color: var(--text-mute); font-family: var(--font-body); letter-spacing: 0; }

.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }

.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; font-weight: 600; color: var(--text-dim); }
.link-btn { background: none; border: none; color: var(--scan); font-family: var(--font-body); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.link-btn svg { width: 16px; height: 16px; }

.scan-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.scan-row { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; animation: scanIn .3s; }
@keyframes scanIn { from { opacity: 0; transform: translateX(-10px); background: var(--scan-glow); } to { opacity: 1; transform: none; } }
.scan-row-code { font-family: var(--font-disp); font-weight: 600; font-size: 15px; }
.scan-row-cat { font-size: 12px; color: var(--text-mute); }
.scan-row-qty { background: var(--scan-glow); color: var(--scan); font-weight: 700; padding: 4px 12px; border-radius: 20px; font-size: 15px; }
.scan-row-info { min-width: 0; flex: 1; }
.scan-row-actions { display: flex; align-items: center; gap: 8px; }
.scan-edit, .scan-del { background: var(--surface-2); border: none; border-radius: 9px; padding: 8px; cursor: pointer; display: grid; place-items: center; transition: background .2s; }
.scan-edit svg, .scan-del svg { width: 17px; height: 17px; }
.scan-edit { color: var(--scan); }
.scan-edit:hover { background: var(--scan-glow); }
.scan-del { color: var(--red); }
.scan-del:hover { background: var(--red-glow); }
.btn-volver { background: transparent; border: none; color: var(--text-dim); font-family: var(--font-body); font-weight: 600; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 8px 0; margin-bottom: 8px; transition: color .2s; }
.btn-volver:hover { color: var(--scan); }
.btn-volver svg { width: 20px; height: 20px; }

.inv-footer { margin-top: 24px; }

/* ---------- Modales ---------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(4,10,22,.75); backdrop-filter: blur(4px); z-index: 100; align-items: flex-end; justify-content: center; padding: 0; }
.modal.active { display: flex; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: var(--surface); border-radius: 24px 24px 0 0; padding: 24px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; animation: slideUp .3s cubic-bezier(.2,.9,.3,1); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-lg { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-family: var(--font-disp); font-size: 20px; font-weight: 700; }

@media (min-width: 560px) {
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: 24px; }
}

/* ---------- Cámara ---------- */
.cam-reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; min-height: 260px; }
.cam-hint { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 12px; }

/* ---------- Comparación ---------- */
.compare-tablero { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.tab-card { border-radius: 14px; padding: 16px 10px; text-align: center; border: 1px solid var(--border); }
.tab-card.c1 { background: var(--scan-glow); }
.tab-card.c2 { background: var(--amber-glow); }
.tab-card.diff { background: var(--red-glow); }
.tab-card-lbl { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.tab-card-num { font-family: var(--font-disp); font-size: 34px; font-weight: 700; line-height: 1.1; }
.tab-card.c1 .tab-card-num { color: var(--scan); }
.tab-card.c2 .tab-card-num { color: var(--amber); }
.tab-card.diff .tab-card-num { color: var(--red); }
.tab-card-sub { font-size: 11px; color: var(--text-mute); }

.compare-scroll { max-height: 50vh; overflow-y: auto; }
.compare-block { margin-bottom: 12px; }
.compare-block-title { font-weight: 700; font-size: 14px; margin: 12px 0 8px; display: flex; align-items: center; gap: 8px; }
.compare-block-title svg { width: 18px; height: 18px; }
.cmp-row { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmp-row.ok { border-left: 3px solid var(--green); }
.cmp-row.warn { border-left: 3px solid var(--amber); }
.cmp-row.bad { border-left: 3px solid var(--red); }
.cmp-code { font-family: var(--font-disp); font-weight: 600; font-size: 14px; }
.cmp-cat { font-size: 12px; color: var(--text-mute); }
.cmp-vals { font-size: 13px; color: var(--text-dim); text-align: right; }
.cmp-vals b { color: var(--text); }
.cmp-msg { font-size: 12px; color: var(--amber); }

/* ---------- Informe / formato ---------- */
.fmt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.fmt-btn { background: var(--bg-2); border: 2px solid var(--border); border-radius: 14px; padding: 18px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; color: var(--text); font-family: var(--font-body); transition: all .2s; }
.fmt-btn svg { width: 26px; height: 26px; color: var(--scan); }
.fmt-btn span { font-weight: 600; font-size: 14px; }
.fmt-btn small { color: var(--text-mute); font-size: 11px; }
.fmt-btn.active { border-color: var(--scan); background: var(--scan-glow); }
.informe-accion { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 20px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; padding: 0 16px; }
.toast { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 14px 20px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; animation: toastIn .3s; max-width: 400px; }
.toast svg { width: 20px; height: 20px; flex-shrink: 0; }
.toast.ok { border-left: 4px solid var(--green); } .toast.ok svg { color: var(--green); }
.toast.err { border-left: 4px solid var(--red); } .toast.err svg { color: var(--red); }
.toast.info { border-left: 4px solid var(--scan); } .toast.info svg { color: var(--scan); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* ---------- Panel Central (root) ---------- */
.root-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.root-head .pane-title { margin-bottom: 0; }
