/* ==========================================================================
   Inventario MegaNet — estilos
   Panel administrativo estándar, ejecutado con precisión.
   Azul MegaNet = acción y selección · naranja = bajo mínimo · celeste = foco.
   ========================================================================== */
:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --sidebar: #f5f6f8;
  --hover: #f1f3f6;
  --subtle: #f7f8fa;
  --border: #e4e7eb;
  --border-strong: #d3d8de;
  --text: #16181d;
  --text-2: #565d6a;
  --text-3: #6c727d;
  --navy: #084888;
  --navy-hover: #0a3d70;
  --navy-soft: #ebf1f8;
  --navy-line: #c9d9ec;
  --cyan: #12b5ea;
  --focus: 0 0 0 3px rgba(18, 181, 234, .3);
  --orange: #e86828;
  --orange-text: #a8480f;
  --orange-soft: #fdf1e9;
  --green: #1a7f4b;
  --green-soft: #e9f6ef;
  --red: #c0312b;
  --red-soft: #fcedec;
  --amber: #8f5507;
  --amber-soft: #fdf4e3;
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-pop: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 28px -6px rgba(16, 24, 40, .16);
  --shadow-modal: 0 2px 6px rgba(16, 24, 40, .06), 0 28px 56px -14px rgba(16, 24, 40, .32);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --sidebar-w: 232px;
}

/* ---------- Base y superficies del navegador ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scrollbar-color: #c7cdd5 transparent; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss03";
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: rgba(8, 72, 136, .16); }
input, textarea { caret-color: var(--navy); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd4db; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b5bcc6; border: 3px solid transparent; background-clip: padding-box; }
a, button, label, summary, .row-link, .list-item[data-id], .picker-item { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.011em; color: var(--text); }
h1 { font-size: 20px; line-height: 1.3; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--navy); text-underline-offset: 2px; }
code {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text-2);
  background: var(--subtle);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.num, .tnum, td.num, .stat-value, .qty { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sku-line { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; }
.small { font-size: 13px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.ic { width: 16px; height: 16px; flex: none; }
.text-danger { color: var(--red); }
.text-success { color: var(--green); }
.mobile-only { display: none; }
@media (min-width: 901px) { .hide-desktop { display: none !important; } }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; box-shadow: 0 0 0 2px var(--navy); }

/* ---------- Teclas ---------- */
.kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  font: 500 11px/1 "Inter", system-ui, sans-serif; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
}
.btn-primary .kbd { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .22); color: rgba(255, 255, 255, .9); }

