/* Research dashboard. Mobile-first, sin dependencias. Tokens de color por rol (claro/oscuro). */
:root {
  color-scheme: light;
  --surface-0: #f5f5f3;
  --surface-1: #fcfcfb;
  --border: #e3e2de;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6b6a66;
  --link: #1c5cab;
  --series-1: #2a78d6;
  --series-1-soft: #86b6ef;
  --grid: #e8e7e3;
  --good: #0a7d0a;
  --warning-bg: #fff4d6;
  --warning-border: #e3a008;
  --pending: #8a5a00;
  --chip-bg: #efeee9;
  --badge-xbrl: #1c5cab;
  --badge-pr: #8a4b00;
  --badge-derived: #52514e;
  --badge-missing: #b02a2a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9d9c94;
    --link: #86b6ef;
    --series-1: #3987e5;
    --series-1-soft: #1c5cab;
    --grid: #2b2b28;
    --good: #4cc44c;
    --warning-bg: #3a2f10;
    --warning-border: #c98500;
    --pending: #f0b84a;
    --chip-bg: #2a2a27;
    --badge-xbrl: #86b6ef;
    --badge-pr: #f0a35e;
    --badge-derived: #c3c2b7;
    --badge-missing: #f08a8a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --border: #33332f;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9d9c94; --link: #86b6ef;
  --series-1: #3987e5; --series-1-soft: #1c5cab; --grid: #2b2b28; --good: #4cc44c;
  --warning-bg: #3a2f10; --warning-border: #c98500; --pending: #f0b84a; --chip-bg: #2a2a27;
  --badge-xbrl: #86b6ef; --badge-pr: #f0a35e; --badge-derived: #c3c2b7; --badge-missing: #f08a8a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0.2em 0; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.4em 0 0.6em; }
h3 { font-size: 0.95rem; margin: 0 0 0.3em; font-weight: 600; color: var(--text-secondary); }
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 32px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; color: var(--text-primary); }
.tickers { display: flex; gap: 4px; flex-wrap: wrap; }
.tickers a { padding: 4px 10px; border-radius: 999px; color: var(--text-secondary); font-weight: 600; font-size: 0.9rem; }
.tickers a[aria-current="page"] { background: var(--chip-bg); color: var(--text-primary); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-width: 0; }
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .kpi-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } .index-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.ticker { font-weight: 700; font-size: 0.8em; padding: 2px 8px; border-radius: 6px; background: var(--chip-bg); color: var(--text-secondary); vertical-align: middle; }
.chip { display: inline-block; font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; background: var(--chip-bg); color: var(--text-secondary); white-space: nowrap; }
.chip.ok { color: var(--good); }
.chip.pending { color: var(--pending); }
.chip.warn { color: var(--pending); }
.chip.cat { font-size: 0.72rem; }

/* índice */
.company-card { display: flex; flex-direction: column; gap: 6px; color: var(--text-primary); }
.company-card:hover { text-decoration: none; border-color: var(--series-1); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.company-card .name { font-weight: 600; }
.metric { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.metric .value { font-size: 1.25rem; font-weight: 700; }
.delta { color: var(--text-secondary); font-size: 0.9rem; }
.headline { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.news-line { margin: 0; color: var(--text-secondary); overflow-wrap: anywhere; }

/* empresa */
.hero-head p { margin: 0 0 12px; }
.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.summary-head h2 { margin: 0; }
.summary-list { margin: 10px 0 4px; padding-left: 1.1em; }
.summary-list li { margin: 4px 0; overflow-wrap: anywhere; }
.src { font-size: 0.75rem; margin-left: 2px; vertical-align: super; }
details summary { cursor: pointer; color: var(--text-secondary); }
.alert { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: var(--warning-bg); border: 1px solid var(--warning-border); }

.kpi-card h3 { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.defby { font-size: 0.7rem; font-weight: 500; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.kpi-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.kpi-value a { color: var(--text-primary); }
.kpi-deltas { display: flex; gap: 10px; flex-wrap: wrap; color: var(--text-secondary); min-height: 1.3em; }
.kpi-badges { margin: 4px 0 6px; min-height: 1.4em; }
.badge { display: inline-block; font-size: 0.68rem; font-weight: 600; padding: 0 6px; border-radius: 4px; border: 1px solid currentColor; margin-right: 4px; }
.badge.xbrl { color: var(--badge-xbrl); }
.badge.pr { color: var(--badge-pr); }
.badge.derived, .badge.nongaap, .badge.restated { color: var(--badge-derived); }
.badge.missing { color: var(--badge-missing); }
.chart-box { position: relative; height: 150px; }

.table-details { margin-top: 14px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); margin-top: 8px; }
table { border-collapse: collapse; width: 100%; }
.kpi-table th, .kpi-table td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; font-size: 0.82rem; }
.kpi-table th[scope="row"] { text-align: left; position: sticky; left: 0; background: var(--surface-1); font-weight: 600; }
.kpi-table thead th { position: sticky; top: 0; background: var(--surface-1); font-weight: 600; }
.kpi-table td.missing { color: var(--badge-missing); }
.mark { font-size: 0.65rem; margin-left: 1px; color: var(--text-muted); }
.mark.pr { color: var(--badge-pr); }

.two-col { display: grid; gap: 0 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); } }
.list-table th, .list-table td { padding: 5px 6px; border-bottom: 1px solid var(--grid); text-align: left; font-size: 0.85rem; }
.list-table td:last-child { overflow-wrap: anywhere; }
.release { margin-top: 12px; }
.release ul { margin: 6px 0 0; padding-left: 1.1em; }
.news { list-style: none; margin: 0; padding: 0; }
.news li { padding: 8px 0; border-bottom: 1px solid var(--grid); overflow-wrap: anywhere; }
.news li p { margin: 4px 0 0; color: var(--text-secondary); }
.news.compact li { padding: 6px 0; }
.defs dt { font-weight: 600; margin-top: 8px; }
.defs dd { margin: 2px 0 0; color: var(--text-secondary); }
.footer { max-width: 1180px; margin: 0 auto; padding: 16px; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }
