/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f0e;
  --bg2: #141614;
  --bg3: #1c1f1c;
  --bg4: #232623;
  --border: rgba(255,255,255,0.07);
  --border-em: rgba(255,255,255,0.14);
  --text: #e8ebe8;
  --text2: #8a9488;
  --text3: #5a625a;
  --green: #4caf7d;
  --green-dim: rgba(76,175,125,0.12);
  --red: #e05252;
  --red-dim: rgba(224,82,82,0.10);
  --blue: #4a90d9;
  --blue-dim: rgba(74,144,217,0.10);
  --amber: #e8a23a;
  --amber-dim: rgba(232,162,58,0.12);
  --accent: #b8ff57;
  --accent-dim: rgba(184,255,87,0.10);
  --mono: 'DM Mono', monospace;
  --display: 'Syne', sans-serif;
  --radius: 6px;
  --radius-lg: 10px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-weight: 300;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Noise texture overlay ───────────────────────────── */
.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.6;
}
main, header, footer, section { position: relative; z-index: 1; }

/* ── Header ───────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky; top: 0;
  background: rgba(13,15,14,0.92);
  backdrop-filter: blur(12px);
  z-index: 100;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 0.75rem 0;
  gap: 12px; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 22px; }
.logo-title {
  font-family: var(--display);
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.logo-sub { font-size: 11px; color: var(--text3); letter-spacing: 0.04em; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ───────────────────────────────────────────── */
.btn-pill {
  font-family: var(--mono); font-size: 12px; font-weight: 400;
  padding: 6px 14px; border-radius: 100px;
  border: 1px solid var(--border-em);
  background: transparent; color: var(--text2);
  cursor: pointer; transition: all .15s; letter-spacing: 0.02em;
}
.btn-pill:hover { background: var(--bg3); color: var(--text); }
.btn-pill.accent { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.btn-pill.accent:hover { background: var(--accent); color: var(--bg); }
.btn-pill:active { transform: scale(.97); }
.btn-pill:disabled { opacity: .4; cursor: default; }

/* ── Alert bar ─────────────────────────────────────────── */
.alert-bar {
  background: var(--amber-dim); border-bottom: 1px solid rgba(232,162,58,0.3);
  padding: 10px 1.5rem; font-size: 12px; color: var(--amber);
  line-height: 1.5; text-align: center; letter-spacing: 0.01em;
}

/* ── Main layout ───────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* ── Metric cards ─────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px; margin-bottom: 1.5rem;
}
.met-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px;
  transition: border-color .2s;
}
.met-card:hover { border-color: var(--border-em); }
.met-card.primary { border-color: rgba(184,255,87,0.15); background: rgba(184,255,87,0.04); }
.met-label { font-size: 10px; color: var(--text3); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
.met-value { font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--text); line-height: 1.1; }
.met-card.primary .met-value { color: var(--accent); }
.met-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Section titles ───────────────────────────────────── */
h2 {
  font-family: var(--display); font-size: 13px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text2);
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 0.75rem;
}
.section-sub { font-size: 11px; color: var(--text3); }

/* ── Chart section ─────────────────────────────────────── */
.chart-section {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  margin-bottom: 1rem;
}
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fuel-tabs, .period-tabs {
  display: flex; border: 1px solid var(--border); border-radius: 100px; overflow: hidden;
}
.ftab, .ptab {
  font-family: var(--mono); font-size: 11px; padding: 4px 12px;
  border: none; background: transparent; color: var(--text3);
  cursor: pointer; transition: all .15s; letter-spacing: 0.02em;
}
.ftab.on, .ptab.on { background: var(--bg4); color: var(--text); }
.ftab:hover:not(.on), .ptab:hover:not(.on) { color: var(--text2); }

.legend {
  display: flex; gap: 14px; font-size: 11px; color: var(--text3);
  margin: 0.5rem 0; flex-wrap: wrap; letter-spacing: 0.02em;
}
.leg { display: flex; align-items: center; gap: 5px; }
.lsq { width: 9px; height: 9px; border-radius: 2px; }
.lsq.green { background: var(--green); }
.lsq.red { background: var(--red); }
.lsq.blue-dash { background: var(--blue-dim); border: 1px dashed var(--blue); }
.lline { width: 16px; height: 2px; background: var(--blue); border-radius: 1px; }
.chart-wrap { position: relative; width: 100%; height: 240px; margin-top: 0.5rem; }

