/* =====================================================================
   MantecaApp — Design system
   Inspirado en referencias: dark mode + acento lime green, cards redondeados,
   tipografía moderna tipo enterprise.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Base dark */
  --bg:            #0A0A0A;
  --bg-elev:       #141414;
  --surface:       #1A1A1A;
  --surface-2:     #222222;
  --border:        #2A2A2A;
  --border-soft:   #1F1F1F;

  /* Overlays para topbar/tabs/modal (cambian entre temas) */
  --overlay-bar:   rgba(10,10,10,.72);
  --overlay-tabs:  rgba(10,10,10,.92);
  --modal-bg:      rgba(0,0,0,.70);

  /* Light surfaces para cards que imitan referencias */
  --card-light:    #F4F4F2;
  --card-light-2:  #ECECEA;
  --on-light:      #0A0A0A;
  --muted-light:   #6B6B6B;

  /* Accent lime (tomado de referencias) */
  --lime:          #C3F53C;
  --lime-2:        #B4E832;
  --lime-soft:     #E4FB8F;
  --lime-glow:     rgba(195,245,60,.35);

  /* Text */
  --text:          #F5F5F4;
  --text-dim:      #A3A3A3;
  --muted:         #6B6B6B;

  /* Status */
  --ok:            #6EE7A0;
  --warn:          #FFB020;
  --err:           #FF5C5C;

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-1: 0 1px 0 rgba(255,255,255,.04) inset, 0 8px 24px rgba(0,0,0,.35);
  --shadow-2: 0 10px 40px rgba(0,0,0,.45);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ═══════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════════════════════ */
