/* ============================================================
   Liberación de Margen — Impulsora
   Paleta: rojo Impulsora como acento, tablas estilo BI Publisher
   (encabezado oscuro), estados semánticos con ícono + texto.
   ============================================================ */

:root {
  --brand-red: #d92d20;
  --brand-red-dark: #b42318;
  --ink: #1f2937;
  --ink-secondary: #4b5563;
  --ink-muted: #6b7280;
  --surface: #f6f7f9;
  --card: #ffffff;
  --border: #e5e7eb;
  --table-head: #263140;
  --table-head-ink: #f4f5f7;

  --ok-bg: #ecfdf3;
  --ok-border: #abefc6;
  --ok-ink: #067647;

  --warn-bg: #fffaeb;
  --warn-border: #fedf89;
  --warn-ink: #b54708;

  --bad-cell-bg: #fee4e2;
  --bad-cell-ink: #b42318;
  --hl-cell-bg: #fef7c3;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.45;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hidden { display: none !important; }

/* ============ HERO ============ */

.hero {
  background: linear-gradient(160deg, #1b2431 0%, #263140 55%, #32405a 100%);
  color: #fff;
  padding: 64px 24px 72px;
  text-align: center;
}

.hero-inner { max-width: 720px; margin: 0 auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
}

.brand-mark {
  color: var(--brand-red);
  font-size: 1.5rem;
  line-height: 1;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  font-weight: 700;
}

.hero-sub {
  margin: 0 auto 32px;
  max-width: 520px;
  color: #cbd2dc;
  font-size: 1.02rem;
}

.search-form {
  display: flex;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}

.search-form input {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  font-size: 1.05rem;
  border: 2px solid transparent;
  border-radius: 10px;
  outline: none;
}

.search-form input:focus { border-color: var(--brand-red); }

.search-form button[type="submit"] {
  padding: 14px 26px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand-red);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.search-form button[type="submit"]:hover { background: var(--brand-red-dark); }
.search-form button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }

.hero-hint {
  margin-top: 18px;
  font-size: 0.88rem;
  color: #9aa4b2;
}

.demo-link {
  background: none;
  border: none;
  padding: 0;
  color: #cbd2dc;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.demo-link:hover { color: #fff; }

/* ============ ESTADOS ============ */

.state-block {
  max-width: 560px;
  margin: 40px auto;
  padding: 24px;
  text-align: center;
  color: var(--ink-secondary);
}

#error .state-inner,
#error p {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-ink);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 0;
}

.spinner {
  width: 36px; height: 36px;
  margin: 0 auto 12px;
  border: 4px solid var(--border);
  border-top-color: var(--brand-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RESULTADOS ============ */

.results {
  max-width: 1080px;
  margin: -36px auto 60px;
  padding: 0 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.order-type {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}

/* --- Veredicto --- */

.verdict {
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 18px;
  border: 1px solid;
}

.verdict.approved {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-ink);
}

.verdict.action-required {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

.verdict-headline {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.verdict-icon { font-size: 1.4rem; line-height: 1; }

.verdict-sub {
  margin: 6px 0 0 34px;
  font-size: 0.95rem;
}

.verdict ul.checks {
  margin: 14px 0 0 34px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 0.93rem;
}

.verdict ul.checks li { display: flex; gap: 8px; align-items: baseline; }

.check-icon { flex: none; font-weight: 700; }

.verdict li.check-pass { color: var(--ok-ink); }
.verdict li.check-fail { color: var(--bad-cell-ink); font-weight: 600; }
.verdict li.check-info { color: var(--ink-secondary); }

/* --- Encabezado orden --- */

.header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 24px;
  margin: 14px 0 0;
}

.header-grid > div { min-width: 0; }

.header-grid dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: 2px;
}

.header-grid dd {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* --- Stat tiles --- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-compare {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 4px;
}

.stat-tile.stat-bad {
  background: var(--bad-cell-bg);
  border-color: #fda29b;
}
.stat-tile.stat-bad .stat-value { color: var(--bad-cell-ink); }

.stat-tile.stat-ok .stat-value { color: var(--ok-ink); }

/* --- Tablas --- */

.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  background: var(--table-head);
  color: var(--table-head-ink);
  font-weight: 600;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.78rem;
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th.num, .data-table td.num { text-align: right; }

.data-table tbody tr:nth-child(even) { background: #fafbfc; }

.data-table td.cell-bad {
  background: var(--bad-cell-bg);
  color: var(--bad-cell-ink);
  font-weight: 600;
}

.data-table td.cell-hl { background: var(--hl-cell-bg); }

.data-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--table-head);
  border-bottom: none;
  padding-top: 10px;
}

.tfoot-label { text-align: right; color: var(--ink-secondary); }

/* --- Detalle colapsable --- */

details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details summary::-webkit-details-marker { display: none; }

details summary::before {
  content: "▸";
  color: var(--ink-muted);
  transition: transform 0.15s;
}

details[open] summary::before { transform: rotate(90deg); }

details summary h2 { margin: 0; display: inline; }

details .table-scroll { margin-top: 16px; }

.footnote {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.82rem;
  margin: 26px 0 0;
}

.footnote code {
  background: #eceef1;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 560px) {
  .hero { padding: 44px 18px 56px; }
  .search-form { flex-direction: column; }
  .results { padding: 0 12px; }
  .card { padding: 16px; }
  .verdict-sub, .verdict ul.checks { margin-left: 0; }
}
