/* tokens.css — Sistema visual Grupo Magma (producto-ui.md · 16-nov-2026)
 * Dirección B (filas planas Linear/Stripe). Cero hex sueltos fuera de tokens,
 * cero cajas dentro de cajas, cero baldosas de cifras, móvil 390px primero.
 */

:root {
  --bg-base: #ffffff;
  --bg-surface: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-subtle: #eff1f5;

  --border-subtle: #e5e8ee;
  --border-strong: #cfd5df;

  --text-title: #14171c;
  --text-body: #2f3540;
  --text-muted: #5e6675;

  --btn-primary-bg: #14171c;
  --btn-primary-fg: #f8f9fb;
  --btn-primary-hover: #262b34;

  --state-ok: #15803d;
  --state-ok-bg: #eaf6ee;
  --state-review: #1d4ed8;
  --state-review-bg: #ebf2fe;
  --state-warn: #b45309;
  --state-warn-bg: #fef4e6;
  --state-danger: #b91c1c;
  --state-danger-bg: #fdecec;

  --bar-track: #e6e9ef;
  --shadow-bar: 0 -1px 0 #e5e8ee;
  --radius-sm: 8px;
  --radius-md: 12px;
  --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="black"] {
  --bg-base: #0b0d10;
  --bg-surface: #13161c;
  --bg-elevated: #1b2028;
  --bg-subtle: #232934;

  --border-subtle: #252b36;
  --border-strong: #343c4b;

  --text-title: #eef1f6;
  --text-body: #c9d0dc;
  --text-muted: #8e97a8;

  --btn-primary-bg: #eef1f6;
  --btn-primary-fg: #11141a;
  --btn-primary-hover: #d8dee8;

  --state-ok: #4ade80;
  --state-ok-bg: #132a1d;
  --state-review: #60a5fa;
  --state-review-bg: #14243d;
  --state-warn: #fbbf24;
  --state-warn-bg: #2e2310;
  --state-danger: #f87171;
  --state-danger-bg: #321619;

  --bar-track: #232934;
  --shadow-bar: 0 -1px 0 #252b36;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--bg-base);
  color: var(--text-body);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-base);
  color: var(--text-body);
}

/* Cabecera de una sola línea */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 6px 16px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.crumb-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--state-ok);
  flex-shrink: 0;
}

.crumb-text {
  margin: 0;
  font-size: 0.84375rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-title);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 520px) {
  .crumb-text {
    font-size: 0.9375rem;
  }
}

.crumb-prefix {
  display: none;
  color: var(--text-muted);
  font-weight: 500;
}

@media (min-width: 520px) {
  .crumb-prefix {
    display: inline;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Sistema único de botones: 44px, radio 8px, máximo 3 variantes */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border: 1px solid var(--btn-primary-bg);
}

.btn-primary:hover {
  background-color: var(--btn-primary-hover);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-title);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background-color: var(--bg-surface);
}

.btn-text {
  background-color: transparent;
  color: var(--text-body);
  border: 1px solid transparent;
  padding: 0 10px;
}

.btn-text:hover {
  background-color: var(--bg-surface);
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Contenedor principal */
.page-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 92px;
}

/* Pieza protagonista compacta arriba (<180px en móvil para que el listado empiece antes de 260px) */
.protagonist {
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.protagonist-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}

.protagonist-eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.protagonist-figure-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 2px;
}

.protagonist-figure {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-title);
  font-variant-numeric: tabular-nums;
}

.protagonist-unit {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
}

.protagonist-meta {
  display: none;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 768px) {
  .protagonist {
    padding: 14px 0 16px;
  }

  .protagonist-meta {
    display: inline;
  }
}

.quota-bar-svg {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.seg-track {
  fill: var(--bar-track);
}

.seg-ok {
  fill: var(--state-ok);
}

.seg-review {
  fill: var(--state-review);
}

.seg-warn {
  fill: var(--state-warn);
}

.seg-danger {
  fill: var(--state-danger);
}

.protagonist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.swatch-ok {
  background-color: var(--state-ok);
}

.swatch-review {
  background-color: var(--state-review);
}

.swatch-warn {
  background-color: var(--state-warn);
}

/* Bloques de sección y cabeceras planas */
.section-block {
  padding-top: 20px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.section-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-title);
}