/* ---------- Login: barra superior, formulario centrado, cuadrícula de puntos ---------- */
.login {
  position: relative; isolation: isolate;
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg);
}
/* Firma: una cuadrícula de puntos que se abre alrededor del formulario, con un leve halo azul al centro. */
.login-dots {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(#cfd6df 1px, transparent 1.2px) 0 0 / 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 560px 400px at 50% 47%, rgba(0, 0, 0, .25) 0, #000 78%);
  mask-image: radial-gradient(ellipse 560px 400px at 50% 47%, rgba(0, 0, 0, .25) 0, #000 78%);
}
/* El halo azul va en su propia capa, sin la máscara de los puntos, para que el claro se lea iluminado. */
.login::before {
  content: ''; position: absolute; inset: 0; z-index: -2; pointer-events: none;
  background: radial-gradient(closest-side, rgba(8, 72, 136, .08), transparent) 50% 46% / 820px 560px no-repeat;
}
.login-bar, .login-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 40px; background: rgba(255, 255, 255, .72);
}
.login-bar { height: 64px; border-bottom: 1px solid var(--border); }
.login-logo { height: 28px; width: auto; display: block; }
.login-links { display: flex; align-items: center; gap: 20px; font-size: 14px; color: var(--text-2); }
.login-help-btn { background: none; border: 0; padding: 4px 2px; font: 500 14px/1 "Inter", system-ui, sans-serif; color: var(--text); cursor: pointer; border-radius: 4px; }
.login-help-btn:hover { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }
.login-foot { height: 52px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }
.login-status { display: inline-flex; align-items: center; gap: 8px; }
.login-status .dot { width: 7px; height: 7px; color: #b5bcc6; }
.login-status[data-state="ok"] .dot { color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.login-status[data-state="down"] { color: var(--red); }
.login-status[data-state="down"] .dot { color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

.login-main { display: flex; justify-content: center; align-items: flex-start; padding: clamp(40px, 11vh, 120px) 24px 56px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.login-mark {
  width: 52px; height: 52px; border-radius: 14px; align-self: center; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 24px -10px rgba(16, 24, 40, .22);
}
.login-mark img { width: 34px; height: 34px; display: block; }
.login-head { text-align: center; margin: 6px 0 10px; }
.login-head h1 { font-size: 28px; letter-spacing: -.022em; }
.login-head p { color: var(--text-2); margin-top: 6px; font-size: 15px; text-wrap: balance; }
.login-head h1 { text-wrap: balance; }
.login-card label { font-size: 13.5px; }
.login-card input { height: 44px; font-size: 15px; padding: 0 12px; }
.login-card .btn-block { height: 44px; font-size: 15px; margin-top: 4px; gap: 10px; }
.login-card .btn-block .kbd { font-size: 11px; }
.pw-field { position: relative; display: block; }
.pw-field input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 7px; width: 30px; height: 30px; }
.caps-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--orange-text); }
.login-card .caps-hint { margin-top: -10px; }
.caps-hint .ic { width: 14px; height: 14px; }
.login-error { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--red-soft); border: 1px solid #f2c9c6; color: var(--red); font-size: 13.5px; font-weight: 500; animation: login-error-in .18s var(--ease); }
@keyframes login-error-in { from { opacity: 0; transform: translateY(-4px); } }
.login-card input[aria-invalid="true"] { border-color: var(--red); }
.login-card input[aria-invalid="true"]:focus { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red), 0 0 0 3px rgba(192, 49, 43, .18); }
.login-error .ic { width: 15px; height: 15px; }
.login-help { color: var(--text-3); font-size: 13px; text-align: center; }

@media (max-width: 640px) {
  .login-bar { height: 56px; padding: 0 16px; padding-top: env(safe-area-inset-top); }
  .login-logo { height: 24px; }
  .login-links span { display: none; }
  .login-main { padding: 36px 20px 40px; }
  .login-head h1 { font-size: 23px; }
  .login-head p { font-size: 14px; }
  .login-card .btn-block .kbd { display: none; }
  .login-foot { height: auto; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); flex-direction: column-reverse; gap: 6px; text-align: center; }
}

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .22s var(--ease); }
body.side-collapsed .shell { grid-template-columns: 60px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 0 14px 8px; min-height: 44px; }
.brand img { height: 26px; width: auto; display: block; }
.brand .brand-mark { display: none; width: 28px; height: 28px; }
.side-toggle { margin-left: auto; width: 28px; height: 28px; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -10px; padding: 0 10px 8px; }
.sidebar .nav-link .kbd { margin-left: auto; }
.side-wh .wh-dot {
  width: 18px; height: 18px; border-radius: 5px; flex: none; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); font-size: 9.5px; font-weight: 600; letter-spacing: -.02em;
}
.side-wh > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-wh-title .muted { font-weight: 400; }
.side-empty { font-size: 12.5px; color: var(--text-3); padding: 4px 8px; }
.side-shortcuts { margin-top: 6px; color: var(--text-3); }
.side-shortcuts:hover { color: var(--text); }
.sc-list { display: flex; flex-direction: column; }
.sc-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.sc-row:last-child { border-bottom: 0; }
.sc-keys { display: flex; gap: 4px; }

