/* ═══════════════════════════════════════════════
   STACK-S · Design System
   ═══════════════════════════════════════════════ */

/* ── 1. Design Tokens ─────────────────────────── */
:root {
  color-scheme: light;

  /* Neutrals */
  --bg:       #f1f5f9;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;
  --text:     #0f172a;
  --text2:    #334155;
  --muted:    #64748b;
  --subtle:   #94a3b8;
  --line:     #e2e8f0;

  /* Brand */
  --brand:    #2563eb;
  --brand-dk: #1d4ed8;
  --brand-lt: #eff6ff;
  --brand-md: #dbeafe;

  /* Status */
  --ok:       #16a34a;
  --okbg:     #dcfce7;
  --warn:     #b45309;
  --warnbg:   #fef3c7;
  --danger:   #dc2626;
  --dangerbg: #fef2f2;

  /* Movement badges */
  --entrada:   #0d9488;
  --entradabg: #ccfbf1;
  --salida:    #7c3aed;
  --salidabg:  #ede9fe;

  /* Geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Shadows */
  --sh-xs: 0 1px 3px rgba(15,23,42,.05), 0 1px 2px rgba(15,23,42,.03);
  --sh:    0 4px 16px rgba(15,23,42,.07), 0 1px 4px rgba(15,23,42,.04);
  --sh-lg: 0 12px 48px rgba(15,23,42,.12), 0 4px 12px rgba(15,23,42,.06);

  /* Typography */
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── 2. Reset & Base ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body  { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a      { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

/* ── 3. Typography ────────────────────────────── */
h1 {
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  letter-spacing: -.04em;
  font-weight: 800;
  margin-bottom: 0;
  line-height: 1.15;
}
h2 {
  font-size: clamp(1.1rem, 1.7vw, 1.35rem);
  letter-spacing: -.025em;
  font-weight: 700;
  margin-bottom: .2rem;
}
h3   { font-size: .975rem; font-weight: 700; margin-bottom: .25rem; }
p    { color: var(--muted); line-height: 1.65; margin-bottom: 0; }

/* ── 4. App Shell ─────────────────────────────── */
.appShell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px 1fr;
}

/* ── 5. Sidebar ───────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 12px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.brand span {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -.07em;
  color: var(--text);
}
.brand small {
  font-size: .74rem;
  color: var(--muted);
  font-weight: 500;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

/* ── 6. Nav Items ─────────────────────────────── */
.navItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r);
  color: var(--text2);
  font-size: .875rem;
  font-weight: 600;
  transition: background .13s, color .13s;
}
.navItem b {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--surface2);
  color: var(--muted);
  flex-shrink: 0;
  transition: background .13s, color .13s;
}
.navItem span  { font-weight: 600; }
.navItem small { display: none; }
.navItem:hover { background: var(--surface3); color: var(--text); }
.navItem:hover b { background: var(--brand-md); color: var(--brand); }
.navItem.activo { background: var(--brand-lt); color: var(--brand); }
.navItem.activo b { background: var(--brand-md); color: var(--brand); }

/* Alert count badge in nav */
.navCount {
  font-style: normal;
  font-size: .68rem;
  font-weight: 800;
  line-height: 1;
  background: var(--warn);
  color: #fff;
  border-radius: 999px;
  padding: .18rem .42rem;
  margin-left: auto;
}

/* ── 7. Workspace & Topbar ────────────────────── */
.workspace { min-width: 0; padding: 24px 28px 80px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar p {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 0 0 3px;
}

/* ── 8. Panels ────────────────────────────────── */
.hero, .panel, .metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}

.panel {
  padding: 20px;
}

/* ── 9. Hero Section ──────────────────────────── */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px;
  margin-bottom: 16px;
}
.hero h2 {
  font-size: clamp(1.5rem, 3.5vw, 3rem);
  letter-spacing: -.035em;
  font-weight: 800;
  margin-bottom: .35rem;
  line-height: 1.05;
  color: var(--text);
}
.eyebrow {
  display: block;
  color: var(--brand);
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 7px;
}

