:root {
  --bg:          #0b0f1a;
  --surface:     #131929;
  --surface-2:   #1a2235;
  --border:      #1e2d47;
  --border-hover:#2a3f62;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #94a3b8;
  --accent:      #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --green:       #4ade80;
  --green-bg:    rgba(74, 222, 128, 0.08);
  --red:         #f87171;
  --red-bg:      rgba(248, 113, 113, 0.08);
  --amber:       #fbbf24;
  --cheapest-glow: rgba(74, 222, 128, 0.12);
  --radius:      16px;
  --radius-sm:   10px;
  --transition:  200ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 26, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fuel-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex-shrink: 0;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.region-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 100px;
}

/* ── Main ────────────────────────────────────────── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ── Cards Grid ─────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Card ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-hover);
}

.card.cheapest {
  border-color: rgba(74, 222, 128, 0.35);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.1), 0 4px 24px var(--cheapest-glow);
}

.card.cheapest::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(74,222,128,0.04) 0%, transparent 60%);
  pointer-events: none;
}

/* Card header row */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-brand {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-top: 2px;
  min-height: calc(2 * 1.3em);
}

.card-place {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Status badge */
.status-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid transparent;
}

.status-badge.open {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.2);
}

.status-badge.closed {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.2);
}

.status-badge.unknown {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

/* Price block */
.card-price-block {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.price-value {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.card.cheapest .price-value {
  color: var(--green);
}

.price-last-digit {
  font-size: 1.7rem;
  vertical-align: baseline;
}

.price-currency {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
}

.price-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 2px;
}

.price-unavailable {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Cheapest label */
.cheapest-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cheapest-label svg {
  width: 13px;
  height: 13px;
}

/* Card address */
.card-address {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-address svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ── Skeleton ───────────────────────────────────── */
.card.skeleton {
  min-height: 190px;
  background: linear-gradient(90deg,
    var(--surface) 25%,
    var(--surface-2) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-color: var(--border);
}

@keyframes shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ── Error Banner ───────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--red-bg);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--red);
}

.error-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.error-banner.hidden { display: none; }

/* ── Footer row ─────────────────────────────────── */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dot-separator { opacity: 0.4; }

/* Refresh button */
.refresh-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.refresh-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.5s ease;
}

.refresh-btn:hover {
  background: var(--border);
  border-color: var(--border-hover);
  color: var(--text);
}

.refresh-btn.loading svg {
  animation: spin 0.7s linear infinite;
}

.refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Attribution */
.attribution {
  margin-top: 24px;
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Card clickable ─────────────────────────────── */
.card {
  cursor: pointer;
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── Modal overlay ───────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: color var(--transition), background var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

/* ── Range bar ───────────────────────────────────── */
.range-bar {
  display: flex;
  gap: 6px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.range-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.range-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-dim);
}

.range-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Chart area ──────────────────────────────────── */
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 260px;
  padding: 20px 24px 20px;
}

#history-chart {
  width: 100% !important;
  height: 100% !important;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: var(--surface);
}

.chart-overlay.hidden { display: none; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 600px) {
  .header-inner { padding: 14px 16px; }
  main { padding: 20px 16px 40px; }
  .price-value { font-size: 2.4rem; }
  .cards { gap: 12px; }
}
