/* Control de Inventario — estilos (móvil primero, se adapta a PC) */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f6; --text: #111827; --text-2: #5b6474;
  --line: #e2e6ee; --primary: #2952e3; --primary-2: #e8eeff; --on-primary: #ffffff;
  --ok: #0f9d58; --ok-bg: #e6f6ee; --bad: #d93025; --bad-bg: #fdecea; --warn: #b26a00; --warn-bg: #fff4e0;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #161b24; --surface-2: #1f2633; --text: #e8ecf3; --text-2: #9aa4b5;
    --line: #2a3242; --primary: #7c9cff; --primary-2: #1d2a4d; --on-primary: #0b1020;
    --ok: #3ddc84; --ok-bg: #12301f; --bad: #ff6b60; --bad-bg: #3a1714; --warn: #ffb74d; --warn-bg: #3a2a10;
    --shadow: none; --shadow-lg: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #161b24; --surface-2: #1f2633; --text: #e8ecf3; --text-2: #9aa4b5;
  --line: #2a3242; --primary: #7c9cff; --primary-2: #1d2a4d; --on-primary: #0b1020;
  --ok: #3ddc84; --ok-bg: #12301f; --bad: #ff6b60; --bad-bg: #3a1714; --warn: #ffb74d; --warn-bg: #3a2a10;
  --shadow: none; --shadow-lg: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: contain;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.hidden { display: none !important; }

/* ---------- estructura ---------- */
.app { display: flex; min-height: 100%; }
/* Menú lateral: fijo en la PC; en el celular se desliza desde la izquierda con el botón «Menú». */
.sidebar {
  display: flex; flex-direction: column; gap: 4px; width: 248px; overflow-y: auto; padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 4px 8px 18px; }
