:root {
  --blue: #1e88e5;
  --blue-dark: #0b3d66;
  --blue-light: #d6e9ff;
  --teal: #26a69a;
  --teal-light: #d3f1ec;
  --amber: #ffb300;
  --amber-light: #ffe7b8;
  --red: #d32f2f;
  --red-dark: #b71c1c;
  --bg: #f6fafd;
  --surface: #ffffff;
  --surface-2: #edf3f8;
  --text: #16222e;
  --muted: #5a6b7b;
  --outline: #d7e2ec;
  --radius: 14px;
  --shadow-sm: 0 2px 8px rgba(16, 34, 50, 0.06);
  --shadow: 0 6px 24px rgba(16, 34, 50, 0.10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-dark); }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--outline);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  font-size: 22px;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.city-selector { display: flex; align-items: center; gap: 8px; }

.city-selector label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.city-selector select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  min-width: 170px;
  cursor: pointer;
  font-family: inherit;
}

.user-actions { display: flex; align-items: center; gap: 8px; }

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue-dark);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover { background: var(--surface-2); }

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.btn-ghost { background: transparent; }

.btn-block { width: 100%; }

.icon-btn {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  cursor: pointer;
  font-family: inherit;
}

.icon-btn:hover { background: var(--surface-2); }

.link-btn {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}

.link-btn:hover { text-decoration: underline; }

/* ---------- Nav ---------- */
.app-nav {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-btn:hover { background: var(--surface-2); color: var(--blue-dark); }
.nav-btn.active { background: var(--blue); color: #fff; }
.nav-btn.nav-warmode { color: var(--red); font-weight: 800; }
.nav-btn.nav-warmode.active { background: var(--red); color: #fff; }

/* ---------- Main ---------- */
.app-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  min-height: 60vh;
}

/* ---------- States ---------- */
.loading, .empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.state {
  padding: 40px 24px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--outline);
}

.state-error h2 { margin: 0 0 10px; font-size: 20px; color: var(--red); }
.state-error p { color: var(--muted); margin: 0 0 16px; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
  font-size: 14px;
}

.crumb {
  border: 0;
  background: transparent;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  color: var(--blue);
  cursor: pointer;
}

.crumb:hover { background: var(--blue-light); }
.crumb-sep { color: var(--muted); font-size: 14px; }

/* ---------- Level title ---------- */
.level-title {
  font-size: clamp(22px, 2.6vw, 30px);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.level-sub { color: var(--muted); margin: 0 0 20px; }

.section-h {
  font-size: 20px;
  margin: 32px 0 14px;
  letter-spacing: -0.01em;
}

/* ---------- Tile grid ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--outline);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  color: var(--text);
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--blue);
}

.tile-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

.tile-text { flex: 1; min-width: 0; }
.tile-title { display: block; font-weight: 700; font-size: 15px; line-height: 1.2; }
.tile-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tile-chev { color: var(--blue); font-size: 22px; font-weight: 700; }

.tile-image {
  grid-column: 1 / -1;
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-sm);
}

.tile-image img { display: block; max-width: 100%; height: auto; }
.tile-image figcaption { padding: 8px 14px; font-size: 12.5px; color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.card-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 8px;
}

.card-value { font-size: 15px; }

.card-image { padding: 0; overflow: hidden; }
.card-image img { display: block; max-width: 100%; height: auto; }

/* ---------- Detail header ---------- */
.detail-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 20px;
}

.detail-badge {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 8px;
}

.detail-header h1 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -0.01em; }
.detail-sub { color: var(--muted); margin: 0; }

/* ---------- Prices ---------- */
.price-grid { display: flex; flex-direction: column; gap: 6px; }

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--surface-2);
}

.price-row:last-child { border-bottom: 0; }
.price { font-weight: 800; color: var(--blue-dark); }

/* ---------- Tags ---------- */
.tag-block { padding: 12px 0; border-top: 1px solid var(--surface-2); }
.tag-block:first-of-type { border-top: 0; padding-top: 0; }

.tag-title { font-weight: 700; font-size: 15px; }
.tag-value { font-size: 14px; margin-top: 4px; }
.tag-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }

.tag-items { list-style: none; padding: 0; margin: 8px 0 0; }
.tag-items li { padding: 6px 0; font-size: 14px; border-bottom: 1px dashed var(--surface-2); }
.tag-items li:last-child { border-bottom: 0; }
.tag-item-name { font-weight: 600; }
.tag-item-price { float: right; font-weight: 700; color: var(--blue-dark); }

.muted { color: var(--muted); font-size: 13.5px; }

/* ---------- Offers ---------- */
.offer-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

/* Tankstellen in der Menueebene sind anklickbar und oeffnen die
   Detailseite mit der vollstaendigen Preishistorie. */
.offer-card[data-node] {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.offer-card[data-node]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--blue);
}

.offer-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.offer-icon { font-size: 24px; }

.offer-title { font-weight: 700; font-size: 15px; }
.offer-sub { font-size: 12.5px; color: var(--muted); }

