/* Pump Forecast v3 — tokens and layout from the design handoff (__junk/petrol.zip) */

:root, [data-theme="light"] {
  --bg: #f2f1ed; --card: #faf9f6; --sel: #ffffff; --ink: #15213b; --muted: #6c7080; --line: #e5e2db;
  --chip: #ebe8e1; --chip2: #d9d5cb; --blue: #2f5bd8; --bluesoft: rgba(47, 91, 216, 0.12);
  --green: #2e9e5b; --greensoft: #e2f1e6; --red: oklch(0.56 0.17 25); --nav: #15213b; --navink: #c9cfdc;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1420; --card: #161c2a; --sel: #1c2436; --ink: #e8eaf0; --muted: #9aa1b2; --line: #273044;
  --chip: #232b3d; --chip2: #323c52; --blue: #6f8fff; --bluesoft: rgba(111, 143, 255, 0.16);
  --green: #4cc27e; --greensoft: rgba(76, 194, 126, 0.14); --red: oklch(0.70 0.15 25); --nav: #0a0e17; --navink: #9aa1b2;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: "Geist", system-ui, sans-serif; font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.mono, .eyebrow, .chart__y, .chart__x { font-family: "Geist Mono", ui-monospace, monospace; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h2 { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.small-14 { font-size: 14px; color: var(--muted); }
@keyframes pfspin { to { transform: rotate(360deg); } }

/* top bar */
.topbar { background: var(--nav); }
.topbar__inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.wordmark { display: flex; flex-direction: column; line-height: 1; gap: 4px; }
.wordmark__name { font-weight: 700; font-size: 18px; letter-spacing: .04em; color: #fff; }
.wordmark__sub { font-family: "Geist Mono", monospace; font-size: 10px; letter-spacing: .3em; color: var(--navink); }
.theme-toggle { height: 36px; padding: 0 14px; border-radius: 8px; border: none; background: rgba(255,255,255,.08); color: #fff; font-size: 13px; cursor: pointer; white-space: nowrap; }
.theme-toggle:hover { background: rgba(255,255,255,.14); }

.page { max-width: 1160px; margin: 0 auto; padding: 24px 20px 64px; display: flex; flex-direction: column; gap: 20px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar__left { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.month-pill { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.month-pill__initial { width: 28px; height: 28px; border-radius: 7px; background: var(--ink); color: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.month-pill__label { font-weight: 600; font-size: 17px; white-space: nowrap; }
.status { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; background: var(--chip); color: var(--muted); font-size: 14px; white-space: nowrap; }
.status.is-live { background: var(--greensoft); color: var(--green); }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.is-loading .status__dot { width: 10px; height: 10px; background: none; border: 2px solid currentColor; border-right-color: transparent; animation: pfspin .8s linear infinite; }
.btn { height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--sel); }
.btn:disabled { cursor: progress; opacity: .7; }
.error { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--red); font-size: 14px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 28px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card--flush { padding: 0; gap: 0; overflow: hidden; }
.card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
.card__title { font-weight: 600; font-size: 18px; }
.eyebrow { font-size: 12px; letter-spacing: .06em; color: var(--muted); }
.summary { gap: 12px; }
.summary__text { margin: 0; font-size: 17px; line-height: 1.6; max-width: 780px; text-wrap: pretty; }

/* grade cards */
.grade-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); border-bottom: 1px solid var(--line); }
.grade-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grade { position: relative; text-align: left; cursor: pointer; background: transparent; border: none; border-right: 1px solid var(--line); padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.grade:hover { background: color-mix(in srgb, var(--sel) 55%, transparent); }
.grade[aria-selected="true"] { background: var(--sel); }
.grade[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--blue); }
.grade__name { font-size: 15px; color: var(--muted); }
.grade__price { display: flex; align-items: baseline; gap: 6px; }
.grade__mid { font-size: 40px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
.grade__unit { font-size: 13px; color: var(--muted); }
.grade__range { font-family: "Geist Mono", monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.grade__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip { padding: 3px 8px; border-radius: 6px; background: var(--chip); font-family: "Geist Mono", monospace; font-size: 12px; white-space: nowrap; color: var(--muted); }
.up { color: var(--red); }
.down { color: var(--green); }
.spark { width: 45%; max-width: 130px; height: 30px; overflow: visible; }
.spark path { fill: none; stroke: var(--muted); stroke-width: 1.75; vector-effect: non-scaling-stroke; }
.grade[aria-selected="true"] .spark path { stroke: var(--blue); }
@media (max-width: 420px) {
  .grade { padding: 16px 14px 18px; }
  .grade__mid { font-size: 32px; }
  .grade__foot { flex-wrap: wrap; }
  .spark { width: 100%; max-width: none; }
}

/* chart */
.chart-wrap { padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; font-size: 14px; color: var(--muted); }
.legend > span { display: flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 18px; }
.key--line { height: 3px; border-radius: 2px; background: var(--blue); }
.key--band { height: 10px; border-radius: 2px; background: var(--bluesoft); }
.key--dotted { border-top: 2px dotted var(--muted); }
.chart { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 10px; }
.chart__y { position: relative; height: 280px; font-size: 12px; color: var(--muted); }
.chart__y span { position: absolute; right: 0; transform: translateY(-50%); }
.chart__main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chart__plot { position: relative; height: 280px; }
.chart__plot .gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.chart__plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart__official { position: absolute; right: 0; transform: translateY(-130%); font-family: "Geist Mono", monospace; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chart__dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--blue); border: 2.5px solid var(--blue); }
.chart__dot.is-backfilled { background: var(--card); }
.chart__hit { position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; cursor: default; }
.chart__last { position: absolute; transform: translate(-100%, -170%); padding: 5px 9px; border-radius: 7px; background: var(--ink); color: var(--bg); font-family: "Geist Mono", monospace; font-size: 12px; white-space: nowrap; pointer-events: none; }
.chart__x { position: relative; height: 18px; font-size: 12px; color: var(--muted); }
.chart__x span { position: absolute; white-space: nowrap; }
.chart__tip { position: absolute; z-index: 2; pointer-events: none; transform: translate(-50%, calc(-100% - 14px)); padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--bg); font-family: "Geist Mono", monospace; font-size: 12px; white-space: nowrap; }
@media (max-width: 520px) {
  .chart-wrap, .card { padding-left: 18px; padding-right: 18px; }
  .chart__x .opt { display: none; }
}

/* tiles (oil math + drivers) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.tile { background: var(--sel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tile__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tile__label { font-weight: 600; font-size: 16px; }
.tile__chip { height: 26px; min-width: 28px; padding: 0 8px; border-radius: 7px; background: var(--chip); color: var(--muted); display: flex; align-items: center; justify-content: center; font-family: "Geist Mono", monospace; font-size: 12px; white-space: nowrap; }
.tile__value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.tile__value--sm { font-size: 22px; line-height: 1.2; text-wrap: pretty; letter-spacing: 0; }
.tile__note { font-size: 14px; color: var(--muted); text-wrap: pretty; }
.bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar > div { height: 100%; background: var(--green); border-radius: 4px; }

.headlines { display: flex; flex-direction: column; }
.headlines a { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 11px 0; border-top: 1px solid var(--line); color: var(--ink); }
.headlines .t { font-size: 15px; text-wrap: pretty; }
.headlines .m { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* log + record */
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 20px; align-items: start; }
.pair .card { gap: 10px; }
.table { display: grid; gap: 0 18px; font-size: 15px; }
.table--log { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.table--record { grid-template-columns: minmax(0, 1fr) auto auto auto auto; gap: 0 16px; }
.table > span { padding: 10px 0; border-top: 1px solid var(--line); text-align: right; font-family: "Geist Mono", monospace; color: var(--muted); white-space: nowrap; }
.table > span.th { border-top: none; padding: 6px 0; font-family: "Geist", sans-serif; font-size: 13px; }
.table > span.first { text-align: left; font-family: "Geist", sans-serif; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.table > span.strong { color: var(--ink); font-weight: 500; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--chip); color: var(--muted); }
.stats { display: flex; flex-wrap: wrap; gap: 12px 40px; margin-bottom: 4px; }
.stats > div { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.stats__v { font-size: 26px; font-weight: 600; }
.stats__v--good { color: var(--green); }
.linkbtn { align-self: flex-start; border: none; background: none; padding: 0; font-size: 14px; color: var(--blue); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
@media (max-width: 400px) {
  .table { gap: 0 10px; font-size: 14px; }
  .table--record { gap: 0 10px; }
}

.footer { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); max-width: 820px; text-wrap: pretty; }

@media (prefers-reduced-motion: reduce) {
  .status.is-loading .status__dot { animation-duration: 2.4s; }
}