.brand img { width: auto; height: 40px; padding: 3px 6px; background: #fff; border-radius: 9px; }
.sidebtn {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  background: none; border: 0; color: var(--text-2); text-align: left; font-weight: 500;
}
.sidebtn:hover { background: var(--surface-2); color: var(--text); }
.sidebtn.on { background: var(--primary-2); color: var(--primary); }
.sidebar .sp { flex: 1; }
.velo-menu { display: none; }
@media (max-width: 899px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(300px, 84vw);
    padding: calc(18px + var(--safe-t)) 12px calc(18px + var(--safe-b)); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .22s ease; visibility: hidden;
  }
  body.menu-abierto .sidebar { transform: none; visibility: visible; }
  .velo-menu { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(9,12,20,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.menu-abierto .velo-menu { opacity: 1; pointer-events: auto; }
  body.menu-abierto { overflow: hidden; }
  .sidebtn { padding: 12px; font-size: 1rem; }
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: calc(10px + var(--safe-t)) 16px 10px; display: flex; align-items: center; gap: 10px;
}
.topbar h1 { font-size: 1.25rem; margin: 0; letter-spacing: -.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 0 16px calc(96px + var(--safe-b)); flex: 1; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.navbtn {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .7rem; color: var(--text-2); padding: 4px 0; border-radius: 10px;
}
.navbtn.on { color: var(--primary); font-weight: 600; }
.navbtn { position: relative; }
.nav-punto { position: absolute; top: 4px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.navbtn.scan .fab {
  width: 56px; height: 56px; margin-top: -26px; border-radius: 18px; background: var(--primary);
  color: var(--on-primary); display: grid; place-items: center; box-shadow: var(--shadow-lg);
}
.navbtn.scan .fab svg { width: 28px; height: 28px; }

@media (min-width: 900px) {
  .sidebar { flex: none; position: sticky; top: 0; height: 100vh; }
  .bottomnav { display: none; }
  .topbar { padding: 18px 28px 12px; }
  .topbar h1 { font-size: 1.5rem; }
  .content { padding: 0 28px 40px; }
  .solo-movil { display: none !important; }
}
@media (max-width: 899px) { .solo-pc { display: none !important; } }

/* ---------- componentes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.ghost { background: none; box-shadow: none; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; flex: none; position: relative; box-shadow: var(--shadow);
}
.badge {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; border-radius: 10px; padding: 0 5px;
  background: var(--warn); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center;
}
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; font-size: 16px; /* 16px evita el zoom en iPhone */
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-2); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-2); width: 20px; height: 20px; }
.search .input { padding-left: 44px; padding-right: 48px; }
.search .clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; width: 40px; height: 40px; color: var(--text-2); display: grid; place-items: center; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; margin: 4px 0 12px; }
.segmented button { border: 0; background: none; padding: 8px 4px; border-radius: 9px; font-weight: 600; font-size: .85rem; color: var(--text-2); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px;
  font-size: .87rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip.toggle.on { background: var(--primary-2); border-color: var(--primary); color: var(--primary); }
.kpi.warn b { color: var(--warn); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
td.wrap { white-space: normal; line-height: 1.3; }
@media (max-width: 1500px) { .col-fam { display: none; } }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 6px 0 14px; }
.kpi { padding: 12px 14px; }
.kpi small { display: block; color: var(--text-2); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi b { font-size: 1.35rem; letter-spacing: -.01em; }
.kpi.bad b { color: var(--bad); } .kpi.ok b { color: var(--ok); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(5, 1fr); } .kpi b { font-size: 1.6rem; } }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { padding: 12px 14px; }
.item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-code { font-weight: 700; letter-spacing: .01em; }
.item-desc { margin: 1px 0 6px; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .8rem; color: var(--text-2); }
.item-meta span { display: inline-flex; align-items: center; gap: 4px; }
.item-meta svg { width: 14px; height: 14px; }
.pill { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper button { width: 40px; height: 42px; border: 0; background: var(--surface-2); font-size: 1.2rem; font-weight: 700; flex: none; }
.stepper input { width: 100%; min-width: 0; border: 0; text-align: center; font-weight: 700; font-size: 16px; height: 42px; background: none; outline: none; }
.stepper.changed { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-2); }
.stepper.big button { width: 56px; height: 56px; font-size: 1.5rem; }
.stepper.big input { height: 56px; font-size: 1.5rem; }

/* tabla (PC) */
.tablewrap { overflow: auto; max-height: calc(100vh - 330px); }
/* Inventario: la tabla crece con la página (sin caja con scroll propio); los títulos quedan fijos bajo la barra superior */
#lista .tablewrap { overflow: visible; max-height: none; }
#lista th { top: var(--alto-topbar, 64px); }
#lista th:first-child { border-top-left-radius: var(--radius); } #lista th:last-child { border-top-right-radius: var(--radius); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); z-index: 1; }
td.r, th.r { text-align: right; }
tr:hover td { background: color-mix(in srgb, var(--primary-2) 45%, transparent); }
.cell-edit { width: 96px; height: 34px; text-align: right; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: var(--surface); font-weight: 600; }
.cell-edit:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-2); }
.cell-edit.changed { border-color: var(--primary); background: var(--primary-2); }
.t-bad { color: var(--bad); font-weight: 700; } .t-ok { color: var(--ok); font-weight: 700; } .t-warn { color: var(--warn); font-weight: 600; }

/* ---------- listas en renglones (celular) ---------- */
.lista-c { padding: 0; overflow: hidden; }
.ln { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ln:last-child { border-bottom: 0; }
.ln:active { background: var(--surface-2); }
.ln-est { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line); }
.ln-est.ok { background: var(--ok); } .ln-est.bad { background: var(--bad); } .ln-est.warn { background: var(--warn); }
.ln-txt { flex: 1; min-width: 0; }
.ln-1 { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ln-2 { font-size: .74rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.ln-2 b { color: var(--text); }
.ln-3 { font-size: .74rem; color: var(--text-2); line-height: 1.3; margin-top: 1px; overflow-wrap: anywhere; }
.ln-sec { display: inline-flex; align-items: center; gap: 2px; color: var(--primary); font-weight: 600; }
.ln-sec svg { width: 12px; height: 12px; }
.ln-dif { color: var(--bad); font-weight: 700; }
.ln-num { flex: none; text-align: right; line-height: 1.15; min-width: 40px; }
.ln-num small { display: block; font-size: .62rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; }
.ln-num b { font-size: .95rem; }
.ln-cob { min-width: 76px; } .ln-cob small { text-transform: none; margin-bottom: 2px; } .ln-cob .pill { font-size: .68rem; padding: 2px 7px; }
.ln-real { flex: none; width: 64px; height: 38px; border: 1px solid var(--line); border-radius: 10px; text-align: center; font-weight: 700; font-size: 16px; background: var(--surface); outline: none; }
.ln-real.changed, .ln-real:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-2); }
.ln-chk { width: 22px; height: 22px; flex: none; margin: 0; }

