/* elMini Portal — estilos. Cambia --accent para ajustar el color de marca. */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --ink: #17181a;
  --ink-2: #5d6066;
  --ink-3: #8b8e94;
  --line: #e3e1da;
  --accent: #d6402b;
  --accent-ink: #ffffff;
  --accent-soft: rgba(214, 64, 43, 0.10);
  --good: #1a7f4b;
  --warn: #b7791f;
  --bad: #c53030;
  --info: #2b6cb0;
  --good-soft: rgba(26, 127, 75, 0.12);
  --warn-soft: rgba(183, 121, 31, 0.14);
  --bad-soft: rgba(197, 48, 48, 0.12);
  --info-soft: rgba(43, 108, 176, 0.12);
  --chart-1: #d6402b;
  --chart-2: #2b6cb0;
  --chart-3: #1a7f4b;
  --chart-grid: rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --surface: #1a1b1e; --surface-2: #232428; --ink: #f1f0ec; --ink-2: #b4b6bb; --ink-3: #85878d;
    --line: #2e3035; --accent: #ff6a52; --accent-ink: #1a0b08; --accent-soft: rgba(255, 106, 82, 0.14);
    --good: #48c78e; --warn: #f0b429; --bad: #f56565; --info: #63b3ed;
    --good-soft: rgba(72, 199, 142, 0.14); --warn-soft: rgba(240, 180, 41, 0.14); --bad-soft: rgba(245, 101, 101, 0.14); --info-soft: rgba(99, 179, 237, 0.14);
    --chart-1: #ff6a52; --chart-2: #63b3ed; --chart-3: #48c78e; --chart-grid: rgba(255, 255, 255, 0.07);
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111214; --surface: #1a1b1e; --surface-2: #232428; --ink: #f1f0ec; --ink-2: #b4b6bb; --ink-3: #85878d;
  --line: #2e3035; --accent: #ff6a52; --accent-ink: #1a0b08; --accent-soft: rgba(255, 106, 82, 0.14);
  --good: #48c78e; --warn: #f0b429; --bad: #f56565; --info: #63b3ed;
  --good-soft: rgba(72, 199, 142, 0.14); --warn-soft: rgba(240, 180, 41, 0.14); --bad-soft: rgba(245, 101, 101, 0.14); --info-soft: rgba(99, 179, 237, 0.14);
  --chart-1: #ff6a52; --chart-2: #63b3ed; --chart-3: #48c78e; --chart-grid: rgba(255, 255, 255, 0.07);
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: 32px; letter-spacing: 0.2px; text-transform: uppercase; line-height: 1; }
h2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; text-transform: uppercase; letter-spacing: 0.3px; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Estructura */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 8px; }
.brand-mark { font-family: var(--font-display); font-weight: 800; font-size: 30px; color: var(--accent); letter-spacing: 0.3px; line-height: 1; }
.brand-sub { font-size: 12px; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.main { min-width: 0; padding: 0 28px 48px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px 0 14px; background: var(--bg); }
.topbar h1 { margin-right: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mobile-nav { display: none; }

/* Controles */
select, input, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 38px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { max-width: 100%; text-overflow: ellipsis; }
.row > label, .row > select, .row > input { min-width: 0; max-width: 100%; }
.row label select { width: 100%; }
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .lbl { color: var(--ink-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi .val { font-family: var(--font-display); font-weight: 800; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--ink-2); font-size: 12px; }
.delta { font-weight: 700; font-size: 12px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* Etiquetas */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ink-3); }
.dot.verde { background: var(--good); } .dot.amarillo { background: var(--warn); } .dot.rojo { background: var(--bad); } .dot.agotado { background: var(--ink-3); }

/* Tablas */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: 12px; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl th .arr { opacity: 0.6; font-size: 10px; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl td.wrap { white-space: normal; min-width: 180px; }
.tbl td.nw { white-space: nowrap; }
.tbl input.qty { width: 84px; min-height: 30px; padding: 4px 8px; text-align: right; }
.tbl-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 2px 0; color: var(--ink-2); font-size: 12px; flex-wrap: wrap; }
.sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-2); }
.sku.tmp { color: var(--warn); }
.spark { display: block; }
.empty { padding: 28px; text-align: center; color: var(--ink-2); }
.list { display: flex; flex-direction: column; }
.list .it { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.list .it:last-child { border-bottom: 0; }
.list .it .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Subida */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px 20px; text-align: center; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 36px; height: 36px; color: var(--accent); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.cols { display: flex; flex-wrap: wrap; gap: 6px; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.form label input, .form label select, .form label textarea { font-size: 14px; font-weight: 400; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .help { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.form h3 { margin-top: 8px; }

/* Modal y avisos */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 760px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 200; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); color: #fff; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--ink); }
.notice.ok { background: var(--good-soft); } .notice.err { background: var(--bad-soft); } .notice.warn { background: var(--warn-soft); }
details.grp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.grp > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details.grp > summary::-webkit-details-marker { display: none; }
details.grp > summary h3 { margin-right: auto; }
details.grp[open] > summary { border-bottom: 1px solid var(--line); }
details.grp .grp-b { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.loading { padding: 40px; text-align: center; color: var(--ink-2); }

/* Acceso */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0; }

/* Responsivo */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 0 16px 92px; }
  .topbar { padding-top: 12px; }
  h1 { font-size: 28px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi .val { font-size: 28px; }
  .card { padding: 14px; }
  .filters { width: 100%; }
  .filters > * { flex: 1 1 140px; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--ink-2); text-decoration: none; font-weight: 600; padding: 4px 2px; min-width: 52px; position: relative; }
  .mobile-nav a.on { color: var(--accent); }
  .mobile-nav svg { width: 20px; height: 20px; }
  .mobile-nav .badge { position: absolute; top: -2px; right: 4px; height: 16px; min-width: 16px; font-size: 10px; padding: 0 4px; }
  .chart-box { height: 220px; }
}
@media (max-width: 420px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .val { font-size: 24px; }
}
