/* Farmaclinik UI
   Hoja de estilos unica del proyecto (sin framework), packages/web.
   Tokens y componentes documentados en docs/sistema-diseno.md

   Estructura de este archivo:
     1. Tokens (claro / oscuro por media query y por data-theme)
     2. Reset y base
     3. Utilidades comunes (.wrap, .btn, .icon, .reveal)
     4. Landing publica
     5. App privada (todo acotado a .app-shell)
*/

/* =========================== 1. Tokens ================================== */

:root {
  --bone: #fbf7f3;
  --bone-raised: #ffffff;
  --palo: #efe3d3;
  --palo-deep: #d9c6a9;
  --ink: #241e1c;
  --ink-soft: #6c5f57;
  --ink-faint: #a8998e;
  --line: #e6d9c8;
  --rosa: #a94454;
  --rosa-strong: #8e3646;
  --rosa-tint: #f4dfe2;
  --rosa-tint-deep: #ecc7cc;

  --ok: #3f7a5c;
  --ok-tint: #dfeee5;
  --warn: #b8862b;
  --warn-tint: #f5e8d2;

  /* Sombras siempre tintadas hacia el rosa de marca, nunca negro puro. */
  --shadow: 219 154 122;

  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --radius-card: 20px;
  --radius-control: 12px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bone: #1a1512;
    --bone-raised: #221b17;
    --palo: #2c231d;
    --palo-deep: #40332a;
    --ink: #f3ece4;
    --ink-soft: #c2b3a7;
    --ink-faint: #8b7a6e;
    --line: #3a2f27;
    --rosa: #e3919d;
    --rosa-strong: #eda7b1;
    --rosa-tint: #3a2429;
    --rosa-tint-deep: #4a2c32;
    --ok: #7fc09d;
    --ok-tint: #203029;
    --warn: #e0b567;
    --warn-tint: #362a17;
    --shadow: 0 0 0;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bone: #1a1512;
  --bone-raised: #221b17;
  --palo: #2c231d;
  --palo-deep: #40332a;
  --ink: #f3ece4;
  --ink-soft: #c2b3a7;
  --ink-faint: #8b7a6e;
  --line: #3a2f27;
  --rosa: #e3919d;
  --rosa-strong: #eda7b1;
  --rosa-tint: #3a2429;
  --rosa-tint-deep: #4a2c32;
  --ok: #7fc09d;
  --ok-tint: #203029;
  --warn: #e0b567;
  --warn-tint: #362a17;
  --shadow: 0 0 0;
  color-scheme: dark;
}

/* =========================== 2. Reset y base ============================ */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bone);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection {
  background: var(--rosa-tint);
  color: var(--rosa-strong);
}

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; flex: none; }

/* =========================== 4. Landing ================================= */
/* ============================================================
   FARMACLINIK — landing page
   Diseño: blanco cálido + tono "palo" (madera pálida) + rosa
   como único acento. Tipografía Public Sans (display y texto).
   Íconos estilo outline (Tabler), stroke-width 2.
   Radios: botones en píldora, tarjetas/paneles en 20px.
   ============================================================ */










@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}











.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 768px) {
  .wrap { padding: 0 40px; }
}

section { position: relative; }

/* -------------------------- reveal-on-scroll -------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ------------------------------ botones -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  padding: 13px 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--rosa); outline-offset: 3px; }

.btn-primary {
  background: var(--rosa);
  color: #fff8f6;
  box-shadow: 0 10px 24px -12px rgb(var(--shadow) / 0.55);
}
.btn-primary:hover { background: var(--rosa-strong); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--rosa); color: var(--rosa-strong); }

.btn-invert {
  background: var(--bone);
  color: var(--rosa-strong);
}
.btn-invert:hover { background: var(--bone-raised); }




/* ------------------------------- nav ------------------------------------ */
header.site-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgb(251 247 243 / 0.86);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}
:root[data-theme="dark"] header.site-nav {
  background: rgb(26 21 18 / 0.86);
}