/* Menú plegado: solo íconos; el nombre aparece al pasar el mouse (title). */
body.side-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
body.side-collapsed .brand { flex-direction: column; gap: 10px; padding: 2px 0 10px; }
body.side-collapsed .brand-full { display: none; }
body.side-collapsed .brand .brand-mark { display: block; }
body.side-collapsed .side-toggle { margin-left: 0; }
body.side-collapsed .sidebar .nav-link { justify-content: center; padding: 0; gap: 0; }
body.side-collapsed .sidebar .nav-link > span, body.side-collapsed .sidebar .nav-link .kbd, body.side-collapsed .sidebar .nav-link .nav-count { display: none; }
body.side-collapsed .sidebar .nav-link .nav-count.alert { display: block; position: absolute; top: 3px; right: 5px; width: 7px; height: 7px; padding: 0; font-size: 0; border-radius: 50%; background: var(--orange); }
body.side-collapsed .sidebar .nav-section { font-size: 0; padding: 10px 6px 6px; }
body.side-collapsed .sidebar .nav-section::after { content: ''; display: block; height: 1px; background: var(--border); }
body.side-collapsed .side-wh .wh-dot { display: grid; }
body.side-collapsed .side-wh > span:first-child { display: grid !important; }
body.side-collapsed .sidebar-foot { flex-direction: column; gap: 4px; }
body.side-collapsed .user-row { padding: 6px 0; justify-content: center; }
body.side-collapsed .user-row > span:last-child { display: none; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-section { font-size: 11.5px; font-weight: 500; color: var(--text-3); padding: 14px 8px 4px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 8px; border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 13.5px;
  background: none; border: 1px solid transparent; font-family: inherit; cursor: pointer; width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.nav-link .ic { color: var(--text-3); }
.sidebar .nav-link:hover { background: var(--hover); color: var(--text); }
.sidebar .nav-link.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-xs); }
.sidebar .nav-link.active .ic { color: var(--navy); }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-count.alert { color: var(--orange-text); background: var(--orange-soft); padding: 0 6px; border-radius: 10px; line-height: 18px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; display: flex; align-items: center; gap: 6px; }
.user-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); text-decoration: none; color: var(--text); }
.user-row:hover, .user-row.active { background: var(--hover); }
.user-row > span:last-child { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-row strong { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row small { color: var(--text-3); font-size: 12px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--navy-soft); color: var(--navy); font-weight: 600; font-size: 11.5px; text-decoration: none;
  border: 1px solid var(--navy-line);
}

.main-col { min-width: 0; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 15;
  height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 28px;
  background: rgba(251, 251, 252, .88); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.gsearch { position: relative; width: min(420px, 50%); }
.gsearch .search { height: 32px; background: var(--surface); }
.gsearch .search .kbd { margin-left: auto; }
.gsearch-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; }
.topbar, .bottomnav { display: none; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; min-width: 0; }

/* ---------- Encabezado de página y barras de herramientas ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 260px; max-width: 380px; }
.toolbar select, .toolbar input[type="date"] { width: auto; height: 32px; padding-top: 0; padding-bottom: 0; }
.toolbar .check { height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); font-size: 13px; color: var(--text-2); }
.toolbar .check:has(input:checked) { border-color: var(--navy-line); background: var(--navy-soft); color: var(--navy); }
.search {
  display: flex; flex-direction: row; align-items: center; gap: 8px; height: 32px; font-weight: 400;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 0 10px; color: var(--text-3); min-width: 0; transition: border-color .12s, box-shadow .12s;
}
.search > .ic { width: 15px; height: 15px; }
.search input, .search input:hover, .search input:focus {
  border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 0; height: 100%; outline: none; flex: 1; min-width: 0; font-size: 13.5px;
}
.search:hover { border-color: #bfc6cf; }
.search:focus-within { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--navy), var(--focus); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 13.5px/1 "Inter", system-ui, sans-serif; cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background .12s, border-color .12s, box-shadow .12s, transform .12s var(--ease);
}
.btn:hover { background: var(--hover); border-color: #bfc6cf; }
.btn:active { transform: translateY(.5px); }
.btn .ic { width: 15px; height: 15px; color: var(--text-3); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 1px 2px rgba(8, 72, 136, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
.btn-primary .ic { color: rgba(255, 255, 255, .85); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a82822; border-color: #a82822; }
.btn-danger-text, .btn-danger-text .ic { color: var(--red); }
.btn-danger-text:hover { background: var(--red-soft); border-color: #efc4c1; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn-block { width: 100%; height: 36px; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-icon {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: var(--r-sm); border: 0; background: none; color: var(--text-3); cursor: pointer;
  transition: background .12s, color .12s;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }

/* ---------- Paneles ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; }
.card > h3, .panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; }
.panel-head a, .card > h3 a { font-size: 13px; font-weight: 500; text-decoration: none; color: var(--text-2); display: inline-flex; align-items: center; gap: 2px; }
.panel-head a:hover, .card > h3 a:hover { color: var(--navy); }
.panel-head a .ic { width: 14px; height: 14px; }
.card-table { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Reportes ---------- */
.exports { margin-bottom: 14px; }
.export-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 16px; }
.export-row + .export-row { border-top: 1px solid var(--border); }
.export-info { min-width: 0; flex: 1; }
.export-info h3 { font-size: 13.5px; }
.export-info p { color: var(--text-2); font-size: 13px; margin-top: 2px; max-width: 70ch; }
.export-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 170px)); gap: 10px; margin-top: 12px; }
.export-filters label { font-size: 12.5px; color: var(--text-2); }
.export-filters input, .export-filters select { height: 32px; }

