/* Public Sans (SIL OFL 1.1, see ../fonts/OFL-public-sans.txt), the same type as RTB, served from our own domain because the CSP only allows 'self'. */
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/public-sans-latin-400-normal.60715978fab2.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/public-sans-latin-600-normal.6b1fe1f62892.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/public-sans-latin-700-normal.3c0eda7c2982.woff2") format("woff2"); }

/* RTB look: warm paper and terracotta in light, black and gold in dark; the header ("chrome") stays dark in both.
   Light theme by default, dark when the system asks for it or the visitor picks it (data-theme on <html>, set by theme.js). */
:root {
  color-scheme: light;
  --bg: #f4f0eb; --surface: #fffdfa; --surface-2: #faf6f1; --line: #e2d6cc; --line-row: #ece3da; --line-strong: #d2c3b6; --input-border: #9e8675;
  --text: #2b2420; --muted: #6c5c51; --eyebrow: #8a5a35;
  --accent: #a65a31; --link: #864727; --accent-hover: #6b3519; --accent-soft: #f1e6dc; --accent-border: #d9b99f; --on-accent: #ffffff;
  --button: #211d18; --button-text: #f4f3f1; --button-hover: #3a332c; --button-secondary-border: #b8a597;
  --good: #2f5a2a; --good-soft: #e5efe2; --bad: #a52929; --bad-soft: #fbe5e2; --warn: #634321; --warn-soft: #faebd6; --warn-border: #d9a441;
  --chrome: #171615; --chrome-surface: #211e1c; --chrome-border: #3c3833; --chrome-text: #f4f3f1; --chrome-muted: #bcb6b0;
  --gold: #c9a26b; --gold-hover: #d8b47f; --on-gold: #17130e;
  --radius: 2px; --radius-sm: 2px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141414; --surface: #1a1918; --surface-2: #171615; --line: #2f2c29; --line-row: #262422; --line-strong: #3c3833; --input-border: #5a514a;
    --text: #f4f3f1; --muted: #b9b3ad; --eyebrow: #ac8859;
    --accent: #c9a26b; --link: #e0c08f; --accent-hover: #f5dcb3; --accent-soft: #2a2520; --accent-border: #4a3d2c; --on-accent: #17130e;
    --button: #c9a26b; --button-text: #17130e; --button-hover: #d8b47f; --button-secondary-border: #4a443e;
    --good: #a8d4a3; --good-soft: #1f2b1f; --bad: #ffb8b1; --bad-soft: #3a1c1a; --warn: #f2c98e; --warn-soft: #3a2c1a; --warn-border: #d9a441;
    --chrome: #0f0f0f; --chrome-surface: #1a1918;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141414; --surface: #1a1918; --surface-2: #171615; --line: #2f2c29; --line-row: #262422; --line-strong: #3c3833; --input-border: #5a514a;
  --text: #f4f3f1; --muted: #b9b3ad; --eyebrow: #ac8859;
  --accent: #c9a26b; --link: #e0c08f; --accent-hover: #f5dcb3; --accent-soft: #2a2520; --accent-border: #4a3d2c; --on-accent: #17130e;
  --button: #c9a26b; --button-text: #17130e; --button-hover: #d8b47f; --button-secondary-border: #4a443e;
  --good: #a8d4a3; --good-soft: #1f2b1f; --bad: #ffb8b1; --bad-soft: #3a1c1a; --warn: #f2c98e; --warn-soft: #3a2c1a; --warn-border: #d9a441;
  --chrome: #0f0f0f; --chrome-surface: #1a1918;
}

/* Base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 16px/1.55 "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
h1, h2, h3 { line-height: 1.1; font-weight: 700; text-wrap: balance; }
h1 { letter-spacing: -.035em; }
h2 { font-size: 1.5rem; letter-spacing: -.02em; margin: 64px 0 16px; }
h3 { letter-spacing: -.01em; }
h2 a, h3 a { color: inherit; }
img { max-width: 100%; height: auto; }
small { font-size: .875em; }
.muted { color: var(--muted); font-size: 15px; }
td, time, .big, .n, .figure { font-variant-numeric: tabular-nums; }

/* Keyboard and screen-reader helpers */
.skip-link { position: absolute; left: 16px; top: -100px; z-index: 100; padding: 12px 18px; background: var(--button); color: var(--button-text); font-weight: 700; }
.skip-link:focus { top: 16px; color: var(--button-text); text-decoration: none; }
main:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
a, button, summary, label, select { touch-action: manipulation; }