header.site-nav.is-scrolled {
  border-bottom-color: var(--line);
}
.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--rosa);
  color: #fff8f6;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  flex: none;
}
nav.nav-links {
  display: none;
  align-items: center;
  gap: 34px;
}
nav.nav-links a {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: color 0.15s ease;
}
nav.nav-links a:hover { color: var(--rosa-strong); }
.nav-actions { display: flex; align-items: center; gap: 22px; }
.nav-cta { display: none; }
.login-link {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: color 0.15s ease;
}
.login-link:hover { color: var(--rosa-strong); }
.login-link:focus-visible { outline: 2px solid var(--rosa); outline-offset: 3px; border-radius: 4px; }
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bone-raised);
  color: var(--ink);
}
@media (min-width: 1024px) {
  nav.nav-links { display: flex; }
  .nav-cta { display: inline-flex; }
  .nav-toggle { display: none; }
}

.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 8px 24px 22px;
  border-top: 1px solid var(--line);
  background: var(--bone);
}
.mobile-menu.is-open { display: flex; }
.mobile-menu a {
  padding: 12px 4px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.mobile-menu .btn { margin-top: 12px; align-self: flex-start; }
@media (min-width: 1024px) { .mobile-menu { display: none !important; } }

/* ------------------------------- hero ------------------------------------ */
.hero {
  padding: 56px 0 76px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 44px;
  align-items: center;
}
@media (min-width: 1024px) {
  .hero-grid { grid-template-columns: 1.05fr 0.95fr; gap: 20px; }
}
.hero-copy h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.6rem);
  max-width: 12ch;
}
.hero-copy p.lede {
  margin-top: 22px;
  max-width: 46ch;
  font-size: 1.08rem;
  color: var(--ink-soft);
}
.hero-actions {
  margin-top: 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

/* ------------------------- panel de inventario --------------------------- */
.ledger {
  background: var(--bone-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px -30px rgb(var(--shadow) / 0.45);
}
.ledger-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.ledger-head h3 { font-size: 1.02rem; font-weight: 700; }
.ledger-head span {
  font-size: 0.82rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.ledger-row:last-of-type { border-bottom: none; }
.ledger-item { font-size: 0.93rem; font-weight: 600; }
.ledger-qty {
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag-ok { background: var(--palo); color: var(--ink-soft); }
.tag-low {
  background: var(--rosa-tint);
  color: var(--rosa-strong);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.request-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  background: var(--palo);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.request-info p:first-child {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.request-info p:last-child {
  margin-top: 3px;
  font-size: 0.95rem;
  font-weight: 700;
}
.approve-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: var(--bone);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 999px;
  flex: none;
}
:root[data-theme="dark"] .approve-btn { background: var(--rosa); color: #1a1512; }


/* ---------------------------- declaración ------------------------------- */
.statement {
  padding: 88px 0;
  background: var(--palo);
}
.statement h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  max-width: 20ch;
  color: var(--ink);
}
.statement .statement-follow {
  margin-top: 24px;
  max-width: 42ch;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

/* ------------------------------- bento ----------------------------------- */
.features { padding: 96px 0; }
.section-head { max-width: 42ch; margin-bottom: 46px; }
.section-head h2 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); }
.section-head p {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.bento {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 768px) {
  .bento { grid-template-columns: repeat(6, 1fr); }
  .bento .cell-a { grid-column: span 4; grid-row: span 2; }
  .bento .cell-b { grid-column: span 2; }
  .bento .cell-c { grid-column: span 2; }
  .bento .cell-d { grid-column: span 4; }
}

.cell {
  border-radius: 20px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
}
.cell-a {
  background: var(--ink);
  color: var(--bone);
  justify-content: space-between;
}
.cell-a .cell-icon { background: rgb(255 255 255 / 0.1); color: var(--rosa-strong); }
:root[data-theme="dark"] .cell-a { background: var(--rosa); color: #1a1512; }

.cell-b { background: var(--rosa-tint); }
.cell-c { background: var(--bone-raised); }
.cell-d { background: var(--palo); }

.cell-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--palo);
  color: var(--rosa-strong);
  display: grid;
  place-items: center;
  flex: none;
}
.cell h3 { font-size: 1.15rem; font-weight: 700; }
.cell p { color: var(--ink-soft); font-size: 0.95rem; }
.cell-a p { color: rgb(251 247 243 / 0.72); }
:root[data-theme="dark"] .cell-a p { color: rgb(26 21 18 / 0.75); }


.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 54px;
}
.mini-chart i {
  display: block;
  width: 9px;
  border-radius: 3px;
  background: rgb(251 247 243 / 0.3);
}
.mini-chart i:last-child { background: var(--rosa-strong); }
:root[data-theme="dark"] .mini-chart i { background: rgb(26 21 18 / 0.28); }
:root[data-theme="dark"] .mini-chart i:last-child { background: #1a1512; }


/* ------------------------------- proceso ---------------------------------- */
.process { padding: 96px 0; }
.process-rail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}
@media (min-width: 768px) {
  .process-rail { grid-template-columns: repeat(3, 1fr); gap: 28px; }
}
.step { border-top: 1px solid var(--line); padding-top: 22px; }
.step .num {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 600;
  color: var(--palo-deep);
  line-height: 1;
}
.step h3 {
  margin-top: 14px;
  font-size: 1.2rem;
  font-weight: 700;
}
.step p { margin-top: 10px; color: var(--ink-soft); font-size: 0.96rem; }

/* -------------------------------- roles ------------------------------------ */
.roles { padding: 96px 0; background: var(--bone-raised); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.roles-scroll {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  margin: 0 -24px;
  padding-left: 24px;
  padding-right: 24px;
}
@media (min-width: 768px) {
  .roles-scroll { margin: 0 -40px; padding-left: 40px; padding-right: 40px; }
}
.role-card {
  scroll-snap-align: start;
  flex: 0 0 260px;
  background: var(--bone);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.role-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 34px -22px rgb(var(--shadow) / 0.5);
}
.role-card .cell-icon { margin-bottom: 16px; }
.role-card h3 { font-size: 1.02rem; font-weight: 700; }
.role-card p { margin-top: 8px; font-size: 0.9rem; color: var(--ink-soft); }

/* -------------------------------- foto ------------------------------------- */
.photo-block {
  position: relative;
  min-height: 60vh;
  display: flex;
  align-items: flex-end;
  background-size: cover;
  background-position: center;
  isolation: isolate;
}
.photo-block::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(36 30 28 / 0.05), rgb(20 15 13 / 0.72));
  z-index: -1;
}
.photo-copy { padding: 56px 0; color: #fbf7f3; }
.photo-copy p {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.6vw, 2.4rem);
  max-width: 18ch;
  font-weight: 600;
  line-height: 1.15;
}

/* --------------------------------- cta -------------------------------------- */
.cta-band {
  padding: 90px 0;
  background: var(--rosa);
  color: #fff8f6;
}
.cta-inner {
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: flex-start;
}
@media (min-width: 900px) {
  .cta-inner { flex-direction: row; align-items: center; justify-content: space-between; }
}
.cta-band h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  max-width: 16ch;
  color: #fff8f6;
}
.cta-band p { margin-top: 14px; max-width: 40ch; color: rgb(255 248 246 / 0.82); }
:root[data-theme="dark"] .cta-band { color: #1a1512; }
:root[data-theme="dark"] .cta-band h2 { color: #1a1512; }
:root[data-theme="dark"] .cta-band p { color: rgb(26 21 18 / 0.78); }
:root[data-theme="dark"] .cta-band .btn-invert { background: #1a1512; color: #f3ece4; }


/* -------------------------------- footer -------------------------------------- */
footer {
  padding: 64px 0 40px;
  background: var(--ink);
  color: rgb(251 247 243 / 0.72);
}
:root[data-theme="dark"] footer { background: #120e0c; }

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}
@media (min-width: 768px) {
  .footer-grid { grid-template-columns: 1.3fr 1fr 1fr; }
}
.footer-brand p {
  margin-top: 14px;
  max-width: 32ch;
  font-size: 0.92rem;
  line-height: 1.6;
}
.footer-col h4 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(251 247 243 / 0.45);
  margin-bottom: 16px;
}
.footer-col a, .footer-col p {
  display: block;
  font-size: 0.92rem;
  padding: 6px 0;
  color: rgb(251 247 243 / 0.78);
}
.footer-col a:hover { color: var(--rosa-strong); }
.footer-bottom {
  margin-top: 52px;
  padding-top: 24px;
  border-top: 1px solid rgb(251 247 243 / 0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  justify-content: space-between;
  font-size: 0.82rem;
  color: rgb(251 247 243 / 0.48);
}

::selection { background: var(--rosa-tint); color: var(--rosa-strong); }

/* =========================== 5. App privada ============================= */
/* La app usa 15.5px y una escala mas compacta que la landing. */
.app-shell {
  font-size: 15.5px;
  line-height: 1.5;
}

/* ============================================================
   FARMACLINIK — app shell (post-login)
   Mismos tokens de marca que la landing (blanco / palo / rosa),
   adaptados a interfaz de producto: sidebar + panel de dashboard.
   Tipografía Public Sans. Íconos outline (Tabler), stroke-width 2.
   Radios: botones en píldora, tarjetas/paneles en 20px,
   filas de navegación del sidebar en 12px (regla documentada).
   Color semántico (ok / alerta) va separado del acento de marca.
   Tabla de insumos con estilo tipo admin-dashboard: encabezado
   discreto en mayúsculas, filas con borde inferior fino, hover
   de fila y badges en píldora.
   ============================================================ */


















/* ------------------------------- shell ----------------------------------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
}

/* ------------------------------ sidebar ----------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 272px;
  background: var(--bone-raised);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
}
.sidebar.is-open { transform: translateX(0); }

@media (min-width: 1024px) {
  .sidebar { position: sticky; top: 0; height: 100dvh; transform: none; }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}
.app-shell .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--rosa);
  color: #fff8f6;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  flex: none;
}
:root[data-theme="dark"] .brand-mark { color: #1a1512; }


.sidebar-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-soft);
}
@media (min-width: 1024px) { .sidebar-close { display: none; } }

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nav-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 10px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.94rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item .icon { color: var(--ink-faint); transition: color 0.15s ease; }
.nav-item:hover { background: var(--palo); color: var(--ink); }
.nav-item:hover .icon { color: var(--ink-soft); }
.nav-item:focus-visible { outline: 2px solid var(--rosa); outline-offset: 2px; }

.nav-item.is-active {
  background: var(--rosa-tint);
  color: var(--rosa-strong);
}
.nav-item.is-active .icon { color: var(--rosa-strong); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--palo-deep);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  flex: none;
}
.account-chip .who p:first-child { font-size: 0.88rem; font-weight: 700; }
.account-chip .who p:last-child { font-size: 0.78rem; color: var(--ink-faint); margin-top: 1px; }

.nav-item.logout {
  color: var(--ink-faint);
}
.nav-item.logout:hover {
  background: var(--rosa-tint);
  color: var(--rosa-strong);
}
.nav-item.logout:hover .icon { color: var(--rosa-strong); }

.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgb(36 30 28 / 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 45;
}
.sidebar-scrim.is-open { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { .sidebar-scrim { display: none; } }

/* -------------------------------- main ------------------------------------- */
.main {
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: rgb(251 247 243 / 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 1024px) { .topbar { padding: 18px 36px; } }

.sidebar-open-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bone-raised);
  color: var(--ink);
  flex: none;
}
@media (min-width: 1024px) { .sidebar-open-btn { display: none; } }

.topbar h1 { font-size: 1.08rem; }
.topbar .avatar { margin-left: auto; width: 34px; height: 34px; font-size: 0.85rem; }

.content {
  padding: 28px 20px 56px;
  max-width: 1180px;
}
@media (min-width: 1024px) { .content { padding: 36px 36px 64px; } }

.content-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 26px;
}
.content-head h2 { font-size: clamp(1.4rem, 2.6vw, 1.8rem); }
.content-head p { margin-top: 6px; color: var(--ink-soft); font-size: 0.95rem; }

.app-shell .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  padding: 11px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--rosa);
  color: #fff8f6;
  transition: transform 0.15s ease, background 0.2s ease;
}
.app-shell .btn:hover { background: var(--rosa-strong); }
.app-shell .btn:active { transform: translateY(1px) scale(0.98); }
.app-shell .btn:focus-visible { outline: 2px solid var(--rosa); outline-offset: 3px; }

