/* ============================================================
   Inventarios — Design system v4 · Minimalismo refinado
   Superficies planas · bordes hairline · tipografía protagonista
   Paleta neutra zinc + un acento teal · sin gradientes decorativos
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* neutros */
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e4e4e7;
  --line-soft: #f0f0f2;
  --fill: #f4f4f5;
  /* acento único */
  --accent: #0d9488;
  --accent-ink: #0f766e;
  --accent-fill: #f0fdfa;
  /* estado (solo puntos y texto) */
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  /* escala */
  --r: 10px;
  --r-sm: 8px;
  --r-xs: 6px;
  --shadow: 0 1px 2px rgba(24,24,27,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
a { color: inherit; }
::selection { background: #d1f0ec; }

/* a11y */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 0 0 var(--r-sm) 0; font-weight: 600; text-decoration: none;
}
.skip:focus { left: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  color: var(--ink-2);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 60;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff;
}
.brand-mark svg { width: 22px; height: 22px; display: block; }
.login-brand .brand-mark { width: 34px; height: 34px; }
.login-brand .brand-mark svg { width: 25px; height: 25px; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.menu { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; flex: 1; overflow-y: auto; }
.menu-label {
  font-size: 10.5px; font-weight: 600; color: var(--faint);
  text-transform: uppercase; letter-spacing: .09em;
  padding: 16px 8px 5px;
}
.mi {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.mi svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); }
.mi:hover { background: var(--fill); color: var(--ink); }
.mi.active { background: var(--ink); color: #fff; }
.mi.active svg { color: #fff; }
.mi-warn { color: var(--ink-2); }
.mi-cta { color: var(--accent-ink); }
.mi-cta svg { color: var(--accent-ink); }
.mi-cta:hover { background: var(--accent-fill); color: var(--accent-ink); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 9px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--fill); color: var(--ink-2);
  font-weight: 600; font-size: 11.5px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-soft { background: var(--fill); color: var(--ink-2); }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 46px; height: 46px; font-size: 15px; border-radius: var(--r); }
.who { min-width: 0; flex: 1; }
.who .who-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .who-mail { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi-cuenta {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); padding: 6px; border-radius: var(--r-xs);
}
.mi-cuenta:hover { background: var(--fill); color: var(--ink); }
.sidebar .btn-ghost { color: var(--muted); }
.sidebar .btn-ghost:hover { background: var(--fill); color: var(--ink); }

.main { flex: 1; min-width: 0; padding: 34px 40px 48px; max-width: 1180px; }
.main-inner { animation: fadein .2s ease-out; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.nav-toggle, .nav-open, .nav-backdrop { display: none; }

/* ---------- Login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px 26px;
}
.login-brand { display: flex; gap: 10px; align-items: center; padding: 0 0 4px; }
.login-brand .brand-mark { width: 34px; height: 34px; font-size: 13px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 8px 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 5px; }
.login-form button { margin-top: 14px; padding: 10px; font-size: 14.5px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- Tipografía ---------- */
.eyebrow {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .1em; margin: 0 0 3px;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.muted-title { font-weight: 500; color: var(--faint); font-size: .75em; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p.muted { margin: 2px 0 0; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.txt-warn { color: var(--warn); font-weight: 600; }
.txt-danger { color: var(--danger); font-weight: 600; }
.txt-ok { color: var(--ok); font-weight: 600; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .93em; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--fill); color: var(--ink-2); font-size: 11.5px; font-weight: 500;
}
.h-ico { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; color: var(--muted); }
.foot-note { text-align: center; color: var(--faint); font-size: 12px; margin: 44px 0 0; }
.link { color: var(--ink); text-decoration: none; font-weight: 500; border-bottom: 1px solid var(--line); }
.link:hover { border-bottom-color: var(--accent); color: var(--accent-ink); }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.inline { display: inline; }
.grow { flex: 1; }
.grow2 { flex: 2; }

/* ---------- Toasts ---------- */
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 16px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 500;
  animation: fadein .2s ease-out;
}
.toast-ok svg { color: var(--ok); }
.toast-err svg { color: var(--danger); }
.flash-ok { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 0 0 26px; }
.kpi-grid-tight { margin: 0 0 22px; }
.kpi {
  background: var(--surface); border-radius: var(--r);
  border: 1px solid var(--line);
  padding: 15px 17px 13px;
  display: flex; flex-direction: column; gap: 2px;
  text-decoration: none;
}
.kpi:hover { border-color: var(--faint); }
.kpi-label { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--faint); font-weight: 500; }
.kpi-warn { border-left: 3px solid var(--warn); }
.kpi-link:hover .kpi-value { color: var(--accent-ink); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--r);
  border: 1px solid var(--line);
  padding: 18px 20px; margin-bottom: 16px;
  overflow-x: auto;
}
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 14px; letter-spacing: -.01em; }
.card h2 svg { width: 15px; height: 15px; color: var(--muted); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 940px) { .cols-2 { grid-template-columns: 1fr; } }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
.table th.num { text-align: right; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover { background: #fcfcfd; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--fill); color: var(--ink-2);
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-in { background: #f0fdf4; color: #15803d; }
.badge-out { background: #eff6ff; color: #1d4ed8; }
.badge-mut { background: var(--fill); color: var(--muted); }

/* ---------- Feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-body { min-width: 0; }
.feed-body > div:first-child { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user-cell { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- Barras de nivel ---------- */
.lowlist { list-style: none; margin: 0; padding: 0; }
.lowlist li {
  display: grid; grid-template-columns: minmax(130px, 1.1fr) minmax(90px, .9fr) auto;
  gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft);
}
.lowlist li:last-child { border-bottom: 0; }
.low-track { width: 100%; height: 4px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.low-track-wide { margin-top: 6px; }
.low-fill { height: 100%; border-radius: 999px; background: var(--muted); transition: width .3s; }
.low-warn { background: var(--warn); }
.low-out { background: var(--danger); }

/* ---------- Sparkline / categorías ---------- */
.spark-wrap { padding: 2px 0 0; }
.spark-labels { display: flex; justify-content: space-between; width: 168px; margin-top: 5px; }
.spark-labels span { font-size: 10px; color: var(--faint); width: 12px; text-align: center; }
.legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-left: 7px; }
.legend-dot:first-child { margin-left: 0; }
.dot-in { background: var(--accent); }
.dot-out { background: #c9ced6; }
.cat-bars { display: flex; flex-direction: column; gap: 11px; }
.cat-row { display: grid; grid-template-columns: minmax(120px, 170px) 1fr; gap: 14px; align-items: center; }
.cat-meta { display: flex; flex-direction: column; min-width: 0; }
.cat-meta .strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.cat-track { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.cat-fill { height: 100%; border-radius: 999px; background: var(--ink-2); min-width: 3px; transition: width .4s ease-out; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { position: relative; padding: 0 0 14px 18px; border-left: 1px solid var(--line); }
.tl-item:last-child { padding-bottom: 2px; border-left-color: transparent; }
.tl-dot {
  position: absolute; left: -3.5px; top: 5px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint);
}
.tl-in .tl-dot { background: var(--ok); }
.tl-out .tl-dot { background: var(--muted); }
.tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-motivo { font-size: 13px; margin-top: 2px; }

/* ---------- Ítem hero ---------- */
.item-hero { display: flex; gap: 13px; align-items: center; }
.code-avatar { background: var(--fill); color: var(--ink-2); font-family: ui-monospace, Menlo, monospace; }

/* ---------- Buscador ---------- */
.search-shell {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 11px; transition: border-color .12s;
  max-width: 420px;
}
.search-shell svg { width: 14px; height: 14px; color: var(--faint); flex-shrink: 0; }
.search-shell:focus-within { border-color: var(--ink-2); }
.search-shell input {
  border: 0; outline: none; padding: 8px 0; font: inherit; width: 100%;
  background: transparent; color: var(--ink);
}
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Estados vacíos ---------- */
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.empty-art { width: 64px; height: 48px; margin: 0 auto 8px; display: block; color: #d4d4d8; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 2px; }
.empty-text { font-size: 13px; margin: 0 0 12px; }
.empty-card { text-align: center; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--ink-2); }
.input {
  width: 100%; padding: 8.5px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font: inherit; color: var(--ink); background: var(--surface);
  transition: border-color .12s;
}
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--ink-2); }
.field { margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-card { max-width: 840px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.form-inline-card { max-width: 840px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 500; margin: 0; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.field-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-group { display: flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; width: fit-content; }
.radio { display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; padding: 7px 14px; cursor: pointer; font-size: 13.5px; }
.radio:first-child { border-right: 1px solid var(--line); }
.radio input { accent-color: var(--accent); }
.radio:has(input:checked) { background: var(--fill); }
.radio-in { color: #15803d; }
.radio-out { color: #1d4ed8; }
.mov-form { max-width: 410px; }
.form-card .hint { margin-top: 14px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  text-decoration: none; transition: all .12s; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--ink-2); background: var(--surface); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--fill); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Paginación ---------- */
.pager { display: flex; gap: 5px; align-items: center; justify-content: center; margin: 16px 0; }
.pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--r-xs);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 13px; font-weight: 500; text-decoration: none;
}
.pg-btn:hover { border-color: var(--ink-2); color: var(--ink); }
.pg-active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pg-dots { color: var(--faint); padding: 0 2px; }

/* ---------- Impresión ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .no-print, .foot-note, .pager, .toast, .skip, .nav-open { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { border: 1px solid #ccc; break-inside: avoid; }
}

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 248px; height: 100vh;
    transform: translateX(-102%); transition: transform .2s ease-out;
    box-shadow: 0 0 60px rgba(24,24,27,.12);
  }
  .nav-toggle:checked ~ .layout .sidebar { transform: none; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(24,24,27,.3); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .nav-toggle:checked ~ .layout .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav-open {
    display: inline-flex; align-items: center; gap: 7px;
    font-weight: 600; font-size: 13px; color: var(--ink-2);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
    padding: 7px 12px; margin-bottom: 14px; cursor: pointer;
  }
  .nav-open svg { width: 15px; height: 15px; }
  .menu { flex-direction: column; }
  .main { padding: 18px 16px 32px; }
  .lowlist li { grid-template-columns: 1fr auto; }
  .lowlist .low-track { grid-column: 1 / -1; order: 3; }
  .cat-row { grid-template-columns: 1fr; gap: 5px; }
}