/* Shell: the dark sidebar holds the sections and the account; the page scrolls beside it */
.env-banner { background: var(--warn-soft); color: var(--warn); text-align: center; padding: 6px 16px; font-weight: 700; font-size: 13px; }
.shell { flex: 1; display: flex; align-items: stretch; background: linear-gradient(to right, var(--chrome) 240px, transparent 240px); }
.page { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar { position: sticky; top: 0; align-self: flex-start; flex: none; width: 240px; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--chrome); color: var(--chrome-text); }
.brand { display: block; padding: 28px 24px 20px; color: var(--chrome-text); font-weight: 700; font-size: 22px; letter-spacing: -.02em; }
.brand:hover { color: var(--gold); text-decoration: none; }
.side-nav { display: flex; flex-direction: column; padding: 8px 0; }
.side-nav a { display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 24px; border-left: 3px solid transparent;
  color: var(--chrome-muted); font-weight: 600; font-size: 15px; white-space: nowrap; transition: color .15s ease, background-color .15s ease; }
.side-nav a svg { flex: none; transition: transform .2s ease; }
.side-nav a:hover { background: var(--chrome-surface); color: var(--chrome-text); text-decoration: none; }
.side-nav a:hover svg { transform: translateX(2px); }
.side-nav a[aria-current] { background: var(--chrome-surface); color: var(--chrome-text); border-left-color: var(--gold); }
.side-nav a[aria-current] svg { color: var(--gold); }
.sidebar .account { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 20px 24px 28px; background: var(--chrome-surface); }
.account a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; color: var(--chrome-muted); font-weight: 600; font-size: 14px; }
.account a:hover, .account a[aria-current] { color: var(--chrome-text); text-decoration: none; }
.account a.button { padding: 0 14px; color: var(--on-gold); background: var(--gold); border-color: var(--gold); }
.account a.button:hover { background: var(--gold-hover); border-color: var(--gold-hover); color: var(--on-gold); }
.account form { margin: 0; }
.account button.link { min-height: 40px; padding: 0 8px; color: var(--chrome-muted); font-size: 14px; }
.account button.link:hover { color: var(--chrome-text); }
.theme-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; min-height: 0; padding: 0; background: var(--chrome); color: var(--chrome-muted); border: 0; }
.theme-toggle:hover { background: var(--chrome); color: var(--gold); }
.theme-toggle .moon, :root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}
@media (max-width: 900px) {
  .shell { flex-direction: column; background: none; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 16px; font-size: 20px; }
  .sidebar .account { order: 2; margin: 0 0 0 auto; padding: 0 8px; background: none; flex-wrap: nowrap; }
  .side-nav { order: 3; width: 100%; flex-direction: row; padding: 0 32px 0 8px; overflow-x: auto; scrollbar-width: none; background: var(--chrome-surface);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
  .side-nav a { min-height: 46px; padding: 0 12px; gap: 8px; border-left: 0; font-size: 14px; }
  .side-nav a[aria-current] { box-shadow: inset 0 -3px 0 var(--gold); }
  .side-nav a svg { display: none; }
}

/* Layout */
main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 56px clamp(16px, 4vw, 56px) 96px; }
.hero { margin: 0 0 40px; }
.hero h1 { font-size: clamp(2.25rem, 5vw, 3.75rem); margin: 0 0 16px; }
.hero p { max-width: 60ch; font-size: 18px; margin: 0; }
.two-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 56px; }
.two-cols > section > h2:first-child { margin-top: 40px; }