.section-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Chips semánticos (píldoras solo para estado/filtro) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}

.chip-ok {
  background-color: var(--state-ok-bg);
  color: var(--state-ok);
}

.chip-review {
  background-color: var(--state-review-bg);
  color: var(--state-review);
}

.chip-warn {
  background-color: var(--state-warn-bg);
  color: var(--state-warn);
}

.chip-danger {
  background-color: var(--state-danger-bg);
  color: var(--state-danger);
}

/* Listas de filas planas (Linear/Stripe) */
.flat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.flat-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
  align-items: start;
}

.row-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.row-icon svg {
  width: 18px;
  height: 18px;
}

.icon-ok {
  background-color: var(--state-ok-bg);
  color: var(--state-ok);
}

.icon-review {
  background-color: var(--state-review-bg);
  color: var(--state-review);
}

.icon-warn {
  background-color: var(--state-warn-bg);
  color: var(--state-warn);
}

.row-main {
  min-width: 0;
}

.row-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-title);
}

.row-desc {
  margin: 3px 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.row-path {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-body);
}

.row-right {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row-figure {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-title);
  font-variant-numeric: tabular-nums;
}

/* Fila plana de 4 cifras (sin baldosas ni tarjetas) */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-subtle);
}

.metric-item {
  padding: 14px 12px 14px 0;
  min-width: 0;
}

.metric-item:nth-child(even) {
  padding-left: 12px;
  padding-right: 0;
  border-left: 1px solid var(--border-subtle);
}

.metric-item:nth-child(1),
.metric-item:nth-child(2) {
  border-bottom: 1px solid var(--border-subtle);
}

.metric-value-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
}

.metric-value {
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-title);
  font-variant-numeric: tabular-nums;
}

.metric-unit {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.metric-label {
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.metric-mini-bar {
  display: block;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

/* Estados: cargando, vacío, error */
.state-panel {
  padding: 24px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.state-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-title);
}

.state-desc {
  margin: 6px 0 14px;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background-color: var(--bg-subtle);
  margin-bottom: 10px;
}

.w-40 {
  width: 40%;
}

.w-70 {
  width: 70%;
}

.w-90 {
  width: 90%;
}

/* Toast sobrio */
.toast {
  position: fixed;
  bottom: 76px;
  right: 16px;
  left: 16px;
  max-width: 360px;
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-title);
  font-size: 0.875rem;
  z-index: 40;
}

.is-hidden {
  display: none;
}

/* Barra fija inferior en móvil (zona del pulgar, opaca; el contenido termina 92px por encima) */
.mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background-color: var(--bg-base);
  box-shadow: var(--shadow-bar);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bottom-bar-info {
  min-width: 0;
}

.bottom-bar-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottom-bar-status {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-title);
  font-variant-numeric: tabular-nums;
}

.desktop-only {
  display: none;
}

@media (min-width: 680px) {
  .flat-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
  }

  .row-right {
    grid-column: 3;
    justify-content: flex-end;
    text-align: right;
  }
}

@media (min-width: 768px) {
  .page-shell {
    padding: 0 24px 48px;
  }

  .topbar-inner {
    padding: 8px 24px;
  }

  .mobile-bottom-bar {
    display: none;
  }

  .desktop-only {
    display: inline-flex;
  }

  .toast {
    bottom: 24px;
    left: auto;
    margin: 0;
  }
}

@media (min-width: 900px) {
  .metrics-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-item {
    padding: 16px;
    border-bottom: none;
  }

  .metric-item:first-child {
    padding-left: 0;
  }

  .metric-item:last-child {
    padding-right: 0;
  }

  .metric-item:nth-child(1),
  .metric-item:nth-child(2) {
    border-bottom: none;
  }

  .metric-item + .metric-item {
    border-left: 1px solid var(--border-subtle);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}