/* ---------- Indicadores (franja) ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 14px; overflow: hidden;
}
.stat { padding: 14px 16px; border-left: 1px solid var(--border); min-width: 0; text-decoration: none; color: inherit; }
.stat:first-child { border-left: 0; }
a.stat:hover { background: var(--subtle); }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.stat.alert .stat-value { color: var(--orange-text); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; display: inline-block; }

/* ---------- Listas ---------- */
.list { display: flex; flex-direction: column; margin: 0 -8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-sm); min-height: 44px; }
.list-item + .list-item { box-shadow: 0 -1px 0 var(--border); }
.list-item[data-id]:hover { background: var(--subtle); box-shadow: none; }
.list-item[data-id]:hover + .list-item { box-shadow: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow strong { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .grow small { color: var(--text-3); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .qty { font-weight: 600; white-space: nowrap; }
.list-item .of { color: var(--text-3); font-weight: 400; }
.row-link, .list-item[data-id] { cursor: pointer; }

/* ---------- Barras de datos ---------- */
.bars { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.bar-label { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label small { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.bar-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--navy); min-width: 2px; }

/* ---------- Formularios ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
input, select, textarea {
  font: 400 14px/1.4 "Inter", system-ui, sans-serif; height: 36px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); width: 100%; outline: 0; min-width: 0;
  box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s;
  accent-color: var(--navy);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
select { appearance: none; padding-right: 30px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236c727d' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5'/%3E%3C/svg%3E") no-repeat right 8px center; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: #bfc6cf; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: inset 0 0 0 1px var(--navy), var(--focus); }
input:disabled, select:disabled { background: var(--subtle); color: var(--text-3); }
input[type="date"] { font-variant-numeric: tabular-nums; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row-2:has(> .hidden) { grid-template-columns: 1fr; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.check input { width: 15px; height: 15px; box-shadow: none; }
.fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: 6px 14px 14px; margin: 0; background: var(--subtle); }
legend { padding: 0 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.help { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.inline-form { display: flex; gap: 8px; max-width: 520px; }
.inline-form input { flex: 1; height: 32px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-2);
  padding: 0 14px; height: 34px; border-bottom: 1px solid var(--border); background: var(--subtle); white-space: nowrap;
}
td { padding: 0 14px; height: 44px; border-bottom: 1px solid var(--border); vertical-align: middle; }
td strong { font-weight: 500; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.row-link { transition: background .1s; }
.row-link:hover td { background: var(--subtle); }
.row-inactive td { color: var(--text-3); }
.row-actions { text-align: right; white-space: nowrap; width: 1%; }
.row-actions .btn-icon { width: 28px; height: 28px; }
@media (min-width: 1101px) {
  .card-table { overflow: clip; }
  .card-table .table-wrap { overflow: visible; }
  .card-table th { position: sticky; top: 52px; z-index: 2; box-shadow: inset 0 -1px 0 var(--border); }
  .card-table thead th:first-child { border-top-left-radius: var(--r-lg); }
  .card-table thead th:last-child { border-top-right-radius: var(--r-lg); }
}
.table-simple { border: 1px solid var(--border); border-radius: var(--r); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.table-simple td { height: 38px; }
.table-foot { padding: 10px 14px; display: flex; justify-content: center; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; }
.total-row td { background: var(--subtle); font-weight: 600; }
.unit { color: var(--text-3); font-size: 12.5px; margin-left: 4px; }
.clip { display: block; max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 641px) {
  .mov-table td { white-space: nowrap; }
  .mov-table td.place { white-space: normal; min-width: 150px; }
}

/* ---------- Estados (pastillas) ---------- */
.status, .badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--hover); color: var(--text-2);
}
.qty-ok { color: var(--text); }
.qty-low { color: var(--orange-text); font-weight: 600; }
.qty-out { color: var(--red); font-weight: 600; }
.status-ok { background: var(--green-soft); color: var(--green); }
.status-low { background: var(--orange-soft); color: var(--orange-text); }
.status-out { background: var(--red-soft); color: var(--red); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-navy { background: var(--navy-soft); color: var(--navy); }
.badge .btn-icon { width: 18px; height: 18px; margin-right: -4px; color: inherit; }
.badge .btn-icon .ic { width: 12px; height: 12px; }
.type { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; color: var(--text); }
.type .ic { width: 14px; height: 14px; }
.type .ic { color: var(--text-3); }
.mov-icon { width: 28px; height: 28px; border-radius: var(--r-sm); flex: none; display: grid; place-items: center; background: var(--subtle); border: 1px solid var(--border); }
.mov-icon .ic { width: 14px; height: 14px; }
.mov-icon { color: var(--text-2); }

/* ---------- Vacíos y carga ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty-icon { width: 36px; height: 36px; margin: 0 auto 10px; border-radius: var(--r); display: grid; place-items: center; background: var(--subtle); border: 1px solid var(--border); color: var(--text-3); }
.empty > div:nth-child(2) { font-weight: 500; color: var(--text); }
.empty p { margin: 4px auto 0; font-size: 13px; max-width: 42ch; }
.empty .btn { margin-top: 12px; }
.skeleton { padding: 0; }
.sk-row { display: flex; align-items: center; gap: 16px; padding: 0 14px; height: 44px; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--hover) 0%, #e8ebef 50%, var(--hover) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; padding: 0; margin: 0; background: transparent;
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
  display: grid; place-items: start center; padding-top: min(12vh, 120px);
}
dialog.modal:not([open]) { display: none; }
dialog.modal::backdrop { background: rgba(15, 20, 28, .32); }
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - min(12vh, 120px) - 24px);
  overflow: auto; display: flex; flex-direction: column; box-shadow: var(--shadow-modal);
  animation: pop .22s var(--ease);
}
@keyframes pop { from { transform: translateY(6px) scale(.985); opacity: 0; } }
.modal-wide .modal-box { width: min(760px, calc(100vw - 24px)); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 6px 20px; }
.modal-head h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 8px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--subtle); }
.modal-body .modal-foot { margin: 6px -20px -20px; }
.modal-body h3 { margin: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.modal-body h3 a { font-weight: 500; text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.detail-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 0 -1px -1px 0; }
.lbl { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* ---------- Control segmentado y selector ---------- */
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 2px; background: var(--hover); border-radius: var(--r); border: 1px solid var(--border); }
.seg {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 30px;
  border: 0; border-radius: var(--r-sm); background: none; font: 500 13px/1 "Inter", system-ui, sans-serif;
  color: var(--text-2); cursor: pointer; transition: background .12s, color .12s;
}
.seg:hover { color: var(--text); }
.seg .ic { width: 14px; height: 14px; }
.seg.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 0 0 1px var(--border); }
.seg.active .ic { color: var(--navy); }
.picker { position: relative; }
.picker-list, .gsearch-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-pop); max-height: 300px; overflow: auto; padding: 4px;
}
.picker-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10; }
.picker-item { padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 400; font-size: 13.5px; border-radius: var(--r-sm); color: var(--text); }
.picker-item:hover, .picker-item.active { background: var(--hover); }
.picker-item small { color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.picker-item.foot { color: var(--text-2); justify-content: flex-start; }
.picker-selected {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 36px;
  background: var(--navy-soft); color: var(--navy); padding: 0 4px 0 10px; border-radius: var(--r-sm); font-weight: 500;
  border: 1px solid var(--navy-line);
}
.picker-selected span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-selected .btn-icon { color: var(--navy); width: 26px; height: 26px; }
.stock-info { font-size: 13px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--subtle); border: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); }
.stock-info strong { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 1000; pointer-events: none; max-width: calc(100vw - 32px); }
.toast {
  --tone: #4fd18b;
  position: relative; overflow: hidden; pointer-events: auto; cursor: pointer;
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: start; gap: 10px;
  width: 360px; max-width: 100%; padding: 12px 12px 13px 14px;
  background: #17191e; color: #fff; border: 1px solid #2a2e36; border-radius: var(--r-lg);
  box-shadow: 0 2px 6px rgba(16, 24, 40, .12), 0 16px 36px -10px rgba(16, 24, 40, .45);
  opacity: 0; transform: translateY(10px) scale(.97);
  transition: opacity .2s, transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateX(16px); transition: opacity .18s, transform .25s ease-in; }
