/* =========================================================================
   GOCARE · Integrador — estilos base
   ========================================================================= */
:root {
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --borde: #ECEEF2;
  --borde-fuerte: #E1E4EA;
  --borde-sidebar: #E7E9EE;
  --borde-control: #E3E6EB;
  --texto: #1A212C;
  --texto-2: #5B6472;
  --muted: #9AA2B1;
  --verde: #3F7A63;
  --verde-bg: #E6F0EB;
  --ambar: #96603A;
  --ambar-bg: #F6EDE4;
  --acento: #3F5C8A;
  --acento-hover: #34507A;
  --acento-anillo: rgba(63, 92, 138, 0.14);
  --activo-bg: #EEF1F8;
  --hover-bg: #F4F5F8;
  --peligro: #8F4A4A;
  --peligro-bg: #F4E8E8;
  --consola: 44px;
  --sombra: 0 1px 2px rgba(20, 25, 35, 0.03);
  --sombra-menu: 0 10px 28px rgba(20, 25, 35, 0.10), 0 1px 2px rgba(20, 25, 35, 0.04);
  --radio: 12px;
  --sidebar: 220px;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { font-size: 14px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; flex-shrink: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--borde-sidebar);
  display: flex;
  flex-direction: column;
  padding: 22px 12px 16px;
  z-index: 10;
}