.offer-prices {
  border-top: 1px solid var(--surface-2);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.offer-price {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
}

.offer-price span:last-child { font-weight: 700; color: var(--blue-dark); }

.offer-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.offer-status.is-free { color: #1b7a3a; }
.offer-status.is-busy { color: #c62828; }

/* ---------- Calendar ---------- */
.calendar-card { padding: 16px; }

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-title { font-weight: 700; font-size: 17px; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 0;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--outline);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s ease;
}

.cal-day:hover { background: var(--surface-2); }
.cal-empty { background: transparent; border: 0; cursor: default; }
.cal-empty:hover { background: transparent; }
.cal-has-events { background: var(--blue-light); color: var(--blue-dark); font-weight: 800; }
.cal-today { border: 2px solid var(--blue); }
.cal-selected { background: var(--blue); color: #fff; border-color: var(--blue); }
.cal-selected .cal-dot { background: #fff; }
.cal-day-num { line-height: 1; }

.cal-dots {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
}

.cal-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }

.calendar-foot { display: flex; justify-content: center; margin-top: 12px; }

/* ---------- Event cards ---------- */
.event-list { display: flex; flex-direction: column; gap: 12px; }
.event-card { margin: 0; }

.event-time { font-weight: 800; color: var(--blue); font-size: 15px; margin-bottom: 4px; }
.event-title { font-weight: 700; font-size: 17px; }
.event-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.event-cat {
  font-size: 12px;
  color: var(--blue);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 6px;
}
.event-desc { margin: 8px 0 0; font-size: 14px; }
.event-price { margin-top: 8px; font-weight: 700; color: var(--blue-dark); }

/* Bild zur Veranstaltung: Nur sichtbar, wenn in der Spalte image_url
   ein gueltiger Web-Link hinterlegt ist.
   Die Grafik wird NICHT skaliert: Sie erscheint in ihrer natuerlichen
   Groesse (die Bilder sind je nach Eintrag zwischen 200x200 und
   310x310 Pixel gross). Nur wenn sie breiter als die Kachel ist,
   wird sie auf die verfuegbare Breite begrenzt - das
   Seitenverhaeltnis bleibt dabei erhalten (height: auto). */
.event-image {
  display: block;
  max-width: 100%;
  margin: 0 auto 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.event-image img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* Button "Weitere Informationen": Nur sichtbar, wenn in der Spalte url
   ein gueltiger Web-Link hinterlegt ist. */
.event-link {
  display: inline-flex;
  margin-top: 12px;
}

/* ---------- Search ---------- */
.search-box { margin-bottom: 20px; }

.search-box input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--outline);
  background: var(--surface);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

.search-box input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: var(--blue);
}

/* ---------- Warmode ---------- */
.warmode-title { color: var(--red); }
.warn-list { display: flex; flex-direction: column; gap: 12px; }

.warn-card {
  padding: 16px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.warn-info { background: var(--blue); }
.warn-amber { background: #ef6c00; }
.warn-red { background: var(--red); }

.warn-title { font-weight: 800; font-size: 16px; margin-bottom: 6px; }
.warn-msg { font-size: 14.5px; }
.warn-time { font-size: 12px; opacity: 0.85; margin-top: 8px; }

.sos-card { text-align: center; }
.sos-id { font-weight: 800; color: var(--red); }
.sos-coord {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  margin-top: 4px;
}
.sos-time { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 61, 102, 0.55);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(11, 61, 102, 0.32);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-inner { padding: 28px; position: relative; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: 0;
  background: transparent;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal h2 { margin: 0 0 6px; font-size: 22px; }
.modal .muted { margin: 0 0 18px; }

.modal form { display: flex; flex-direction: column; gap: 12px; }

.modal label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.modal input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

.modal input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: var(--blue);
}

.form-error {
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  min-height: 0;
}

.form-error:not(:empty) { margin: 2px 0; }

.modal-switch {
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Footer ---------- */
.app-footer {
  background: var(--blue-dark);
  color: #cfe3f5;
  padding: 30px 24px;
  text-align: center;
  font-size: 13.5px;
}

.app-footer p { margin: 4px 0; }
.app-footer a { color: #fff; }

/* ---------- Tankstellen: Steuerung & Statistik ---------- */
.fuel-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.fuel-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.fuel-control-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}

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

.chip {
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 13px;
  font-family: inherit;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chip:hover { background: var(--surface-2); }
.chip-active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip-active:hover { background: var(--blue-dark); border-color: var(--blue-dark); }

.offer-price.is-selected span { color: var(--blue-dark); font-weight: 800; }

.fuel-stats {
  border-top: 1px solid var(--surface-2);
  margin-top: 10px;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fuel-stats-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.fuel-stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.fuel-stat-window {
  width: 72px;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--muted);
}

.fuel-stat-min { flex: 1; }
.fuel-stat-max { flex: 1; font-weight: 700; color: var(--blue-dark); }

/* ---------- Oeffnungszeiten ---------- */
.hours-table {
  width: 100%;
  border-collapse: collapse;
}

.hours-table th {
  width: 42px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 8px;
}

.hours-table td {
  font-size: 14px;
  padding: 5px 8px;
  border-radius: 8px;
}

.hours-table tr.hours-today th,
.hours-table tr.hours-today td {
  background: var(--blue-light);
  color: var(--blue-dark);
  font-weight: 800;
}

.hours-table .hours-closed { color: var(--muted); }
.hours-today-tag {
  text-align: right;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue);
}

.hours-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.hours-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hours-status-dot.is-open { background: #2e7d32; }
.hours-status-dot.is-closed { background: #c62828; }

.hours-status-text {
  font-size: 14px;
  font-weight: 700;
}

.hours-status-text.is-open { color: #2e7d32; }
.hours-status-text.is-closed { color: #c62828; }

.closed-days {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-2);
}

.closed-days-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 8px;
}

.closed-day-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
}

.closed-day-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--outline);
  flex-shrink: 0;
}

.closed-day-row.is-current .closed-day-dot { background: #c62828; }

.closed-day-row.is-current .closed-day-date {
  color: #c62828;
  font-weight: 800;
}

.closed-day-date { flex: 1; }

.closed-day-label {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .header-inner { padding: 10px 16px; }
  .brand-title { font-size: 15px; }
  .city-selector select { min-width: 140px; font-size: 13px; }
  .app-main { padding: 20px 16px 40px; }
  .app-nav { padding: 0 16px 10px; }
  .tile-grid { grid-template-columns: 1fr; }
}