/* ------------------------------ stat tiles --------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }

.stat-tile {
  background: var(--bone-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 22px;
}
.stat-tile .stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-tile .stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.stat-tile.tone-neutral .stat-icon { background: var(--palo); color: var(--ink-soft); }
.stat-tile.tone-accent .stat-icon { background: var(--rosa-tint); color: var(--rosa-strong); }
.stat-tile.tone-warn .stat-icon { background: var(--warn-tint); color: var(--warn); }

.stat-tile .stat-value {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-tile .stat-label { margin-top: 4px; font-size: 0.86rem; color: var(--ink-soft); }

/* --------------------------------- panels ------------------------------------ */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 960px) { .panel-grid { grid-template-columns: 1.3fr 1fr; } }

.panel {
  background: var(--bone-raised);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.panel-head h3 { font-size: 1rem; font-weight: 700; }
.panel-head a { font-size: 0.84rem; font-weight: 700; color: var(--rosa-strong); }

.req-row, .stock-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.req-row:last-child, .stock-row:last-child { border-bottom: none; }

.req-info, .stock-info { flex: 1; min-width: 0; }
.req-info p:first-child, .stock-info p:first-child {
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.req-info p:last-child, .stock-info p:last-child {
  margin-top: 2px;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-ok { background: var(--ok-tint); color: var(--ok); }

.req-actions { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--palo);
  color: var(--ink-soft);
  border: none;
}
.icon-btn:hover { background: var(--rosa-tint); color: var(--rosa-strong); }
.icon-btn:focus-visible { outline: 2px solid var(--rosa); outline-offset: 2px; }

.stock-qty {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--ink-soft);
  flex: none;
}

/* --------------------------------- tabla -------------------------------------- */
.table-panel { margin-top: 18px; padding: 0; overflow: hidden; }
.table-panel .panel-head { padding: 20px 22px 16px; margin-bottom: 0; }
.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 640px;
}
.data-table thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--palo);
  padding: 12px 22px;
  white-space: nowrap;
}
.data-table thead th.num { text-align: right; }
.data-table tbody td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: var(--bone); }
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}
.data-table td.actions-col { text-align: right; white-space: nowrap; }