html[data-theme="light"] {
  --bg:            #FAFAF7;
  --bg-elev:       #F2F2EE;
  --surface:       #FFFFFF;
  --surface-2:     #EFEFEA;
  --border:        #E1E1DC;
  --border-soft:   #EDEDE8;

  --overlay-bar:   rgba(250,250,247,.82);
  --overlay-tabs:  rgba(255,255,255,.92);
  --modal-bg:      rgba(30,30,30,.45);

  --text:          #0A0A0A;
  --text-dim:      #5C5C5C;
  --muted:         #7A7A7A;

  --shadow-1: 0 1px 0 rgba(0,0,0,.03) inset, 0 6px 18px rgba(0,0,0,.06);
  --shadow-2: 0 10px 40px rgba(0,0,0,.12);
}
html[data-theme="light"] body::before {
  background: radial-gradient(1200px 600px at 85% -10%, rgba(195,245,60,.12), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(195,245,60,.08), transparent 60%);
}
html[data-theme="light"] .brand-mark { box-shadow: 0 0 0 2px rgba(0,0,0,.04), 0 6px 20px var(--lime-glow); }
html[data-theme="light"] .btn-dark   { background: #0A0A0A; color: #fff; }
html[data-theme="light"] .btn-danger { background: #FFECEC; color: #B91C1C; border-color: #FBC5C5; }
html[data-theme="light"] .btn-ok     { background: #E6F9EE; color: #0A7A3F; border-color: #BFEAD1; }
html[data-theme="light"] .mov-icon.entrada { background: #E6F9EE; color: #0A7A3F; }
html[data-theme="light"] .mov-icon.salida  { background: #FFECEC; color: #B91C1C; }
html[data-theme="light"] .tab.active { background: rgba(195,245,60,.24); color: #0A0A0A; }
html[data-theme="light"] .tab { color: var(--muted); }
html[data-theme="light"] .login-card::before { background: radial-gradient(circle, rgba(195,245,60,.45), transparent 60%); }
html[data-theme="light"] .gbtn { background: #0A0A0A; color: #fff; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "ss01","cv11";
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Subtle radial glow behind the whole app */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(195,245,60,.08), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgba(195,245,60,.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}
#app-root { position: relative; z-index: 1; }

/* ═══════════════════════════════════════════════════════════
   HEADER / TOPBAR
   ═══════════════════════════════════════════════════════════ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--overlay-bar);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: nowrap;
}
/* Topbar compacto en mobile */
@media (max-width: 480px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand-mark { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; }
  .brand-name { font-size: 14px; }
  .brand-sub  { font-size: 9px; letter-spacing: 1px; }
  .user-chip  { padding: 4px 8px 4px 4px; font-size: 11px; }
  .user-chip img { width: 22px; height: 22px; }
  .user-chip .role { font-size: 8px; padding: 1px 6px; }
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: -.02em;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--lime);
  color: #0A0A0A;
  display: grid; place-items: center;
  font-weight: 900;
  box-shadow: 0 0 0 2px rgba(255,255,255,.04), 0 6px 20px var(--lime-glow);
}
.brand-name   { font-size: 16px; }
.brand-sub    { font-size: 10px; color: var(--text-dim); font-family: var(--mono); letter-spacing: 1.2px; }
.topbar-spacer { flex: 1; }

/* User chip in topbar */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip img {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--border);
}
.user-chip .role {
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 9px;
  font-weight: 800;
  background: var(--lime);
  color: #0A0A0A;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.user-chip .role.empleado { background: var(--surface-2); color: var(--text); }
.user-chip .role.pending  { background: var(--warn);      color: #0A0A0A; }

/* ═══════════════════════════════════════════════════════════
   TABS (bottom-nav mobile-first)
   ═══════════════════════════════════════════════════════════ */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  max-width: 760px;
  margin: 0 auto;
  background: var(--overlay-tabs);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-top: 1px solid var(--border-soft);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  gap: 4px;
}
/* En desktop la barra se ve como pill centrada abajo */
@media (min-width: 760px) {
  .tabs {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(680px, calc(100% - 32px));
    bottom: 16px;
    border-radius: 22px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.02) inset;
    padding: 8px;
  }
}
.tab {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 2px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 10px; font-weight: 700;
  letter-spacing: .3px;
  transition: all .15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab .i { font-size: 20px; margin-bottom: 2px; line-height: 1; }
@media (max-width: 360px) {
  .tab { font-size: 9px; }
  .tab .i { font-size: 18px; }
}
.tab.active { color: var(--lime); background: rgba(195,245,60,.08); }
.tab.active .i { transform: scale(1.08); }

/* ═══════════════════════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════════════════════ */
.section {
  display: none;
  padding: 18px 18px 120px;
  animation: sec-in .25s ease;
}
.section.active { display: block; }
@keyframes sec-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.eyebrow::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--lime); box-shadow: 0 0 8px var(--lime-glow);
}

h1.page-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -.03em;
  margin-bottom: 16px;
}
h1.page-title .hl {
  color: var(--lime);
  font-style: italic;
}
h1.page-title .pill {
  display: inline-block;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--lime);
  color: #0A0A0A;
  font-style: normal;
}
.subtitle { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin-bottom: 18px; max-width: 520px; }

.sec-hdr {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 18px; font-weight: 800; letter-spacing: -.02em;
  margin-bottom: 14px;
}
.sec-hdr .badge {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  border: 1px solid var(--border); padding: 3px 10px; border-radius: var(--r-pill);
}

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-1);
}
.card.light {
  background: var(--card-light);
  color: var(--on-light);
  border-color: transparent;
}
.card.lime {
  background: var(--lime);
  color: #0A0A0A;
  border-color: transparent;
}

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative; overflow: hidden;
}
.stat-card .k { font-family: var(--mono); font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.stat-card .v { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; line-height: 1; }
.stat-card.accent { background: var(--lime); color: #0A0A0A; border-color: transparent; }
.stat-card.accent .k { color: rgba(10,10,10,.72); }

/* Product cards — variantes tipo referencia (mezcla light / lime / dark) */
.products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.product-card {
  border-radius: var(--r-lg);
  padding: 16px 16px 18px;
  position: relative; overflow: hidden;
  min-height: 148px;
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--border);
  background: var(--surface);
}
.product-card.v-light { background: var(--card-light); color: var(--on-light); border-color: transparent; }
.product-card.v-lime  { background: var(--lime);       color: #0A0A0A;         border-color: transparent; }
.product-card .p-size { font-size: 28px; font-weight: 900; letter-spacing: -.03em; line-height: 1; }
.product-card .p-unit { font-size: 11px; opacity: .6; margin-top: 2px; font-weight: 600; }
.product-card .p-stock {
  font-family: var(--mono);
  font-size: 40px; font-weight: 500; line-height: 1;
  letter-spacing: -.04em;
}
.product-card .p-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; margin-top: 2px; }
.product-card .p-plus {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #0A0A0A; color: var(--lime);
  display: grid; place-items: center;
  font-size: 16px; font-weight: 700;
}
.product-card.v-lime .p-plus { background: #0A0A0A; color: var(--lime); }
.product-card.v-light .p-plus{ background: #0A0A0A; color: var(--lime); }

/* Variante "pill" para mostrar tamaño (p.ej. "250g", "4Lt") sin recortar */
.product-card .p-size-badge {
  position: absolute; top: 12px; right: 12px;
  background: #0A0A0A; color: var(--lime);
  font-family: var(--mono);
  font-size: 11px; font-weight: 700;
  letter-spacing: .4px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-card .p-stock.low { color: var(--err); }
.product-card.v-light .p-stock.low,
.product-card.v-lime  .p-stock.low { color: #A6001F; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 15px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.01em;
  cursor: pointer;
  transition: transform .08s ease, opacity .12s ease, background .12s ease;
}
.btn:active { transform: scale(.985); opacity: .92; }
.btn + .btn { margin-top: 10px; }

.btn-primary { background: var(--lime); color: #0A0A0A; box-shadow: 0 8px 24px var(--lime-glow); }
.btn-primary:hover { background: var(--lime-2); }
.btn-dark    { background: #0A0A0A; color: #fff; border-color: var(--border); }
.btn-ghost   { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-danger  { background: #2A1414; color: #FFB4B4; border-color: #4A1F1F; }
.btn-ok      { background: rgba(110,231,160,.12); color: var(--ok); border-color: rgba(110,231,160,.25); }

.btn-sm { padding: 10px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-icon { width: 44px; padding: 0; }
.row-btns { display: flex; gap: 10px; }
.row-btns .btn { margin: 0; }

/* Arrow badge (ver referencias: esquina superior derecha) */
.arrow-badge {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 50%;
  background: #0A0A0A; color: var(--lime);
  display: grid; place-items: center;
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════ */
label {
  display: block;
  font-size: 10px; font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
input[type="text"], input[type="number"], input[type="email"], select {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  transition: border-color .15s;
  -webkit-appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--lime);
  box-shadow: 0 0 0 3px var(--lime-glow);
}

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

.qty-control {
  display: inline-flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.qty-btn {
  width: 44px; height: 44px;
  background: transparent; border: none;
  color: var(--text); font-size: 22px; font-weight: 600;
  cursor: pointer;
}
.qty-btn:hover { background: var(--surface-2); }
.qty-val {
  width: 58px; text-align: center;
  background: transparent; border: none;
  color: var(--text); font-family: var(--mono); font-size: 16px;
}
.qty-val:focus { outline: none; }

/* ═══════════════════════════════════════════════════════════
   CHIPS / FILTERS
   ═══════════════════════════════════════════════════════════ */
.chip-row {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  margin-bottom: 14px;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: background .12s, color .12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.active {
  background: var(--lime);
  color: #0A0A0A;
  border-color: transparent;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   SCANNER
   ═══════════════════════════════════════════════════════════ */
.scan-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: #000;
  margin-bottom: 14px;
  aspect-ratio: 4 / 3;
}
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan-frame {
  width: 74%; height: 56%;
  border: 2px solid var(--lime);
  border-radius: var(--r-md);
  position: relative;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.55);
}
.scan-line {
  position: absolute; left: 6%; right: 6%;
  height: 2px; background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
  animation: scanline 1.8s ease-in-out infinite;
}
@keyframes scanline { 0%,100% { top: 6%; } 50% { top: 92%; } }
.scan-corner { position: absolute; width: 22px; height: 22px; border-color: var(--lime); border-style: solid; }
.sc-tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.sc-tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; }
.sc-bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; }
.sc-br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }

.scan-idle {
  border-radius: var(--r-xl);
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.scan-idle .big-icon { font-size: 46px; margin-bottom: 14px; display: block; }
.scan-idle h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; letter-spacing: -.02em; }
.scan-idle p  { color: var(--text-dim); font-size: 13px; line-height: 1.6; }

.sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
  font-size: 11px; font-family: var(--mono); letter-spacing: 1px; text-transform: uppercase;
  margin: 16px 0;
}
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ═══════════════════════════════════════════════════════════
   SCAN RESULT
   ═══════════════════════════════════════════════════════════ */
.result-card {
  display: none;
  border-radius: var(--r-xl);
  padding: 20px;
  background: var(--card-light);
  color: var(--on-light);
  margin-top: 14px;
  position: relative; overflow: hidden;
}
.result-card.show { display: block; }
.result-card .rname { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 4px; word-break: break-word; }
.result-card .rcode { font-family: var(--mono); font-size: 12px; color: var(--muted-light); margin-bottom: 16px; word-break: break-all; }
.result-card .result-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.result-card .qty-label { font-size: 13px; color: var(--muted-light); font-weight: 600; }
.result-card .qty-control {
  background: #fff; border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.result-card .r-qty {
  font-family: var(--mono);
  font-size: 28px; font-weight: 800;
  color: #B91C1C;
  letter-spacing: -.02em;
}
.result-card .r-meta {
  font-size: 12px;
  color: var(--muted-light);
  font-family: var(--mono);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   MOVIMIENTOS LIST
   ═══════════════════════════════════════════════════════════ */
.mov-list { display: flex; flex-direction: column; gap: 8px; }
.mov-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 0;
}
.mov-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 16px;
}
.mov-icon.entrada { background: rgba(110,231,160,.12); color: var(--ok); }
.mov-icon.salida  { background: rgba(255,92,92,.12);  color: var(--err); }
.mov-icon.ajuste  { background: rgba(195,245,60,.12); color: var(--lime); }
.mov-info { flex: 1; min-width: 0; }
.mov-product { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-meta    { font-size: 11px; color: var(--text-dim); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-qty {
  font-family: var(--mono);
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.mov-qty.entrada { color: var(--ok); }
.mov-qty.salida  { color: var(--err); }
.mov-qty.ajuste  { color: var(--lime); }

/* ═══════════════════════════════════════════════════════════
   CONFIG
   ═══════════════════════════════════════════════════════════ */
.cfg-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 10px;
}
.cfg-name { font-size: 15px; font-weight: 800; margin-bottom: 12px; letter-spacing: -.01em; }
.cfg-status {
  font-family: var(--mono); font-size: 11px; margin-top: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
}
.cfg-status.ok  { background: rgba(110,231,160,.10); color: var(--ok); }
.cfg-status.bad { background: rgba(255,92,92,.10);  color: var(--err); }

.adj-row {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  row-gap: 8px;
  align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 14px;
  margin-bottom: 8px;
}
.adj-name {
  font-weight: 700; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
/* En pantallas muy angostas bajamos el qty-control debajo del nombre */
@media (max-width: 440px) {
  .adj-row { grid-template-columns: 1fr; }
  .adj-row .qty-control { justify-self: start; }
}

/* ═══════════════════════════════════════════════════════════
   USERS ADMIN
   ═══════════════════════════════════════════════════════════ */
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.user-row img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.user-row .info { flex: 1; min-width: 0; }
.user-row .un { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .ue { font-family: var(--mono); font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row select {
  background: var(--surface-2);
  padding: 6px 8px; font-size: 12px;
  width: auto; min-width: 110px;
}

/* Bloque destacado de pendientes */
.pending-block {
  border-radius: var(--r-lg);
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,176,32,.10) 0%, rgba(255,176,32,.04) 100%);
  border: 1px solid rgba(255,176,32,.35);
  margin-bottom: 16px;
}
.pending-block .sec-hdr { color: var(--warn); }
.badge.badge-warn {
  background: var(--warn);
  color: #0A0A0A;
  border: none;
  font-weight: 800;
}
.pending-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 10px;
}
.pending-card img {
  grid-row: 1; grid-column: 1;
  width: 44px; height: 44px;
  border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border);
  align-self: center;
}
.pending-card .info {
  grid-row: 1; grid-column: 2;
  min-width: 0;
  align-self: center;
  overflow: hidden;
}
.pending-card .un {
  font-weight: 800; font-size: 15px; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pending-card .ue {
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pending-actions {
  grid-row: 2; grid-column: 1 / -1;
  display: flex; gap: 8px;
  flex-wrap: wrap;
}
.pending-actions .btn {
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  flex: 1 1 130px;
  min-width: 0;
}
@media (min-width: 640px) {
  .pending-card {
    grid-template-columns: 44px 1fr auto;
    grid-template-rows: auto auto;
  }
  .pending-actions { grid-row: 2; grid-column: 1 / -1; }
  .pending-actions .btn { flex: 0 1 auto; font-size: 13px; padding: 10px 16px; }
}

/* Punto rojo indicador sobre el tab */
.tab { position: relative; }
.tab .tab-dot {
  position: absolute;
  top: 4px; right: 16px;
  width: 8px; height: 8px;
  background: var(--err);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,92,92,.6);
}

/* ═══════════════════════════════════════════════════════════
   TOAST / FEEDBACK
   ═══════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  left: 18px; right: 18px;
  bottom: 88px;
  max-width: 640px; margin-inline: auto;
  padding: 14px 18px;
  background: var(--lime);
  color: #0A0A0A;
  border-radius: var(--r-md);
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px var(--lime-glow);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.err  { background: var(--err); color: #fff; box-shadow: 0 10px 30px rgba(255,92,92,.3); }

/* ═══════════════════════════════════════════════════════════
   EMPTY
   ═══════════════════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
  font-size: 13px;
}
.empty .ei { font-size: 42px; display: block; margin-bottom: 10px; opacity: .6; }

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  position: relative;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-2);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--lime-glow), transparent 60%);
  pointer-events: none;
}
.login-card .brand-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.login-card .eyebrow { margin-top: 16px; }
.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-top: 6px; margin-bottom: 8px;
}
.login-card h1 .hl { color: var(--lime); }
.login-card p { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin-bottom: 22px; }

.gbtn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: #fff;
  color: #0A0A0A;
  font-weight: 700; font-size: 14px;
  border: none; cursor: pointer;
  transition: transform .08s;
}
.gbtn:active { transform: scale(.985); }
.gbtn svg { width: 20px; height: 20px; }

.login-footnote {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.55;
  font-family: var(--mono);
}
.login-error {
  background: rgba(255,92,92,.08);
  border: 1px solid rgba(255,92,92,.3);
  color: var(--err);
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 18px;
}

/* ═══════════════════════════════════════════════════════════
   THEME TOGGLE
   ═══════════════════════════════════════════════════════════ */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: grid; place-items: center;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s, transform .08s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle:active { transform: scale(.94); }
@media (max-width: 480px) {
  .theme-toggle { width: 32px; height: 32px; font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.modal {
  position: fixed; inset: 0;
  z-index: 9998;
  background: var(--modal-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  box-shadow: var(--shadow-2);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  animation: modal-pop .22s ease;
}
@keyframes modal-pop { from { transform: translateY(10px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title {
  font-size: 20px; font-weight: 800; letter-spacing: -.02em;
  margin-bottom: 6px;
}
.modal-sub {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.modal-code {
  font-family: var(--mono); font-size: 14px;
  background: var(--surface); color: var(--text);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  word-break: break-all;
  margin-bottom: 16px;
}
.modal-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 6px;
}
.modal-actions .btn { margin: 0; }

/* ═══════════════════════════════════════════════════════════
   SUB-TABS (dentro de Ajustes)
   ═══════════════════════════════════════════════════════════ */
.sub-tabs {
  display: flex; gap: 6px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 10px;
  margin: 0 -4px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  letter-spacing: .2px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  transition: background .12s, color .12s, border-color .12s;
}
.sub-tab:hover { background: var(--surface-2); color: var(--text); }
.sub-tab.active {
  background: var(--lime);
  color: #0A0A0A;
  border-color: transparent;
}
.sub-tab .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--err);
  box-shadow: 0 0 6px rgba(255,92,92,.6);
}
.sub-panel { display: none; }
.sub-panel.active { display: block; animation: sec-in .22s ease; }

/* Layout de acciones rápidas para Cerrar sesión */
.session-block {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 420px;
}
.session-block .me {
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.session-block .me img {
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--border);
}
.session-block .me .mn { font-weight: 800; font-size: 15px; }
.session-block .me .mm { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE FIXES
   ═══════════════════════════════════════════════════════════ */
/* Grillas de productos y ajustes: 2 cols en mobile, 3 en tablet, 4 en desktop */
@media (min-width: 640px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-grid    { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .products-grid { grid-template-columns: repeat(4, 1fr); }
}

/* user-row con select/botón: que no se salgan del contenedor */
@media (max-width: 520px) {
  .user-row { flex-wrap: wrap; }
  .user-row .info { flex: 1 1 100%; order: -1; }
  .user-row select { flex: 1; min-width: 0; }
  .user-row .btn-sm { flex: 0 0 auto; }
}

/* (el adj-row ya usa grid, ver arriba) */

/* cfg-item: input no debe desbordar */
.cfg-item input { max-width: 100%; }

/* Títulos un poco más chicos en mobile para que no se corten */
@media (max-width: 380px) {
  h1.page-title { font-size: 24px; }
  .stat-card .v { font-size: 28px; }
}

/* Páginas tienen botton nav fijo — aumentar padding-bottom siempre */
.section { padding-bottom: 140px; }

/* ═══════════════════════════════════════════════════════════
   COST CALCULATOR (Costos)
   ═══════════════════════════════════════════════════════════ */
.cost-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.cost-block .sec-hdr { margin-bottom: 12px; font-size: 16px; }
.cost-block .subtitle { margin-bottom: 12px; font-size: 12px; }

/* <details> como cost-block */
details.cost-block summary {
  list-style: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding-right: 20px;
  position: relative;
}
details.cost-block summary::-webkit-details-marker { display: none; }
details.cost-block summary::after {
  content: '▾';
  position: absolute;
  right: 0;
  font-size: 14px;
  color: var(--text-dim);
  transition: transform .15s;
}
details.cost-block[open] summary::after { transform: rotate(180deg); }
details.cost-block[open] summary { margin-bottom: 12px; }
details.cost-block .badge {
  font-family: var(--mono); font-size: 9px; font-weight: 800;
  background: var(--warn); color: #0A0A0A;
  border: none; padding: 3px 8px; letter-spacing: .8px;
}

.cost-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .cost-grid { grid-template-columns: 1fr; }
}
.cost-field { min-width: 0; }
.cost-field label {
  font-size: 10px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.cost-field input,
.cost-field select {
  padding: 12px 14px;
  font-size: 14px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--mono);
  -webkit-appearance: none;
  appearance: none;
}
.cost-field input[readonly] {
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: default;
  border-style: dashed;
}
.cost-field input[readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}
.cost-field .auto-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  background: var(--lime);
  color: #0A0A0A;
  border-radius: var(--r-pill);
  vertical-align: middle;
}
.cost-field .hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  letter-spacing: .2px;
}

/* Costo unitario auto en tarro */
.cost-tarro .readonly-val {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--lime);
  text-align: left;
}

/* Tarjeta de tarro dinámico */
.cost-tarro {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}
.cost-tarro .t-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.cost-tarro .t-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.cost-tarro .t-rm {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--err);
  cursor: pointer;
  font-size: 14px;
  display: grid; place-items: center;
  transition: background .12s;
}
.cost-tarro .t-rm:hover { background: rgba(255,92,92,.1); }
.cost-tarro .t-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 560px) {
  .cost-tarro .t-grid { grid-template-columns: 1fr 1fr; }
  .cost-tarro .t-grid .cost-field:nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 360px) {
  .cost-tarro .t-grid { grid-template-columns: 1fr; }
  .cost-tarro .t-grid .cost-field:nth-child(3) { grid-column: auto; }
}
.cost-tarro input {
  padding: 10px 12px;
  font-size: 13px;
}

/* Precios de venta dinámicos */
.cost-pv-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.cost-pv-row .pv-name {
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.cost-pv-row .pv-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}
.cost-pv-row input {
  width: 130px;
  padding: 10px 12px;
  font-size: 13px;
}
@media (max-width: 380px) {
  .cost-pv-row { grid-template-columns: 1fr; }
  .cost-pv-row input { width: 100%; }
}

/* Resultados */
.cost-totals {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.cost-totals .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 13px;
}
.cost-totals .row:last-child { border-bottom: none; }
.cost-totals .row .k {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .3px;
}
.cost-totals .row .v {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.cost-totals .row.highlight .v {
  color: var(--lime);
  font-size: 16px;
}
.cost-totals .row.highlight.bad .v { color: var(--err); }

/* Tabla de detalle */
.cost-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cost-table-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.cost-table-row .ct-name {
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 8px;
  letter-spacing: -.01em;
}
.cost-table-row .ct-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (max-width: 480px) {
  .cost-table-row .ct-grid { grid-template-columns: repeat(2, 1fr); }
}
.cost-table-row .ct-cell { min-width: 0; }
.cost-table-row .ct-k {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.cost-table-row .ct-v {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.cost-table-row .ct-v.win  { color: var(--ok); }
.cost-table-row .ct-v.lose { color: var(--err); }

/* ═══════════════════════════════════════════════════════════
   UTIL
   ═══════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.mono { font-family: var(--mono); }