/* ── Forecast section ─────────────────────────────────── */
.forecast-section {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  margin-bottom: 1rem;
}
.forecast-section h2 { margin-bottom: 0.75rem; }

.best-tank-card {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--green-dim); border: 1.5px solid var(--green);
  border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 1rem;
}
.best-icon { font-size: 22px; }
.best-info { flex: 1; min-width: 140px; }
.best-day { font-family: var(--display); font-size: 15px; font-weight: 600; color: var(--text); }
.best-detail { font-size: 11px; color: var(--text2); margin-top: 2px; }
.best-price { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--green); }

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
  gap: 6px; margin-bottom: 1rem;
}
.fc-day {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 6px; text-align: center;
  transition: border-color .15s;
}
.fc-day:hover { border-color: var(--border-em); }
.fc-day.best { border-color: var(--green); background: var(--green-dim); }
.fc-day.worst { border-color: var(--red); background: var(--red-dim); }
.fc-date { font-size: 10px; color: var(--text3); margin-bottom: 4px; letter-spacing: 0.02em; }
.fc-price { font-family: var(--display); font-size: 13px; font-weight: 600; color: var(--text); }
.fc-dir { font-size: 10px; margin-top: 2px; }
.fc-dir.up { color: var(--red); }
.fc-dir.dn { color: var(--green); }
.fc-conf { height: 3px; border-radius: 2px; background: var(--blue); margin-top: 5px; opacity: 0.5; }

.insight-box {
  font-size: 12px; color: var(--text2); line-height: 1.7;
  padding: 10px 14px; background: var(--blue-dim);
  border-radius: var(--radius); border-left: 2px solid var(--blue);
  letter-spacing: 0.01em;
}
.insight-box b { color: var(--text); font-weight: 500; }

/* ── Stations section ─────────────────────────────────── */
.stations-section { margin-bottom: 1.5rem; }
.stations-section h2 { margin-bottom: 0; }
#stList { display: grid; gap: 6px; margin-top: 0.75rem; }

.scard {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 14px;
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 12px;
  transition: border-color .15s;
}
.scard:hover { border-color: var(--border-em); }
.scard.best-s { border-color: var(--green); border-width: 1.5px; }
.sn { font-family: var(--display); font-size: 13px; font-weight: 600; color: var(--text); }
.sm { font-size: 11px; color: var(--text3); margin-top: 3px; }
.sp { display: flex; gap: 10px; align-items: center; }
.pp { text-align: center; min-width: 56px; }
.pp-label { font-size: 9px; color: var(--text3); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 2px; }
.pp-val { font-family: var(--display); font-size: 13px; font-weight: 600; color: var(--text); }
.sdiv { width: 1px; height: 28px; background: var(--border); }
.badge-cheap {
  font-size: 9px; background: var(--green-dim); color: var(--green);
  border: 1px solid rgba(76,175,125,0.3); border-radius: 3px;
  padding: 1px 6px; letter-spacing: 0.04em; margin-right: 6px;
}
.odot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 4px; vertical-align: middle; }
.cdot { width: 6px; height: 6px; border-radius: 50%; background: var(--red); display: inline-block; margin-right: 4px; vertical-align: middle; }

/* ── Loading / error states ───────────────────────────── */
.loading-msg {
  text-align: center; padding: 2rem; color: var(--text3);
  font-size: 12px; letter-spacing: 0.04em;
}
.err-msg {
  text-align: center; padding: 1.5rem; color: var(--text3);
  font-size: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ── Timestamps ────────────────────────────────────────── */
.ts { font-size: 10px; color: var(--text3); margin-top: 8px; letter-spacing: 0.04em; }

/* ── Footer ────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  font-size: 11px; color: var(--text3);
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
footer a { color: var(--text2); text-decoration: none; }
footer a:hover { color: var(--text); }

/* ── Spinner ───────────────────────────────────────────── */
.spin { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 1rem; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 200px; }
  .forecast-grid { grid-template-columns: repeat(5, 1fr); }
  .fc-date { font-size: 9px; }
  .scard { grid-template-columns: 1fr; }
  .sp { justify-content: flex-start; }
}

/* ── Entry animation ───────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.metrics-grid, .chart-section, .forecast-section, .stations-section {
  animation: fadeUp 0.4s ease both;
}
.chart-section    { animation-delay: 0.05s; }
.forecast-section { animation-delay: 0.10s; }
.stations-section { animation-delay: 0.15s; }
