/* Electro Nejma Stock — estilos */
:root {
  --red: #E3141B;
  --red-dark: #B80F15;
  --red-soft: #FDECEC;
  --ink: #16181D;
  --ink-2: #23262D;
  --muted: #5B6068;
  --line: #E7E8EB;
  --line-2: #EEF0F2;
  --surface: #F6F6F7;
  --bg: #F4F5F7;
  --ok-bg: #E6F4EA; --ok: #1E6A36;
  --low-bg: #FEF0DC; --low: #9A4A05;
  --out-bg: #FDECEC; --out: #B80F15;
  --radius: 14px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: Poppins, Inter, system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--display); line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* Splash */
.splash { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; background: #fff; }
.splash img { width: 260px; height: auto; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid #D5D7DB; background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { color: var(--red-dark); border-color: #F3C4C6; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red-dark); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.sq { width: 42px; height: 42px; padding: 0; border-radius: 10px; border: 1px solid #D5D7DB; background: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sq:hover { border-color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--red); font-weight: 600; text-decoration: underline; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lbl, .field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.input { min-height: 46px; width: 100%; border: 1px solid #D5D7DB; border-radius: 10px; padding: 0 12px; background: #fff; font-size: 16px; }
textarea.input { padding: 10px 12px; min-height: 90px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sec { font: 700 15px var(--display); margin-top: 6px; }
.err { background: var(--red-soft); color: var(--red-dark); padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.ok { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; }

/* Acceso */
.auth { min-height: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: #fff; }
.auth-side { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding-top: max(48px, env(safe-area-inset-top)); }
.auth-logo { background: #fff; border-radius: 14px; padding: 10px 16px; align-self: flex-start; }
.auth-logo img { height: 56px; width: auto; }
.auth-side h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
.auth-side p { color: #C9CCD1; font-size: 17px; max-width: 420px; margin-top: 12px; }
.auth-main { padding: 48px clamp(24px, 6vw, 72px); display: flex; flex-direction: column; justify-content: center; gap: 18px; max-width: 560px; width: 100%; }
.auth-main form { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; padding-top: max(28px, env(safe-area-inset-top)); }
  .auth-side p { display: none; }
  .auth-main { padding: 28px 20px; }
}

/* Estructura */
.shell { height: 100%; display: flex; }
.side { width: 232px; flex-shrink: 0; background: var(--ink); color: #fff; display: flex; flex-direction: column; padding: 18px 14px; gap: 18px; padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); padding-left: max(14px, env(safe-area-inset-left)); }
.side-logo { background: #fff; border-radius: 12px; padding: 8px 10px; display: flex; justify-content: center; }
.side-logo img { height: 46px; width: auto; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: #C9CCD1; font-weight: 500; font-size: 15px; text-align: left; }
.nav button:hover { background: var(--ink-2); color: #fff; }
.nav button.on { background: var(--red); color: #fff; }
.me { margin-top: auto; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid #2E3138; padding-top: 14px; }
.me-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 700 15px var(--display); flex-shrink: 0; color: #fff; }
.me-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 12px; color: #9AA0A8; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { min-height: 72px; flex-shrink: 0; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px 16px; padding: 10px 24px; flex-wrap: wrap; padding-top: max(10px, env(safe-area-inset-top)); padding-right: max(24px, env(safe-area-inset-right)); }
.top h1 { font-size: 22px; }
.top-sub { font-size: 13px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.banner { background: #FFF7E8; color: #7A3E04; font-size: 14px; padding: 10px 24px; border-bottom: 1px solid #F6DFB8; }
.content { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 18px; padding-right: max(24px, env(safe-area-inset-right)); -webkit-overflow-scrolling: touch; }

@media (max-width: 860px) {
  .shell { flex-direction: column-reverse; }
  .side { width: 100%; flex-direction: row; padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); gap: 0; }
  .side-logo, .me-row { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 2px; }
  .nav button { flex-direction: column; gap: 2px; font-size: 11px; min-height: 54px; padding: 4px; justify-content: center; text-align: center; }
  .me { margin: 0; border: 0; padding: 0; }
  .me .nav-out { flex-direction: column; gap: 2px; font-size: 11px; min-height: 54px; padding: 4px 8px; }
  .top { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .content { padding: 16px; }
  .banner { padding: 10px 16px; }
}

/* Cajas */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.tile b { font: 700 28px var(--display); font-variant-numeric: tabular-nums; }
.tile small { font-size: 13px; color: var(--muted); }
.tile-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.tile-dark .lbl, .tile-dark small { color: #C9CCD1; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.panel { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head h2 { font-size: 17px; }
.list-btn { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-bottom: 1px solid var(--line-2); background: transparent; padding: 8px 0; text-align: left; min-height: 54px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* Píldoras */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-low { background: var(--low-bg); color: var(--low); }
.pill-out { background: var(--out-bg); color: var(--out); }
.pill-grey { background: #F1F2F4; color: var(--ink); }

/* Filtros */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 260px; }
.search .input { padding-left: 42px; }
.search svg { position: absolute; left: 13px; top: 14px; color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip small { font-size: 12px; opacity: .7; }

/* Tabla de productos */
.table { overflow: hidden; }
.row { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(0, .9fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, .9fr) 176px; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: 0; }
.row-head { background: var(--surface); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding-block: 12px; }
.prod { display: flex; align-items: center; gap: 12px; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.thumb { width: 48px; height: 48px; border-radius: 10px; background: var(--surface); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--red); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-name { display: block; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-sub { font-size: 12.5px; color: var(--muted); }
.stockcell { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.price { font: 700 16px var(--display); font-variant-numeric: tabular-nums; }
.acts { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 1000px) {
  .row { grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.1fr) minmax(0, 1fr) 170px; }
  .row .c-cat, .row .c-loc { display: none; }
}
@media (max-width: 640px) {
  .row-head { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "p p" "s pr" "a a"; row-gap: 10px; }
  .row .c-prod { grid-area: p; }
  .row .c-stock { grid-area: s; }
  .row .c-price { grid-area: pr; text-align: right; }
  .row .c-acts { grid-area: a; justify-content: stretch; }
  .row .c-acts .btn { flex: 1; }
}

/* Ficha lateral */
.scrim { position: fixed; inset: 0; background: rgba(22, 24, 29, .45); border: 0; z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: #fff; z-index: 21; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0, 0, 0, .15); animation: slide .2s ease; }
@keyframes slide { from { transform: translateX(40px); opacity: .6; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); padding-top: max(14px, env(safe-area-inset-top)); }
.drawer-head h2 { font-size: 19px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.photo-main { height: 230px; border-radius: var(--radius); background: var(--surface); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; color: var(--muted); font-size: 14px; text-align: center; padding: 10px; }
.photo-main img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photos { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 6px; }
.ph-wrap { position: relative; }
.ph { width: 66px; height: 66px; padding: 0; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); overflow: hidden; display: block; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph.on { border-color: var(--red); }
.ph-x { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; padding: 0; }
.addph { width: 66px; height: 66px; border-radius: 10px; border: 2px dashed #C9CCD1; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; }
.addph:hover { border-color: var(--red); color: var(--red); }
.money-box { background: #FFF7F7; border: 1px solid #F8D4D5; border-radius: 12px; padding: 14px; }
.stepper { display: flex; gap: 6px; }
.stepper .input { text-align: center; font-weight: 700; font-size: 18px; }
.bigprice { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bigprice b { display: block; font: 800 32px var(--display); }
.bigprice .lbl { color: #C9CCD1; }
.spec { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.spec span:first-child { color: var(--muted); }
.spec span:last-child { font-weight: 600; text-align: right; }
.energy { display: inline-block; min-width: 46px; text-align: center; padding: 4px 10px; border-radius: 6px; font: 800 14px var(--display); }
.desc { font-size: 15px; line-height: 1.6; white-space: pre-line; }
.note { background: var(--surface); border-radius: 12px; padding: 12px 14px; white-space: pre-line; }
.lock { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 14px; }
.confirm { background: var(--red-soft); border-radius: 12px; padding: 12px; display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.uploading { font-size: 13px; color: var(--muted); }

/* Movimientos */
.mrow { display: grid; grid-template-columns: 130px minmax(0, 2fr) minmax(0, 1.5fr) 130px; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); align-items: center; font-size: 14px; }
.mrow-head { background: var(--surface); font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mrow strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .mrow { grid-template-columns: minmax(0, 1fr) auto; }
  .mrow-head { display: none; }
  .mrow .m-when { grid-column: 2; grid-row: 1; text-align: right; font-size: 12px; }
  .mrow .m-who { display: none; }
}

/* Equipo */
.perms { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.perm { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; font-weight: 500; }
.toggle { width: 48px; height: 30px; border-radius: 999px; border: 0; background: #C9CCD1; position: relative; padding: 0; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: #1E7A3C; }
.toggle.on::after { left: 22px; }
.toggle[disabled] { opacity: .5; }

/* Ajustes */
.tagrow { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 6px 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 500; }
.tag button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #F1F2F4; display: inline-flex; align-items: center; justify-content: center; }
.addrow { display: flex; gap: 8px; }

/* Aviso flotante */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; z-index: 50; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100% - 32px); text-align: center; }
.toast.bad { background: var(--red-dark); }
@media (max-width: 860px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
