:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-alt: #edf2ee;
  --text: #111827;
  --muted: #4b5563;
  --border: #d1d5db;
  --primary: #0b5d3b;
  --primary-text: #ffffff;
  --good-bg: #dcfce7;
  --good-text: #14532d;
  --warn-bg: #fef3c7;
  --warn-text: #78350f;
  --bad-bg: #fee2e2;
  --bad-text: #7f1d1d;
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #273449;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --border: #334155;
  --primary: #22c55e;
  --primary-text: #052e16;
  --good-bg: #14532d;
  --good-text: #bbf7d0;
  --warn-bg: #78350f;
  --warn-text: #fde68a;
  --bad-bg: #7f1d1d;
  --bad-text: #fecaca;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.hidden {
  display: none !important;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

/* Header — never squashes on narrow phone screens */
.app-header {
  position: sticky;
  top: 0;
  z-index: 400;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.2;
  white-space: nowrap;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.view-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.banner {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.92rem;
}

.banner.info {
  background: var(--warn-bg);
  color: var(--warn-text);
}

/* Compact Main Toolbar */
.toolbar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented {
  display: flex;
  flex: 1 1 150px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-alt);
}

.seg-btn {
  flex: 1;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--primary);
  color: var(--primary-text);
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.88rem;
  color: var(--muted);
}

.mini-stats strong {
  color: var(--text);
}

/* Panels & Controls */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 1.12rem;
}

.panel-subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.section-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn.active,
.btn.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.btn.compact {
  min-height: 46px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.btn.danger {
  border-color: var(--bad-text);
  color: var(--bad-text);
}

.search-input,
.select-input {
  width: 100%;
  min-height: 50px;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.control-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.control-buttons .btn {
  flex: 1 1 160px;
}

/* Discount Wallet */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-alt);
}

.rule-info {
  flex: 1 1 180px;
}

.rule-title {
  font-weight: 700;
  font-size: 0.96rem;
}

.rule-meta {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 2px;
}

.rule-actions {
  display: flex;
  gap: 8px;
}

.discount-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 6px 4px;
}

.checkbox-field input {
  width: 22px;
  height: 22px;
}

/* Map Card */
.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fuel-map {
  width: 100%;
  height: 64vh;
  min-height: 360px;
  max-height: 660px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  z-index: 1;
}

.fuel-pin-wrapper {
  background: transparent;
  border: none;
}

.fuel-pin {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.fuel-pin.good { background: #15803d; color: #ffffff; }
.fuel-pin.mid { background: #1e293b; color: #ffffff; }
.fuel-pin.high { background: #b91c1c; color: #ffffff; }
.fuel-pin.oos { background: #b45309; color: #ffffff; }

.map-legend {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-dot.good { background: #15803d; }
.legend-dot.mid { background: #1e293b; }
.legend-dot.high { background: #b91c1c; }
.legend-star { font-weight: 800; color: var(--primary); margin-right: 3px; }

.map-popup {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #111827;
  font-family: system-ui, -apple-system, sans-serif;
}

.map-popup-title { font-size: 1rem; }
.map-popup-sub { font-size: 0.85rem; color: #4b5563; }
.map-popup-price { font-size: 0.98rem; font-weight: 800; color: #0b5d3b; }
.map-popup-fuels { font-size: 0.82rem; color: #374151; }
.map-popup-link {
  display: inline-block;
  margin-top: 4px;
  padding: 8px 12px;
  background: #0b5d3b;
  color: #ffffff !important;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  text-align: center;
}

/* Station List Cards */
.station-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.station-name {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.station-meta {
  margin: 3px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.savings-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--good-bg);
  color: var(--good-text);
  font-size: 0.82rem;
  font-weight: 700;
}

.price-badge {
  min-width: 106px;
  text-align: right;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-alt);
  flex-shrink: 0;
}

.price-badge.good { background: var(--good-bg); color: var(--good-text); }
.price-badge.high { background: var(--bad-bg); color: var(--bad-text); }
.price-badge.oos { background: var(--warn-bg); color: var(--warn-text); }

.price-main {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
}

.price-raw-strike {
  font-size: 0.8rem;
  text-decoration: line-through;
  opacity: 0.8;
  margin-top: 2px;
}

.price-unit {
  font-size: 0.76rem;
  font-weight: 600;
  opacity: 0.9;
}

.all-fuels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fuel-tag {
  background: var(--surface-alt);
  color: var(--text);
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
}

.station-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.updated-text {
  font-size: 0.84rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.footer-note {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 8px 20px;
}
