/* MarketOps - consola de operaciones. Sobria, neutra, un acento (teal). Modo oscuro por prefers-color-scheme. */

:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-2: #eceff1;
  --text: #1b2127;
  --muted: #5d6872;
  --border: #d3d9de;
  --accent: #0d5c63;
  --accent-text: #ffffff;
  --accent-soft: #dcecee;
  --link: #0d5c63;
  --ok: #17703f;
  --ok-bg: #ddf1e5;
  --warn: #8a5200;
  --warn-bg: #fcefd2;
  --fail: #a4231a;
  --fail-bg: #fbe2df;
  --run: #0d5c63;
  --run-bg: #dcecee;
  --skip: #5d6872;
  --skip-bg: #e4e8eb;
  --banner-bg: #1f2a30;
  --banner-text: #e3e9ec;
  --focus: #0d5c63;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111518;
    --surface: #182024;
    --surface-2: #20292e;
    --text: #e2e8eb;
    --muted: #9aa6ae;
    --border: #2c373e;
    --accent: #4fb3ba;
    --accent-text: #0b1316;
    --accent-soft: #17353a;
    --link: #7fd0d5;
    --ok: #5fcf8f;
    --ok-bg: #15301f;
    --warn: #f0bd5a;
    --warn-bg: #3a2d12;
    --fail: #ff8a80;
    --fail-bg: #3d1b18;
    --run: #7fd0d5;
    --run-bg: #17353a;
    --skip: #9aa6ae;
    --skip-bg: #262f35;
    --banner-bg: #0a0e10;
    --banner-text: #aab5bd;
    --focus: #7fd0d5;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}