/* ── 10. Metric Cards ─────────────────────────── */
.metricGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.metric > span { font-size: .78rem; font-weight: 700; color: var(--muted); }
.metric strong  {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  letter-spacing: -.04em;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.metric small   { font-size: .75rem; color: var(--muted); }
.metric.critico {
  border-color: #fed7aa;
  background: linear-gradient(135deg, #fffbf5 0%, #fff 60%);
}
.metric.critico strong { color: var(--warn); }

/* ── 11. Layout Helpers ───────────────────────── */
.twoColumns {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(320px,.62fr);
  gap: 16px;
}
.sectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.sectionHead.wrap { flex-wrap: wrap; }
.sectionHead > span { font-size: .78rem; color: var(--muted); font-weight: 600; }
.sectionHead a { color: var(--brand); font-weight: 700; font-size: .85rem; }
.sectionHead a:hover { text-decoration: underline; }
.topbar p, .brand small, .navItem small, .sectionHead span { color: var(--muted); }

/* ── 12. Buttons ──────────────────────────────── */
.boton {
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 40px;
  padding: .58rem 1.1rem;
  font-weight: 700;
  font-size: .875rem;
  background: var(--surface);
  color: var(--text);
  transition: background .13s, border-color .13s, box-shadow .13s, transform .12s;
  white-space: nowrap;
}
.primario {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.22);
}
.primario:hover {
  background: var(--brand-dk);
  box-shadow: 0 4px 16px rgba(37,99,235,.34);
  transform: translateY(-1px);
}
.secundario {
  background: var(--brand-lt);
  color: var(--brand);
  border-color: var(--brand-md);
}
.secundario:hover { background: var(--brand-md); transform: translateY(-1px); }
.ghost { border-color: var(--line); }
.ghost:hover { background: var(--surface3); border-color: var(--subtle); }
.danger { background: var(--dangerbg); color: var(--danger); border-color: #fecaca; }
.danger:hover { background: #fee2e2; transform: translateY(-1px); }
.wide { width: 100%; }

/* ── 13. Badges ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .2rem .62rem;
  font-weight: 700;
  font-size: .73rem;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge.ok      { background: var(--okbg);     color: var(--ok);      }
.badge.bajo    { background: var(--warnbg);   color: var(--warn);    }
.badge.agotado { background: var(--dangerbg); color: var(--danger);  }
.badge.entrada { background: var(--entradabg); color: var(--entrada); }
.badge.salida  { background: var(--salidabg);  color: var(--salida);  }

/* ── 14. Link Buttons / Back ──────────────────── */
.sectionHead a, .linkBtn, .back {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  cursor: pointer;
}
.linkBtn { font-size: .82rem; padding: 0; }
.linkBtn:hover { text-decoration: underline; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 16px;
  padding: 0;
}
.back:hover { color: var(--text); }

/* ── 15. Stack / Attention ────────────────────── */
.stack { display: grid; gap: 8px; }

.attention {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  padding: 13px 16px;
  transition: border-color .13s, background .13s, transform .12s;
}
.attention:hover {
  border-color: var(--brand-md);
  background: var(--brand-lt);
  transform: translateY(-1px);
}
.attention strong { display: block; font-size: .9rem; font-weight: 700; }
.attention small  { display: block; color: var(--muted); margin-top: 2px; font-size: .78rem; }
.attention i      { font-style: normal; color: var(--brand); font-weight: 700; font-size: .8rem; white-space: nowrap; }

/* ── 16. Empty State ──────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-lg);
  background: var(--surface2);
  gap: 6px;
}
.empty strong { font-size: .95rem; color: var(--text2); font-weight: 700; }
.empty p { font-size: .85rem; max-width: 280px; }

/* ── 17. Filters ──────────────────────────────── */
.filters {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0 18px;
}

/* ── 18. Forms ────────────────────────────────── */
label { display: grid; gap: 5px; font-weight: 600; }
label > span, legend {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text2);
}
input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  padding: .66rem .84rem;
  color: var(--text);
  font-size: .9rem;
  transition: border-color .13s, box-shadow .13s, background .13s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.13), 0 2px 10px rgba(37,99,235,.08);
}
input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}
textarea { min-height: 96px; resize: vertical; }
.error {
  color: var(--danger);
  font-weight: 600;
  font-size: .78rem;
  padding: .1rem .1rem 0;
}