.toast-ic { color: var(--tone); padding-top: 1px; }
.toast-ic .ic { width: 18px; height: 18px; }
.toast-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; }
.toast-desc { font-size: 12.5px; color: rgba(255, 255, 255, .68); margin-top: 2px; line-height: 1.4; overflow-wrap: anywhere; }
.toast-action {
  align-self: center; height: 26px; padding: 0 10px; border-radius: var(--r-sm); cursor: pointer;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); color: #fff;
  font: 500 12.5px/1 "Inter", system-ui, sans-serif; white-space: nowrap; transition: background .12s;
}
.toast-action:hover { background: rgba(255, 255, 255, .18); }
.toast-action:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; box-shadow: none; }
.toast::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: var(--tone); opacity: .55; transform-origin: left;
  animation: toast-time var(--toast-dur, 4s) linear forwards;
}
.toast:hover::after { animation-play-state: paused; }
.toast.sticky::after { animation: toast-busy 1.2s ease-in-out infinite; width: 30%; }
@keyframes toast-time { to { transform: scaleX(0); } }
@keyframes toast-busy { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.toast-error { --tone: #ff7a6e; }
.toast-warn { --tone: #ff9a5c; }
.toast-info { --tone: #6cc9f0; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .export-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .shell, body.side-collapsed .shell { grid-template-columns: 1fr; }
  .sidebar, .appbar { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 12px;
    background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  }
  .topbar img { height: 20px; width: auto; display: block; }
  .topbar-title { font-weight: 600; flex: 1; padding-left: 12px; border-left: 1px solid var(--border-strong); line-height: 18px; }
  .content { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(10px);
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottomnav .nav-link { flex-direction: column; gap: 2px; height: 52px; padding: 0; font-size: 11px; justify-content: center; text-align: center; color: var(--text-3); border: 0; }
  .bottomnav .nav-link .ic { width: 20px; height: 20px; }
  .bottomnav .nav-link.active, .bottomnav .nav-link.active .ic { color: var(--navy); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dialog.modal { place-items: end center; padding-top: 0; }
  .modal-box { width: 100vw; max-height: calc(100vh - 40px); border-radius: 14px 14px 0 0; border-bottom: 0; }
  .modal-wide .modal-box { width: 100vw; }
  .modal-foot { position: sticky; bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { width: 100%; }
  .sheet-nav .nav-link { height: 44px; font-size: 14px; }
}
@media (max-width: 640px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; height: 36px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 19px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .export-row { flex-direction: column; gap: 12px; }
  .export-row .btn { width: 100%; height: 36px; }
  .export-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .segmented { grid-template-columns: 1fr 1fr; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar select, .toolbar input[type="date"] { flex: 1 1 45%; min-width: 0; }
  .mobile-only { display: inline; }
  input, select, textarea, .search input { font-size: 16px; }

  /* Tablas que se convierten en tarjetas */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; height: auto; padding: 3px 0; border: 0; text-align: right; }
  .table-cards td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; font-weight: 400; text-align: left; flex: none; }
  .table-cards td.td-main { display: block; text-align: left; font-size: 14.5px; padding-bottom: 6px; }
  .table-cards td.td-main::before { content: none; }
  .table-cards td.row-actions { justify-content: flex-end; padding-top: 8px; }
  .table-cards td.row-actions::before { content: none; }
  .table-cards td .btn-sm { height: 32px; }
  .row-link:hover td { background: none; }
  .table-cards .row-move { width: auto; height: 32px; padding: 0 12px; gap: 6px; border: 1px solid var(--border-strong); color: var(--text); font: 500 13.5px/1 "Inter", system-ui, sans-serif; display: inline-flex; align-items: center; }
  .list-item .status { display: none; }

  /* Productos: tarjeta compacta de dos filas */
  .products-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto 36px; column-gap: 12px; row-gap: 4px; align-items: center; padding: 10px 14px; }
  .products-table td { display: block; padding: 0; text-align: left; }
  .products-table td::before { content: none; }
  .products-table td.td-main { grid-area: 1 / 1 / 3 / 2; padding: 0; font-size: 14.5px; }
  .products-table td.stock-cell { grid-area: 1 / 2; text-align: right; font-weight: 500; }
  .products-table td.status-cell { grid-area: 2 / 2; text-align: right; }
  .products-table td.row-actions { grid-area: 1 / 3 / 3 / 4; padding: 0; justify-content: center; display: flex; }
  .products-table td.cat-cell { display: none; }
  .products-table td.min-cell, .products-table td.cost-cell { grid-row: 3; font-size: 12.5px; color: var(--text-3); }
  .products-table td.min-cell { grid-column: 1; }
  .products-table td.min-cell::before { content: 'Mínimo '; }
  .products-table td.cost-cell { grid-column: 2 / 4; text-align: right; }
  .products-table .row-move { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .products-table .row-move .mobile-only { display: none; }
}
@media (hover: none) {
  .row-link:active td, .list-item[data-id]:active { background: var(--hover); }
  .btn:active, .seg:active, .btn-icon:active { transform: scale(.97); }
  .bottomnav .nav-link:active { background: var(--hover); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .sidebar, .topbar, .bottomnav, .appbar, .toolbar, .actions, .toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: none; }
}

/* ---------- Foco de teclado: anillo azul bajo el contorno celeste (≥3:1) ---------- */
:is(.btn, .seg, .nav-link, .btn-icon, a.stat, .list-item):focus-visible,
.sidebar .nav-link.active:focus-visible,
.seg.active:focus-visible {
  box-shadow: 0 0 0 2px var(--navy);
}
.btn.btn-primary:focus-visible { box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--navy); }