/* Home: the best margin right now is the opening figure */
.lead { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 40px 64px; align-items: center; }
.lead-text { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 24px 0; }
.lead h1 { font-size: clamp(2.75rem, 6.4vw, 5.75rem); line-height: .98; margin: 0 0 32px; max-width: 12ch; }
.lead-text > p { font-size: 19px; max-width: 34ch; margin: 0 0 32px; }
.lead-text > .status-line { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 32px 0 0; color: var(--muted); font-size: 15px; }
.status-line > span { white-space: nowrap; }
.market-now { background: var(--chrome); color: var(--chrome-text); padding: 36px 36px 28px; }
:root[data-theme="dark"] .market-now { background: var(--accent-soft); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .market-now { background: var(--accent-soft); } }
.market-now h2 { margin: 0 0 8px; font-size: 1rem; letter-spacing: 0; color: var(--chrome-muted); font-weight: 600; }
.market-now a { color: var(--gold); }
.market-now a:hover { color: var(--gold-hover); }
.figure { margin: 0; font-size: clamp(3.5rem, 6vw, 5.5rem); line-height: 1; font-weight: 700; letter-spacing: -.04em; }
.figure a { color: var(--gold); }
.figure span { display: block; margin-top: 10px; font-size: 15px; letter-spacing: 0; font-weight: 600; color: var(--chrome-muted); }
.figure-note { margin: 20px 0 24px; color: var(--chrome-text); max-width: 42ch; }
.market-now table.data { margin: 0 0 20px; font-size: 15px; }
.market-now table.data caption { text-align: left; padding: 0 0 6px; color: var(--chrome-muted); font-size: 14px; font-weight: 600; }
.market-now table.data td { padding: 10px 12px 10px 0; border-bottom-color: var(--chrome-border); color: var(--chrome-muted); }
.market-now table.data td:first-child a { color: var(--chrome-text); font-weight: 600; }
.market-now table.data td.n.good { color: var(--gold); padding-right: 0; }
.market-now table.data tbody tr:hover td { background: transparent; }
.tools h2, .news h2 { margin-top: 120px; font-size: clamp(1.75rem, 3vw, 2.5rem); }
.tools ul { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 4px; }
.tools li { display: flex; flex-direction: column; gap: 6px; padding: 28px 28px 32px; background: var(--surface); transition: background-color .15s ease; }
.tools li:hover { background: var(--accent-soft); }
.tools li a { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.tools li a::after { content: " →"; color: var(--accent); display: inline-block; transition: transform .2s ease; }
.tools li:hover a::after { transform: translateX(4px); }
.tools li span { color: var(--muted); }
.news-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 32px 56px; margin-top: 32px; }
.news-lead img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); display: block; margin-bottom: 20px; }
.news-lead h3 { font-size: clamp(1.4rem, 2.4vw, 2rem); margin: 0 0 12px; }
.news-lead p { margin: 0 0 10px; max-width: 62ch; }
.news-grid .post { grid-template-columns: 120px 1fr; }
.news-grid .post:first-child { padding-top: 0; }

/* Figures (version, servers, totals): tone steps instead of boxes */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 4px; margin: 32px 0; }
.cards article, .panel { background: var(--surface); padding: 28px; }
.cards h2 { margin: 0 0 10px; font-size: 15px; letter-spacing: 0; font-weight: 600; color: var(--muted); }
.cards p { margin: 0 0 8px; }
.cards p:last-child { margin-bottom: 0; }
.big { font-size: clamp(2rem, 3.4vw, 2.75rem); line-height: 1.05; font-weight: 700; letter-spacing: -.03em; margin: 0; color: var(--text); }
.cards p.big { margin-bottom: 10px; }
.big.good { color: var(--good); }
.big.bad { color: var(--bad); }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--muted); vertical-align: 1px; }
.dot.good { background: #7fae7a; }
.dot.bad { background: #d9665e; }
.flag { color: var(--warn); font-weight: 700; }
.flag.bad { color: var(--bad); }

/* Forms */
.panel { max-width: 480px; margin: 0 auto; padding: 36px; }
.panel h1 { margin-top: 0; font-size: 2.25rem; }
.panel.wide { max-width: none; margin: 0 0 24px; }
.field { display: grid; gap: 6px; margin-bottom: 18px; align-content: start; }
.field label { font-weight: 600; font-size: 14px; }
.field small { color: var(--muted); }
.field.check { display: flex; gap: 10px; align-items: center; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 0 20px; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--input-border); background: var(--bg); color: var(--text); font: inherit; accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; }
select { width: auto; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 22px; border: 1px solid var(--button); border-radius: var(--radius-sm);
  background: var(--button); color: var(--button-text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, transform .1s ease; }
button:hover, .button:hover { background: var(--button-hover); border-color: var(--button-hover); color: var(--button-text); text-decoration: none; }
button:active, .button:active { transform: scale(.98); }
.button.secondary { background: transparent; color: var(--text); border-color: var(--button-secondary-border); font-weight: 600; }
.button.secondary:hover { background: var(--accent-soft); color: var(--text); }
button.link { min-height: 0; background: none; border: 0; color: var(--link); padding: 0; font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }
button.danger { background: transparent; color: var(--bad); border-color: currentColor; }
button.danger:hover { background: var(--bad-soft); color: var(--bad); border-color: currentColor; }
.danger-zone { margin-top: 32px; padding-top: 24px; }
.errorlist { color: var(--bad); margin: 0; padding-left: 18px; font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin: 24px 0 4px; padding: 16px 20px; background: var(--surface); }
.filters label { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 15px; }
.filters input[type=search] { width: 220px; }
.message { background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); padding: 14px 18px; margin: 0 0 24px; font-weight: 600; }
.message.success { background: var(--good-soft); border-left-color: #7fae7a; }
.message.error { background: var(--bad-soft); border-left-color: #d9665e; }

/* Tables: real data keeps its row lines */
.table-scroll { overflow-x: auto; margin: 4px 0 20px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
.table-scroll table.data { margin: 0; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
table.data th, table.data td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line-row); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--accent-soft); }
table.data tr.stale td:first-child::after { content: ' · sin actualizar'; color: var(--warn); }
table.data .n, span.n { text-align: right; white-space: nowrap; }
table.data td.n.good, table.data td.n.bad { font-weight: 700; }
.good { color: var(--good); }
.bad { color: var(--bad); }
ul.plain { list-style: none; padding: 0; margin: 8px 0 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line-row); }
ul.plain li:last-child { border-bottom: 0; }
.cards ul.plain li { padding: 3px 0; border: 0; color: var(--muted); font-size: 15px; }

/* Collapsible panels (refineries, roadmap) */
.panel-details { background: var(--surface); padding: 0 20px; margin: 4px 0; }
.panel-details summary { cursor: pointer; padding: 16px 0; font-weight: 600; }
.panel-details summary::marker { color: var(--accent); }
.panel-details[open] { padding-bottom: 12px; }
.panel-details .table-scroll { background: var(--bg); }

/* Section tabs: words with an underline on the current one */
.subnav, .chips { display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 0 0 8px; }
.chips { gap: 4px 20px; margin: 16px 0 8px; }
.subnav a, .chips a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-weight: 600; font-size: 17px; }
.chips a { font-size: 15px; }
.subnav a:hover, .chips a:hover { color: var(--text); text-decoration: none; }
.subnav a[aria-current], .chips a[aria-current] { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); }