h1 { font-size: 1.35rem; margin: 0.2rem 0 0.5rem; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; font-weight: 650; }
h3 { font-size: 0.92rem; margin: 0.9rem 0 0.3rem; color: var(--muted); }
p { margin: 0.4rem 0; }
a { color: var(--link); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 0.05rem 0.3rem; border-radius: 4px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.stale { color: var(--warn); font-weight: 600; }
.nowrap { white-space: nowrap; }
.clip { max-width: 28rem; overflow-wrap: anywhere; }
.inline { display: inline; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.between { justify-content: space-between; }
.status-row { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.crumbs { font-size: 0.82rem; color: var(--muted); margin: 0 0 0.2rem; }
.meta { color: var(--muted); font-size: 0.86rem; margin: 0 0 0.6rem; }
.summary { font-weight: 550; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.error-text { color: var(--fail); }

/* banner de piloto */
.banner {
  background: var(--banner-bg);
  color: var(--banner-text);
  font-size: 0.76rem;
  padding: 0.38rem 1rem;
  text-align: center;
  letter-spacing: 0.01em;
}

/* cabecera */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--accent); text-decoration: none; letter-spacing: 0.02em; }
.who { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; flex-wrap: wrap; justify-content: flex-end; }
.who-name { font-weight: 600; }

/* disposición */
.layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 90px); }
.layout-public { display: block; }
.nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0.7rem 0.6rem;
}
.nav h3 { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0.9rem 0.4rem 0.25rem; }
.nav h3:first-child { margin-top: 0.2rem; }
.nav a {
  display: block;
  padding: 0.3rem 0.55rem;
  border-radius: 5px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.content { padding: 1.2rem 1.4rem; min-width: 0; max-width: 1280px; width: 100%; }
.layout-public .content { margin: 0 auto; }

/* tarjetas y KPIs */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 0 0 1rem;
  min-width: 0;
}
.login { max-width: 380px; margin: 2.5rem auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.cards .card { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.7rem; margin: 0.6rem 0 1rem; }
.kpi {
  display: flex; flex-direction: column; gap: 0.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 0.9rem; text-decoration: none; color: var(--text);
}
.kpi-label { font-size: 0.78rem; color: var(--muted); }
.kpi-value { font-size: 1.55rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 0.2rem 0; }
.keywords { line-height: 1.9; }
.tag {
  display: inline-block; font-size: 0.74rem; padding: 0 0.4rem; margin: 0.05rem 0.1rem;
  border-radius: 4px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}

/* facts (definición de datos) */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0; font-size: 0.92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* pills de estado */
.pill {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap; line-height: 1.5;
  background: var(--skip-bg); color: var(--skip); border: 1px solid transparent;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-fail { background: var(--fail-bg); color: var(--fail); }
.pill-run { background: var(--run-bg); color: var(--run); }
.pill-skip { background: var(--skip-bg); color: var(--skip); }

/* rango de fuente */
.rank {
  display: inline-block; font-size: 0.74rem; border: 1px solid var(--border); border-radius: 4px;
  padding: 0 0.4rem; color: var(--muted); white-space: nowrap; background: var(--surface);
}
.rank-1 { border-color: var(--accent); color: var(--accent); font-weight: 700; background: var(--accent-soft); }
.rank-2 { border-color: var(--accent); color: var(--accent); }
.rank-3 { color: var(--muted); }

/* tablas */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th, td { padding: 0.42rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th {
  background: var(--surface-2); color: var(--muted); font-weight: 600;
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* formularios */
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.86rem; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 5px; padding: 0.42rem 0.55rem; width: 100%; max-width: 100%;
}
textarea { resize: vertical; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem; align-items: end; }
.filter-actions { display: flex; gap: 0.5rem; align-items: center; }

/* botones */
.btn {
  display: inline-block; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: 5px; padding: 0.42rem 0.9rem; font: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; }
.btn-sm { padding: 0.2rem 0.55rem; font-size: 0.8rem; }

/* mensajes */
.error {
  background: var(--fail-bg); color: var(--fail); border: 1px solid var(--fail);
  border-radius: 6px; padding: 0.55rem 0.75rem; margin: 0 0 0.9rem; font-size: 0.92rem;
}
.notice {
  background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok);
  border-radius: 6px; padding: 0.55rem 0.75rem; margin: 0 0 0.9rem; font-size: 0.92rem;
}
.flash {
  background: var(--accent-soft); color: var(--accent); border-radius: 6px;
  padding: 0.5rem 0.75rem; margin: 0 0 0.9rem; font-size: 0.9rem;
}
.warn-list { color: var(--warn); }
.warn-list li { color: var(--text); }
.pending progress { width: 100%; }

/* pregunta y markdown */
.question {
  margin: 0.4rem 0 1rem; padding: 0.55rem 0.9rem; border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 0 6px 6px 0; font-size: 1rem;
}
blockquote {
  margin: 0.5rem 0; padding: 0.35rem 0.8rem; border-left: 3px solid var(--accent);
  color: var(--muted); background: var(--surface-2); border-radius: 0 4px 4px 0; font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.md { overflow-wrap: anywhere; }
.md pre { max-width: 100%; overflow: auto; }
.md ul, .md ol { padding-left: 1.3rem; }

/* citas */
.desk-card h2 { margin-bottom: 0; }
.desk-card .summary { margin-top: 0.5rem; }
details.cit {
  border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.6rem; margin: 0.4rem 0;
  background: var(--surface);
}
details.cit summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.9rem; }
details.cit summary::marker { color: var(--muted); }
.cit-title { font-weight: 550; overflow-wrap: anywhere; }
details.cit .facts { margin: 0.5rem 0; }
details.cit blockquote { font-size: 0.88rem; }

/* diff */
.diff {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.4; background: var(--surface-2);
  padding: 0.5rem 0.6rem; margin: 0.4rem 0 0; overflow: auto; max-height: 30rem;
  white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 6px; color: var(--text);
}
.diff span { display: block; }
.diff .add { background: var(--ok-bg); color: var(--ok); }
.diff .del { background: var(--fail-bg); color: var(--fail); }
.diff .hunk { color: var(--accent); }
.diff .meta { color: var(--muted); }
.alert-item { border-top: 1px solid var(--border); padding: 0.6rem 0; }
.alert-item:first-of-type { border-top: 0; }

/* navegación secundaria y paginación */
.tabs { display: flex; gap: 0.4rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.tabs a {
  padding: 0.25rem 0.7rem; border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; color: var(--muted); font-size: 0.88rem; background: var(--surface);
}
.tabs a.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 0.6rem 0; }

/* responsive: 375px sin scroll horizontal de página */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav {
    border-right: 0; border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.9rem; padding: 0.5rem 16px;
  }
  .nav h3 { display: none; }
  .nav a { padding: 0.25rem 0.4rem; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 0.9rem 16px 1.5rem; }
}

@media (max-width: 480px) {
  .topbar { padding: 0.5rem 16px; }
  .who-name { display: none; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
  .facts dt { margin-top: 0.4rem; font-size: 0.8rem; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 0.75rem; }
  .kpi-value { font-size: 1.3rem; }
  .clip { max-width: 70vw; }
  .banner { font-size: 0.7rem; padding: 0.35rem 16px; }
  th, td { padding: 0.35rem 0.45rem; }
}

/* ===== v2: iconos, ayuda, verificación, administración ===================================== */

:root { --radius: 8px; --gap: 1rem; }
.icon { width: 1.05em; height: 1.05em; flex: 0 0 auto; vertical-align: -0.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 2.2rem; height: 2.2rem; color: var(--muted); margin-bottom: 0.4rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-text); padding: 0.4rem 0.7rem; z-index: 10; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* cabecera */
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text); font-size: 1rem; }
.brand img { display: block; }
.brand span { font-weight: 700; color: var(--accent); letter-spacing: 0.02em; }
.who-id { display: inline-flex; align-items: center; gap: 0.4rem; }
.btn .icon { margin-right: 0.3rem; vertical-align: -0.2em; }
.btn-sm .icon { width: 0.95em; height: 0.95em; }
.help-link { display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; margin-left: 0.3rem; border-radius: 999px; }
.help-link:hover { color: var(--accent); }
.help-link .icon { width: 1.1em; height: 1.1em; }

/* navegación con iconos */
.nav a { display: flex; align-items: center; gap: 0.5rem; }
.nav a .icon { color: var(--muted); }
.nav a.active .icon { color: var(--accent); }
.nav a span { min-width: 0; }