/* ── 19. Table ────────────────────────────────── */
.tableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-top: 2px;
}
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
th {
  background: var(--surface2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
td:last-child { white-space: nowrap; }
td strong { display: block; font-weight: 700; font-size: .88rem; }
td small  { display: block; color: var(--muted); margin-top: 2px; font-size: .75rem; }
td b      { margin-left: 8px; font-weight: 800; }

/* ── 20. Product Cards (mobile) ───────────────── */
.mobileList { display: none; }
.productCard {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 16px;
  display: grid;
  gap: 11px;
  box-shadow: var(--sh-xs);
  transition: border-color .13s, transform .12s;
}
.productCard:hover { border-color: var(--brand-md); transform: translateY(-1px); }
.productCard strong { display: block; font-weight: 700; }
.productCard small  { display: block; color: var(--muted); margin-top: 2px; font-size: .78rem; }
.productCard > div:last-child { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.productCard p { font-size: .875rem; margin: 0; color: var(--text2); }

/* ── 21. Detail View ──────────────────────────── */
.detail dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px 24px;
  margin: 18px 0;
  padding: 20px;
  background: var(--surface2);
  border-radius: var(--r);
  border: 1px solid var(--line);
}
.detail dt {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 3px;
}
.detail dd { margin: 0; font-weight: 800; font-size: .95rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── 22. Form / Fieldset ──────────────────────── */
.formPanel form { display: grid; gap: 16px; }
fieldset {
  border: 1px solid #dbe5f1;
  border-radius: var(--r-lg);
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
  background: linear-gradient(180deg, #fcfdff 0%, #f8fbff 100%);
}
legend {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .12rem .55rem;
  color: #1e3a8a;
  background: #eaf1ff;
  border: 1px solid #d6e5ff;
  border-radius: 999px;
}
fieldset label:has(textarea) { grid-column: 1 / -1; }

.formPanel h2 {
  margin-bottom: .35rem;
}

.formPanel .back {
  margin-bottom: 6px;
}

/* ── 23. Segmented Control ────────────────────── */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface2);
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.05);
}
.segmented button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: .62rem;
  font-weight: 700;
  font-size: .875rem;
  color: var(--muted);
  transition: background .16s, color .16s, box-shadow .16s, transform .12s;
}
.segmented button:hover {
  transform: translateY(-1px);
}
.segmented button:first-child:hover {
  background: #f0fdf4;
  color: #15803d;
}
.segmented button:last-child:hover {
  background: #fff1f2;
  color: #be123c;
}
.segmented button.activo {
  transform: translateY(0);
}
.segmented button.activo:first-child {
  background: linear-gradient(180deg, #ecfdf3 0%, #dcfce7 100%);
  color: #166534;
  box-shadow: 0 3px 10px rgba(22,163,74,.22);
}
.segmented button.activo:last-child {
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
  color: #9f1239;
  box-shadow: 0 3px 10px rgba(225,29,72,.18);
}

/* ── 24. Preview Block ────────────────────────── */
.preview {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--r);
  background: var(--brand-lt);
  border: 1px solid var(--brand-md);
  padding: 13px 16px;
  font-size: .88rem;
  font-weight: 600;
}
.negativo { color: var(--danger); font-weight: 800; }

/* ── 25. Movement List ────────────────────────── */
.movementList { display: grid; gap: 8px; }
.movementList article {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  align-items: start;
  transition: background .1s;
}
.movementList article:hover { background: var(--surface2); }
.movementList strong { font-size: .88rem; font-weight: 700; }
.movementList p      { margin: 3px 0 0; font-size: .82rem; color: var(--text2); }
.movementList small  { color: var(--muted); font-size: .76rem; }

/* ── 26. Danger text ──────────────────────────── */
.peligroTexto { color: var(--danger); }

/* ── 27. Settings Grid ────────────────────────── */
.settingsGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.settingsGrid article {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  background: var(--surface2);
}

/* ── 28. Toast ────────────────────────────────── */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  background: var(--text);
  color: #fff;
  border-radius: var(--r);
  padding: 12px 18px;
  box-shadow: var(--sh-lg);
  font-weight: 600;
  font-size: .875rem;
  max-width: 320px;
}
.toast.error { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* ── 29. Mobile Nav ───────────────────────────── */
.mobileNav { display: none; }

/* ── 30. Responsive · Tablet ──────────────────── */
@media (max-width: 1020px) {
  .appShell { grid-template-columns: 1fr; }
  .sidebar  { display: none; }
  .workspace { padding: 16px 16px 90px; }
  .metricGrid { grid-template-columns: repeat(2, 1fr); }
  .twoColumns { grid-template-columns: 1fr; }
  .topbar .boton { display: none; }

  .mobileNav {
    position: fixed;
    left: 10px; right: 10px; bottom: 10px;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    background: rgba(255,255,255,.96);
    box-shadow: var(--sh-lg);
    backdrop-filter: blur(20px);
  }
  .mobileNav button {
    border: 0;
    background: transparent;
    border-radius: var(--r-lg);
    padding: 8px 4px;
    color: var(--muted);
    display: grid;
    gap: 3px;
    place-items: center;
    transition: background .13s, color .13s;
    position: relative;
  }
  .mobileNav .activo {
    background: var(--brand-lt);
    color: var(--brand);
    font-weight: 700;
  }
  .mobileNav b    { display: flex; align-items: center; justify-content: center; }
  .mobileNav span { font-size: .66rem; font-weight: 600; }
  .mobileNav .navCount { position: absolute; top: 4px; right: 16px; font-size: .6rem; }
}

/* ── 31. Responsive · Mobile ──────────────────── */
@media (max-width: 720px) {
  .hero           { display: grid; padding: 18px 20px; }
  .metricGrid, .filters, fieldset, .settingsGrid { grid-template-columns: 1fr; }
  .tableWrap      { display: none; }
  .mobileList     { display: grid; gap: 10px; }
  .sectionHead    { align-items: flex-start; }
  .detail dl      { grid-template-columns: 1fr; }
  .actions        { display: grid; }
  .actions .boton { width: 100%; }
  .toast          { left: 12px; right: 12px; bottom: 82px; }
  .workspace      { padding-inline: 12px; }
  .panel          { padding: 16px; }
  .twoColumns     { gap: 12px; }
}

/* ── 32. Motion ───────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toastIn .2s ease;
  }
  .boton, .navItem, .attention, .productCard, .movementList article {
    transition: transform .14s ease, background .14s ease,
                border-color .14s ease, box-shadow .14s ease;
  }
}