.sec-todos { gap: 8px; margin-top: 8px; font-size: .85rem; color: var(--text-2); cursor: pointer; }
.sec-todos input { width: 18px; height: 18px; margin: 0; flex: none; }

/* ---------- ordenar ---------- */
.orden-fila { gap: 8px; margin: -2px 0 10px; font-size: .85rem; }
.orden-fila > svg { width: 16px; height: 16px; color: var(--text-2); flex: none; }
.sel-orden { width: auto; min-height: 36px; padding: 0 34px 0 12px; font-size: .9rem; background-position: calc(100% - 18px) 15px, calc(100% - 13px) 15px; }
th.ordenable { cursor: pointer; user-select: none; white-space: nowrap; }
th.ordenable:hover { color: var(--text); } th.ordenable.on { color: var(--primary); }

/* ---------- personalización ---------- */
.pers-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .pers-grid { grid-template-columns: 1.2fr 1fr 1fr; align-items: start; } }
.pers-datos, .pers-img { padding: 16px; }
.pers-colores { gap: 10px; margin-bottom: 12px; }
.pers-color { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); padding: 0; cursor: pointer; }
.pers-color.on { box-shadow: 0 0 0 3px var(--text); }
.pers-color.otro { display: grid; place-items: center; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); color: #fff; position: relative; overflow: hidden; }
.pers-color.otro svg { width: 18px; height: 18px; filter: drop-shadow(0 0 2px #000); }
.pers-color.otro input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pers-muestra { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.pers-btn { color: #fff; padding: 8px 14px; border-radius: 10px; font-weight: 700; }
.pers-chip { padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: .85rem; }
.pers-prev { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; }
.pers-prev.logo { background: #fff; height: 150px; padding: 16px; } .pers-prev.logo img { max-width: 100%; max-height: 100%; }
.pers-prev.splash { aspect-ratio: 16 / 9; background: #000; } .pers-prev.splash img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- calendario ---------- */
:root { --priv: #7a4fd0; --priv-bg: #f1ebfd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --priv: #b79bff; --priv-bg: #2a1f45; } }
:root[data-theme="dark"] { --priv: #b79bff; --priv-bg: #2a1f45; }
.cal-badge { margin-left: auto; background: var(--warn); color: #fff; border-radius: 10px; font-size: .72rem; font-weight: 700; padding: 1px 7px; }
.tag-vis { display: inline-flex; align-items: center; gap: 3px; font-size: .7rem; font-weight: 700; border-radius: 6px; padding: 1px 6px; flex: none; }
.tag-vis svg { width: 11px; height: 11px; }
.tag-vis.pub, .cal-ev.pub { background: var(--primary-2); color: var(--primary); }
.tag-vis.priv, .cal-ev.priv { background: var(--priv-bg); color: var(--priv); }
.tr { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tr:last-child { border-bottom: 0; }
.tr:active { background: var(--surface-2); }
.tag-vis.ing, .cal-ev.ing { background: var(--warn-bg); color: var(--warn); }
.tr-oc { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--warn-bg); color: var(--warn); }
.tr-oc svg { width: 15px; height: 15px; }
.tr.hecha .tr-oc { background: var(--ok-bg); color: var(--ok); }
.tr-ck { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: none; flex: none; display: grid; place-items: center; padding: 0; color: transparent; }
.tr-ck svg { width: 15px; height: 15px; stroke-width: 3; }
.tr.hecha .tr-ck { background: var(--ok); border-color: var(--ok); color: #fff; }
.tr-txt { flex: 1; min-width: 0; }
.tr-1 { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr.hecha .tr-1 { text-decoration: line-through; color: var(--text-2); }
.tr-2 { display: flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; }
.tr-2 > svg { width: 12px; height: 12px; flex: none; }
.tr-2 span { overflow: hidden; text-overflow: ellipsis; }
.tr-hora { flex: none; font-weight: 700; font-size: .85rem; color: var(--text-2); text-align: right; line-height: 1.2; }
.tr-hora small { display: block; font-size: .7rem; color: var(--bad); }
.cal-vacio { padding: 14px; text-align: center; color: var(--text-2); font-size: .9rem; }
.cal-sem-top { margin: 4px 0 10px; } .cal-sem-top b { text-align: center; font-size: 1.05rem; }
.cal-semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 10px; }
.cal-semana button { border: 0; background: none; padding: 6px 0 4px; border-radius: 12px; font-size: .72rem; font-weight: 600; color: var(--text-2); }
.cal-semana b { display: block; font-size: 1.05rem; color: var(--text); margin-top: 2px; }
.cal-semana button.hoy b { color: var(--primary); }
.cal-semana i { display: block; height: 6px; margin-top: 3px; } .cal-semana i::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); vertical-align: top; }
.cal-semana i.no::after { display: none; }
.cal-semana button.on { background: var(--primary); color: var(--on-primary); } .cal-semana button.on b { color: var(--on-primary); } .cal-semana button.on i::after { background: var(--on-primary); }
.cal-fab { position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 25; width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: var(--shadow-lg); }
.cal-fab svg { width: 26px; height: 26px; }
/* Edición de una orden: datos arriba, productos en tarjetas (celular) o renglones (PC). */
.oc-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 12px; }
.oc-datos .field { margin-bottom: 10px; } .oc-datos .oc-area, .oc-datos .oc-prov, .oc-datos .oc-notas { grid-column: 1 / -1; }
.oc-datos textarea { min-height: 46px; }
.oc-prod-cab { gap: 8px; margin: 6px 0 10px; }
.oc-fecha-todos { gap: 6px; } .oc-fecha-todos .input { width: auto; min-height: 36px; }
.oc-item { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 10px 12px; margin-bottom: 8px; position: relative; }
.oc-item .field { margin: 0; }
.oc-item .oc-i-cod { grid-column: 1 / 2; } .oc-item .oc-i-desc { grid-column: 2 / -1; align-self: end; padding: 0 40px 12px 0; font-size: .88rem; font-weight: 600; }
.oc-item .oc-i-fecha, .oc-item .oc-i-coment { grid-column: 1 / -1; }
.oc-item .oQuitar { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; }
.oc-item .oFecha.atrasado { border-color: var(--bad); color: var(--bad); }
.oc-items-cab { display: none; }
@media (min-width: 900px) {
  .oc-datos { grid-template-columns: 1.4fr 1fr 1.4fr 1fr 1fr; }
  .oc-datos .oc-area, .oc-datos .oc-prov { grid-column: auto; }
  /* Renglón: código | descripción | cantidad | recibido | precio | fecha | comentario | quitar */
  .oc-items-cab, .oc-item { display: grid; grid-template-columns: 120px minmax(150px, 1.5fr) 92px 92px 104px 150px minmax(130px, 1.2fr) 40px; gap: 8px; align-items: center; }
  #fo.sin-recibido .oc-item, #fo.sin-recibido .oc-items-cab { grid-template-columns: 120px minmax(150px, 1.5fr) 92px 104px 150px minmax(130px, 1.2fr) 40px; }
  .oc-items-cab { padding: 0 13px 6px; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--text-2); }
  .oc-items-cab .r { text-align: right; }
  .oc-item { padding: 8px 12px; margin-bottom: 6px; }
  .oc-item .oc-i-cod, .oc-item .oc-i-desc, .oc-item .oc-i-fecha, .oc-item .oc-i-coment { grid-column: auto; }
  .oc-item .oc-i-desc { padding: 0; align-self: center; }
  .oc-item .field label { display: none; }
  .oc-item .input { min-height: 40px; }
  .oc-item .oNum { text-align: right; }
  .oc-item .oQuitar { position: static; }
}
.oc-ln { cursor: default; align-items: flex-start; } .oc-ln .ln-est { margin-top: 6px; } .oc-ln .ln-num { min-width: 56px; }
.oc-ln:active { background: none; }
.oc-cab { align-items: flex-start; } .oc-cab h2 .pill { vertical-align: 3px; margin-left: 4px; }
.oc-acc { gap: 8px; }
@media (max-width: 899px) { .oc-cab { flex-wrap: wrap; } .oc-acc { order: 3; width: 100%; } .oc-acc .btn { flex: 1; } }
@media (min-width: 900px) {
  .oc-ln { align-items: center; gap: 16px; padding: 11px 16px; } .oc-ln .ln-est { margin-top: 0; }
  .oc-ln .ln-1 { font-size: .95rem; white-space: normal; }
  .oc-cod { flex: none; width: 92px; font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
  .oc-ing { flex: none; width: 150px; line-height: 1.15; }
  .oc-ing small, .oc-ln .ln-num small { display: block; font-size: .66rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; }
  .oc-ing b { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
  .oc-ln .ln-num { min-width: 78px; } .oc-ln .ln-num b { font-size: 1.02rem; }
}
body:has(.savebar) .cal-fab { bottom: calc(156px + var(--safe-b)); }
.cal-barra { margin: 4px 0 12px; } .cal-barra .chips { padding: 0; }
.cal-titulo { font-size: 1.15rem; min-width: 150px; text-align: center; }
.cal-pc { display: flex; gap: 16px; align-items: flex-start; }
.cal-mes { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 0; overflow: hidden; }
.cal-dn { font-size: .72rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; padding: 8px; border-bottom: 1px solid var(--line); }
.cal-dia { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px; min-width: 0; overflow: hidden; cursor: pointer; }
.cal-dia:nth-child(7n) { border-right: 0; }
.cal-dia:hover { background: var(--surface-2); }
.cal-dia.sel { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-dia .n { display: inline-block; min-width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.cal-dia.fuera .n { opacity: .4; }
.cal-dia.hoy .n { background: var(--primary); color: var(--on-primary); }
.cal-ev { display: flex; align-items: center; gap: 4px; font-size: .74rem; border-radius: 6px; padding: 2px 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.cal-ev span { overflow: hidden; text-overflow: ellipsis; }
.cal-ev svg { width: 11px; height: 11px; flex: none; }
.cal-ev.hecha { opacity: .55; } .cal-ev.hecha span { text-decoration: line-through; }
.cal-mas { font-size: .72rem; color: var(--text-2); font-weight: 600; margin: 3px 0 0 4px; }
.cal-panel { width: 300px; flex: none; } .cal-panel .section-title:first-child { margin-top: 0; }
.cal-ley { font-size: .78rem; color: var(--text-2); margin-top: 14px; line-height: 1.8; }
.cal-ley svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
.cal-fh { gap: 10px; align-items: flex-start; }
textarea.input { padding: 10px 14px; resize: vertical; font-family: inherit; }
.vis-opc { display: flex; gap: 8px; }
.vis-opc button { flex: 1; text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; color: var(--text-2); font-size: .8rem; }
.vis-opc b { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: .95rem; margin-bottom: 2px; }
.vis-opc svg { width: 16px; height: 16px; }
.vis-opc button.on[data-vis="1"] { border-color: var(--primary); background: var(--primary-2); }
.vis-opc button.on[data-vis="0"] { border-color: var(--priv); background: var(--priv-bg); }
.cal-aviso { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; font-size: .92rem; cursor: pointer; }
.cal-aviso input { width: 20px; height: 20px; margin: 0; flex: none; }
.cal-aviso svg { width: 18px; height: 18px; flex: none; color: var(--text-2); }
.cal-aviso small { display: block; color: var(--text-2); font-size: .78rem; }
/* indicadores en una sola fila en el celular */
@media (max-width: 899px) {
  .kpis:not(.tramos) { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; margin: 4px 0 10px; }
  .kpis:not(.tramos) .kpi { padding: 7px 8px; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }
  .kpis:not(.tramos) .kpi small { font-size: .6rem; letter-spacing: 0; line-height: 1.15; overflow-wrap: anywhere; }
  .kpis:not(.tramos) .kpi b { font-size: 1.05rem; overflow-wrap: anywhere; line-height: 1.15; }
  .kpis:not(.tramos) .kpi b .muted { display: none; }
}
tfoot td { position: sticky; bottom: 0; background: var(--surface-2); border-top: 1px solid var(--line); z-index: 1; }
.t-consumo .cell-edit { width: 120px; }
.t-consumo .cell-edit::placeholder { color: var(--text-2); font-weight: 500; }
.i.sm { width: 15px; height: 15px; vertical-align: -2px; }
/* análisis */
.kpi.boton { text-align: left; cursor: pointer; font: inherit; color: inherit; width: 100%; }
.kpi.sel { outline: 2px solid var(--primary); outline-offset: -2px; }
.kpi b + small { text-transform: none; letter-spacing: 0; }
.kpis.tramos { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpis.tramos .kpi { padding: 10px 12px; }
@media (min-width: 900px) { .kpis.tramos { grid-template-columns: repeat(7, 1fr); } }

.savebar, .pedidobar {
  position: fixed; left: 12px; right: 12px; bottom: calc(78px + var(--safe-b)); z-index: 25;
  display: flex; gap: 10px; align-items: center; padding: 10px 10px 10px 16px; border-radius: 16px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); animation: up .2s ease;
}
.savebar .grow, .pedidobar .grow { flex: 1; font-weight: 600; font-size: .92rem; }
.savebar .btn.ghost, .pedidobar .btn.ghost { color: var(--bg); }
.pedidobar.arriba { bottom: calc(140px + var(--safe-b)); }  /* si también está la barra de conteos sin guardar */
@media (min-width: 900px) { .savebar, .pedidobar { left: auto; right: 28px; bottom: 24px; width: 460px; } .pedidobar.arriba { bottom: 88px; } }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }

.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty svg { width: 44px; height: 44px; margin-bottom: 8px; opacity: .6; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: .9rem; margin-bottom: 12px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.info { background: var(--primary-2); color: var(--primary); }
.section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 18px 4px 8px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.menu-list .card { overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; width: 100%; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); }
.menu-item:last-child { border-bottom: 0; }
.menu-item .grow small { display: block; color: var(--text-2); font-size: .8rem; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-2); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }

/* hojas inferiores (bottom sheets) y diálogos */
.overlay { position: fixed; inset: 0; z-index: 65; /* por encima del escáner: el conteo se abre sobre la cámara */ background: rgba(9,12,20,.5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); animation: up .22s ease;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { font-size: 1.15rem; margin: 0 0 12px; }
@media (min-width: 900px) {
  .overlay { align-items: center; } .sheet { border-radius: 20px; padding: 20px 24px; } .sheet .grab { display: none; }
  /* Ventanas apaisadas en la PC: más anchas y en dos columnas, para que no haya que bajar tanto. */
  .sheet.ancha { max-width: min(1080px, 94vw); padding: 22px 28px; }
  .sheet .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
  .sheet .cols > .col > .section-title:first-child { margin-top: 0; }
  .sheet.ancha .menu-list.dos { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1px; background: var(--line); }
  .sheet.ancha .menu-list.dos > * { background: var(--surface); }
  .sheet.ancha #ops { columns: 3; column-gap: 24px; } .sheet.ancha #ops > * { break-inside: avoid; }
  .sheet .cal-detalle { min-height: 196px; }
}
@keyframes fade { from { opacity: 0; } }
.option { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.option.on .check { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check svg { width: 14px; height: 14px; stroke-width: 3; }

/* escáner */
.scanner { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 50%; top: 42%; width: min(78vw, 340px); height: min(78vw, 340px); transform: translate(-50%, -50%);
  border-radius: 24px; box-shadow: 0 0 0 9999px rgba(0,0,0,.5);
}
.scanner .frame::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff5252; box-shadow: 0 0 12px #ff5252; animation: laser 1.8s ease-in-out infinite; }
.scanner .frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.scanner .frame i:nth-child(1) { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-radius: 22px 0 0 0; }
.scanner .frame i:nth-child(2) { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-radius: 0 22px 0 0; }
.scanner .frame i:nth-child(3) { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 22px; }
.scanner .frame i:nth-child(4) { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-radius: 0 0 22px 0; }
@keyframes laser { 0%, 100% { transform: translateY(-110px); } 50% { transform: translateY(110px); } }
.scanner .top { position: relative; display: flex; align-items: center; gap: 12px; padding: calc(14px + var(--safe-t)) 16px 10px; }
.scanner .top .iconbtn { background: rgba(255,255,255,.15); border: 0; color: #fff; box-shadow: none; }
.scanner .hint { position: absolute; left: 0; right: 0; top: calc(42% + min(39vw, 170px) + 22px); text-align: center; padding: 0 24px; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.scanner .bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(20px + var(--safe-b)); }
.scanner .manual { display: flex; gap: 8px; }
.scanner .manual .input { background: rgba(255,255,255,.95); color: #111; border: 0; }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 70; }
.flash.go { animation: flash .35s ease; }
@keyframes flash { 30% { opacity: .55; } }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 18px; background:
  radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent),
  radial-gradient(700px 500px at 110% 110%, color-mix(in srgb, var(--primary) 14%, transparent), transparent), var(--bg); }
.login .card { width: 100%; max-width: 400px; padding: 28px 24px; }
.login .logo { display: block; width: auto; height: 96px; max-width: 100%; margin: 0 auto 16px; padding: 10px 16px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); }

/* pantalla de carga */
/* La imagen (con el logo en su centro exacto) cubre toda la pantalla de las notebooks (16:9 / 16:10);
   en pantallas verticales se muestra entera, con los bordes fundidos en el gris del fondo. */
#splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(ellipse at center, #d9d9d9 0%, #b9b9b9 100%); transition: opacity .45s ease; }
#splash img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
@media (max-aspect-ratio: 4/3) {
  #splash img { inset: auto; position: relative; height: auto; object-fit: contain;
    -webkit-mask-image: linear-gradient(transparent, #000 20%, #000 80%, transparent); mask-image: linear-gradient(transparent, #000 20%, #000 80%, transparent); }
}
#splash .spinner { position: absolute; left: 50%; bottom: calc(9vh + var(--safe-b, 0px)); transform: translateX(-50%);
  width: 30px; height: 30px; border-color: rgba(0,0,0,.12); border-top-color: #e30613; }
@keyframes spin-centrado { to { transform: translateX(-50%) rotate(360deg); } }
#splash .spinner { animation-name: spin-centrado; }
#splash.fuera { opacity: 0; pointer-events: none; }
.login h1 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -.02em; }
.pass { position: relative; }
.pass .input { padding-right: 48px; }
.pass button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; width: 42px; height: 42px; color: var(--text-2); display: grid; place-items: center; }

/* toast */
.toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); z-index: 90;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); animation: down .2s ease;
}
@keyframes down { from { transform: translate(-50%, -12px); opacity: 0; } }
/* etiquetas para imprimir: A4, 2 columnas × 7 filas de 99,1 × 38,1 mm (formato estándar tipo L7163).
   El código ocupa todo el ancho: barras de ~0,25 mm, legibles por la cámara del celular. */
#print { display: none; }
@media print {
  @page { size: A4; margin: 15mm 4.5mm 0; }
  body { background: #fff !important; }
  #root, .toast, .savebar, .pedidobar, .overlay, .scanner { display: none !important; }
  #print { display: block; color: #000; }
  .hoja-etq { display: grid; grid-template-columns: repeat(2, 99.1mm); grid-auto-rows: 38.1mm; column-gap: 2.5mm; }
  .etq { overflow: hidden; padding: 2mm 2mm 1.5mm; display: flex; flex-direction: column; justify-content: center; break-inside: avoid; font-family: Arial, sans-serif; }
  .etq .t { font-weight: 700; font-size: 9pt; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .etq .s { font-size: 7pt; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .etq .barcode { width: 100%; height: 15mm; margin-top: 1mm; }
  .etq .b { font: 700 8pt "Courier New", monospace; text-align: center; }
  .hoja-etq.qr { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 70mm; gap: 6mm; }
  .hoja-etq.qr .etq { align-items: center; border: 1px dashed #999; }
  .hoja-etq.qr img { width: 48mm; height: 48mm; }
  .hoja-etq.qr b { font-size: 18pt; margin-top: 2mm; }
  .hoja-etq.qr.suc b { font-size: 12pt; text-align: center; line-height: 1.15; }
}

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 108px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