/* migas de pan */
.crumbs { font-size: 0.82rem; color: var(--muted); margin: 0 0 0.4rem; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.crumbs li + li::before { content: "/"; margin-right: 0.35rem; color: var(--border); }
.crumbs a { color: var(--muted); }
.crumbs [aria-current] { color: var(--text); }

/* tipografía y espaciado */
h1 { font-size: 1.45rem; margin: 0.1rem 0 0.4rem; letter-spacing: -0.01em; }
.content > p.muted { max-width: 70ch; }
.card h3 { margin-top: 0.8rem; }
.card > :first-child { margin-top: 0; }
.card ul, .card ol { padding-left: 1.2rem; margin: 0.3rem 0 0.6rem; }
.card li { margin: 0.2rem 0; }
.card h2 .icon { margin-right: 0.35rem; }
.desk-title { display: inline-flex; align-items: center; gap: 0.45rem; margin: 0; }
.desk-title .icon { width: 1.25rem; height: 1.25rem; color: var(--accent); }

/* estados vacíos con guía */
.empty { text-align: center; padding: 1.2rem 0.8rem; color: var(--text); }
.empty p { margin: 0.3rem 0; }
.empty .icon-lg { display: inline-block; }
td .empty { padding: 0.8rem; }

/* ayuda: tabla de contenidos, comparación y glosario */
.toc { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; font-size: 0.92rem; }
.toc a { text-decoration: none; padding: 0.2rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--text); }
.toc a:hover { color: var(--accent); }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.8rem; margin-top: 0.6rem; }
.compare > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.8rem; }
.compare h3 { margin-top: 0; }
.bad { color: var(--fail); }
.good { color: var(--ok); }
.examples-list { font-size: 0.9rem; }
.examples summary { cursor: pointer; font-weight: 600; }
.glossary dt { font-weight: 650; color: var(--text); }
.glossary dd { margin-bottom: 0.35rem; }
.facts dt .pill, .facts dt .rank { font-size: 0.8rem; }
details summary { cursor: pointer; }

/* verificación */
.unverified {
  background: var(--fail-bg); color: var(--fail); border: 1px solid var(--fail); border-left-width: 5px;
  border-radius: 6px; padding: 0.55rem 0.75rem; margin: 0.5rem 0 0.8rem; font-size: 0.92rem;
}
.unverified ul { color: var(--text); margin: 0.3rem 0 0; }
.verify { border-top: 1px solid var(--border); margin-top: 0.9rem; padding-top: 0.5rem; }
.verify h3 { margin-bottom: 0.3rem; color: var(--text); }
.checks { list-style: none; padding: 0; margin: 0.3rem 0; }
.checks li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.checks li:last-child { border-bottom: 0; }
.check-ok { color: var(--ok); font-weight: 700; display: inline-block; width: 1.2em; }
.check-fail { color: var(--fail); font-weight: 700; display: inline-block; width: 1.2em; }
table.claims td { font-size: 0.85rem; }
.verified-md { border-left: 4px solid var(--ok); padding-left: 0.7rem; }
.claim-list { list-style: none; padding: 0; margin: 0.3rem 0 0.6rem; }
.claim-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; align-items: baseline; }
.claim-list li:last-child { border-bottom: 0; }
.claim-text { flex: 1 1 14rem; overflow-wrap: anywhere; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { font-family: var(--mono); font-size: 0.78rem; border: 1px solid var(--border); border-radius: 999px; padding: 0.05rem 0.5rem; background: var(--surface-2); color: var(--link); text-decoration: none; }
.chip:hover { border-color: var(--accent); }
.chip-off { color: var(--muted); cursor: help; }
details.withdrawn { border: 1px dashed var(--fail); border-radius: 6px; padding: 0.4rem 0.6rem; margin: 0.6rem 0; }
details.withdrawn summary { color: var(--fail); font-weight: 550; }
details.withdrawn s { color: var(--muted); }
details.draft { border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.6rem; margin: 0.6rem 0; background: var(--surface-2); }
details.draft summary { color: var(--muted); font-weight: 550; }

/* avisos de administración */
.notice-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); border-radius: 6px; padding: 0.55rem 0.75rem; margin: 0.5rem 0 0.9rem; font-size: 0.92rem; }
.notice-temp { border-color: var(--warn); background: var(--warn-bg); }
.notice-temp h2 { color: var(--warn); }
.temp-pass { font-size: 1.1rem; letter-spacing: 0.03em; user-select: all; }
.actions .inline { margin-right: 0.25rem; }
.role-form { display: inline-flex; gap: 0.3rem; align-items: center; }
.role-form select { width: auto; font-size: 0.85rem; padding: 0.2rem 0.4rem; }
.login-brand { display: flex; align-items: center; gap: 0.6rem; }
.login-brand h1 { margin: 0; }

/* píldoras y tooltips: cursor de ayuda */
.pill[title], .rank[title] { cursor: help; }

/* responsive 375px */
@media (max-width: 480px) {
  .who { gap: 0.3rem; }
  .who-id .pill { display: none; }
  .brand span { display: none; }
  .nav a { font-size: 0.88rem; }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .actions form { margin-bottom: 0.3rem; }
  .content h1 { font-size: 1.25rem; }
}