.table-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.table-item .row-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--rosa-tint);
  color: var(--rosa-strong);
  display: grid;
  place-items: center;
  flex: none;
}

::selection { background: var(--rosa-tint); color: var(--rosa-strong); }

/* --------------------------- estado vacio -------------------------------
   Para secciones cuya funcionalidad todavia no esta definida. Reutiliza el
   contenedor .panel y no inventa un patron nuevo. */
.app-shell .empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
  padding: 56px 24px;
}
.app-shell .empty-state .empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--rosa-tint);
  color: var(--rosa-strong);
  display: grid;
  place-items: center;
}
.app-shell .empty-state h3 {
  font-size: 1.05rem;
}
.app-shell .empty-state p {
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 46ch;
}

/* Variante neutra del badge, para etiquetas que no comunican estado
   (por ejemplo el rol de un usuario). El rosa queda reservado a la marca. */
.app-shell .badge-neutral {
  background: var(--palo);
  color: var(--ink-soft);
}

/* --------------------------- acceso (login) -----------------------------
   Pantalla centrada, fuera del .app-shell: todavia no hay sesion. */
.acceso {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bone);
}
.acceso-card {
  width: 100%;
  max-width: 400px;
  background: var(--bone-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: 0 24px 60px -40px rgb(var(--shadow) / 0.6);
}
.acceso-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 24px;
  text-decoration: none;
}
.acceso-card h1 {
  font-size: 1.45rem;
  margin-bottom: 6px;
}
.acceso-card .acceso-lede {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.campo {
  display: block;
  margin-bottom: 16px;
}
.campo span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.campo input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bone);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 11px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.campo input:focus {
  outline: none;
  border-color: var(--rosa);
  box-shadow: 0 0 0 3px var(--rosa-tint);
}
.acceso-card .btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}
.acceso-nota {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--warn-tint);
  color: var(--warn);
  font-size: 0.8rem;
  line-height: 1.45;
}
.acceso-volver {
  display: inline-block;
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.acceso-volver:hover { color: var(--rosa-strong); }

/* Accion no disponible (por ejemplo, editar un usuario protegido del
   sistema, que un trigger de Postgres impide borrar). */
.app-shell .icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.app-shell .icon-btn:disabled:hover {
  background: transparent;
  border-color: var(--line);
  color: inherit;
}

/* Error de credenciales en el formulario de acceso. Usa el rosa de marca
   porque aqui SI comunica un fallo de la accion, no un estado de dato. */
.acceso-error {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--rosa-tint);
  color: var(--rosa-strong);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Espera mientras se comprueba la sesion, antes de saber si hay que
   redirigir al login o pintar la app. */
.cargando {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

/* "Salir" pasó de <a> a <button> al conectar el logout real: se normaliza
   para que siga viéndose como una fila de navegación más. */
.app-shell button.nav-item {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.app-shell button.nav-item:disabled {
  opacity: 0.6;
  cursor: progress;
}