/* News and roadmap */
.post { display: grid; grid-template-columns: 160px 1fr; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line-row); }
.post:last-of-type { border-bottom: 0; }
.post img, .roadmap-cards img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); display: block; }
.post h3, .roadmap-cards h3, .news-lead h3 { overflow-wrap: anywhere; }
.post h3, .roadmap-cards h3 { margin: 0 0 6px; font-size: 1.1rem; line-height: 1.25; }
.post p { margin: 0 0 6px; }
.roadmap-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 4px; margin: 16px 0 24px; }
.roadmap-cards article { background: var(--surface); padding: 12px 12px 16px; }
.roadmap-cards p { margin: 0 0 6px; font-size: 15px; }
.events li { padding: 10px 0; }
.pager { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; margin: 32px 0; }

/* Footer: the name returns as the close */
footer { color: var(--chrome-muted); font-size: 14px; padding: 56px clamp(16px, 4vw, 56px) 40px; background: var(--chrome); }
footer a { display: inline-block; padding: 4px 0; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
footer a:hover { color: var(--gold-hover); }

/* Profit chart (loops/charts.py): one series, so no legend; values live in the tables below it */
.chart { margin: 0 0 40px; padding: 20px 20px 12px; background: var(--surface); border: 1px solid var(--line); }
.chart figcaption { margin-bottom: 12px; font-weight: 600; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line-row); stroke-width: 1; }
.chart .grid.zero { stroke: var(--line-strong); }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .pt:hover .dot { r: 6; }
@media (max-width: 600px) {
  .chart { padding: 16px 12px 8px; }
  .chart .tick { font-size: 26px; }
  .chart .dot { r: 7; stroke-width: 3; }
  .chart .pt:hover .dot { r: 10; }
}

/* Entrance: each block of the page rises in once; nothing stays hidden without animation support */
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
main > *, .lead-text > *, .market-now > *, .tools li { animation: rise .35s cubic-bezier(.2, .7, .2, 1) both; }
main > :nth-child(2), .lead-text > :nth-child(2), .market-now > :nth-child(2), .tools li:nth-child(2) { animation-delay: .04s; }
main > :nth-child(3), .lead-text > :nth-child(3), .market-now > :nth-child(3), .tools li:nth-child(3) { animation-delay: .08s; }
main > :nth-child(4), .lead-text > :nth-child(4), .market-now > :nth-child(4), .tools li:nth-child(4) { animation-delay: .12s; }
main > :nth-child(n+5), .lead-text > :nth-child(n+5), .market-now > :nth-child(n+5), .tools li:nth-child(n+5) { animation-delay: .16s; }

@media (max-width: 900px) {
  .lead, .news-grid { grid-template-columns: 1fr; }
  .lead-text { padding: 0; }
  .tools h2, .news h2 { margin-top: 80px; }
}
@media (max-width: 520px) {
  main { padding-top: 32px; padding-bottom: 64px; }
  .post, .news-grid .post { grid-template-columns: 1fr; gap: 12px; }
  .market-now { padding: 28px 20px 20px; }
  .tools li { padding: 22px 20px 24px; }
  .panel { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