.logo {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.16em;
  color: var(--texto);
  padding: 4px 12px 26px;
  display: block;
  text-decoration: none;
}
.logo:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 6px; }

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

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--texto-2);
  font-weight: 600;
  font-size: 13.5px;
  transition: background-color .12s, color .12s;
}
.nav-item:hover { background: var(--hover-bg); color: var(--texto); }
.nav-item.activo { background: var(--activo-bg); color: var(--texto); }
.nav-item.activo::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--acento);
}
.nav-item.activo svg { color: var(--acento); }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-pie {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.sidebar-pie .punto { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.sidebar-pie.ok .punto { background: var(--verde); }
.sidebar-pie.caido .punto { background: var(--ambar); }
.sidebar-pie.caido { color: var(--ambar); }

/* ---------- Contenido ---------- */
.contenido {
  margin-left: var(--sidebar);
  padding: 34px 36px 48px;
  min-height: 100vh;
  max-width: calc(1480px + var(--sidebar));
}

.cabecera {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.cabecera h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.015em;
}
.cabecera p { margin: 4px 0 0; color: var(--texto-2); font-size: 13.5px; }
.cabecera-acciones { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.btn:focus-visible, .filtro:focus-visible, .btn-icono:focus-visible, .nav-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--acento-anillo);
}
.btn-primario { background: var(--acento); color: #fff; }
.btn-primario:hover { background: var(--acento-hover); }
.btn-secundario { background: var(--surface); border-color: var(--borde-control); color: var(--texto); box-shadow: var(--sombra); }
.btn-secundario:hover { border-color: #D3D7DE; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .girando { animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

.btn-icono {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.btn-icono:hover { background: var(--hover-bg); color: var(--texto); border-color: var(--borde); }

/* ---------- Tarjetas de resumen ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 15px 18px 14px;
}
.stat-lbl { font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.stat-val {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 1px; min-height: 17px; }
.stat-sub.aviso { color: var(--ambar); }

/* ---------- Barra de herramientas ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.buscador { position: relative; width: 340px; max-width: 100%; }
.buscador svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.buscador input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 38px;
  border: 1px solid var(--borde-control);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--sombra);
  font: inherit;
  font-size: 13.5px;
  color: var(--texto);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.buscador input::placeholder { color: var(--muted); }
.buscador input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239AA2B1' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.buscador input:focus { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-anillo); }
.buscador kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--borde-control);
  border-radius: 5px;
  padding: 0 6px;
  line-height: 18px;
}
.buscador input:focus + kbd, .buscador input:not(:placeholder-shown) + kbd { display: none; }

.desplegable { position: relative; }
.filtro {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 11px 0 13px;
  border: 1px solid var(--borde-control);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--sombra);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--texto-2);
  cursor: pointer;
  white-space: nowrap;
}
.filtro b { color: var(--texto); font-weight: 700; }
.filtro:hover { border-color: #D3D7DE; }
.filtro svg { color: var(--muted); }
.filtro.aplicado { border-color: #C9D3E4; background: var(--activo-bg); }
.filtro.aplicado b { color: var(--acento); }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 250px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--borde);
  border-radius: 10px;
  box-shadow: var(--sombra-menu);
  padding: 6px;
  z-index: 20;
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--texto);
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover-bg); outline: none; }
.menu-item.sel { font-weight: 700; }
.menu-item.sel svg { color: var(--acento); }
.menu-item .extra { color: var(--muted); font-size: 12px; font-weight: 600; }
.menu-sep { height: 1px; background: var(--borde); margin: 5px 4px; }

.contador { margin-left: auto; color: var(--texto-2); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.contador b { color: var(--texto); }

/* ---------- Tabla de productos ---------- */
.tabla-cab, .fila {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 432px 34px;
  align-items: center;
  column-gap: 20px;
}
.tabla-cab {
  padding: 4px 17px 9px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.lista { display: flex; flex-direction: column; gap: 8px; }

.fila {
  background: var(--surface);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 12px 16px;
  min-height: 70px;
  transition: border-color .12s;
}
.fila:hover { border-color: var(--borde-fuerte); }

.c-prod { display: flex; align-items: center; gap: 13px; min-width: 0; }
.thumb {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.prod-txt { min-width: 0; }
.prod-nombre {
  font-weight: 600;
  font-size: 14px;
  color: var(--texto);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sku {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-num { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stock-num.desconocido { color: var(--muted); }
.stock-sub { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 1px; }
.stock-sub.aviso { color: var(--ambar); }
.stock-sub.pend { color: var(--acento); }
.stock-sub.pend::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--acento); }

.badges { display: flex; gap: 5px; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 57px;
  height: 25px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  cursor: default;
}
.badge.ok { background: var(--verde-bg); color: var(--verde); }
.badge.err { background: var(--ambar-bg); color: var(--ambar); }
.badge.falta { background: transparent; border-color: #DCE0E6; color: var(--muted); }
.badge.inactivo { border-style: dashed; color: #B7BDC8; }
.falta-txt { font-size: 12px; font-weight: 600; color: var(--ambar); margin-top: 6px; }

.c-acc { display: flex; justify-content: flex-end; }

/* ---------- Estados ---------- */
.fila.esqueleto .bloque { background: #EEF0F3; border-radius: 6px; animation: latido 1.2s ease-in-out infinite; }
@keyframes latido { 50% { opacity: .5; } }

.vacio {
  background: var(--surface);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 44px 24px;
  text-align: center;
  color: var(--texto-2);
}
.vacio h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--texto); }
.vacio p { margin: 0; font-size: 13.5px; }
.vacio.error h3 { color: var(--ambar); }

.pie-lista { display: flex; justify-content: center; padding: 18px 0 0; }
.pie-lista[hidden] { display: none; }

/* ---------- Adaptación ---------- */
@media (max-width: 1260px) {
  .tabla-cab { display: none; }
  .fila { grid-template-columns: minmax(0, 1fr) 110px 34px; row-gap: 12px; }
  .c-canales { grid-column: 1 / -1; grid-row: 2; }
  .c-acc { grid-column: 3; grid-row: 1; }
}
@media (max-width: 900px) {
  :root { --sidebar: 64px; }
  .logo { font-size: 0; padding: 4px 0 22px; text-align: center; }
  .logo::after { content: "G"; font-size: 17px; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item span, .sidebar-pie .estado-txt { display: none; }
  .contenido { padding: 24px 16px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cabecera { flex-direction: column; }
  .buscador { width: 100%; }
  .contador { margin-left: 0; width: 100%; }
  .badges { flex-wrap: wrap; }
}
