:root {
  --green-900: #1b5e20;
  --green-700: #2e7d32;
  --green-500: #4caf50;
  --green-300: #a5d6a7;
  --green-50:  #f1f8e9;
  --ink-900:   #1a1f1a;
  --ink-700:   #3b443b;
  --ink-500:   #6b736b;
  --bg:        #ffffff;
  --line:      #e3ebe0;
  --danger:    #c62828;
  --radius:    14px;
  --shadow:    0 2px 12px rgba(27, 94, 32, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", sans-serif;
  color: var(--ink-900);
  background: var(--green-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

#app, body {
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--green-700);
  color: #fff;
  box-shadow: var(--shadow);
}

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

.brand-logo {
  height: 32px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 3px 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  .brand-logo {
    background: transparent;
    box-shadow: none;
    padding: 0;
  }
}

.brand-name {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.status--online     { background: var(--green-500); border-color: var(--green-300); }
.status--connecting { background: #fb8c00; border-color: #ffcc80; }
.status--error      { background: var(--danger); border-color: #ef9a9a; }
.status--offline    { background: rgba(255, 255, 255, 0.1); }

.app-main {
  flex: 1;
  padding: 20px 18px 28px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.hero {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  text-align: center;
}

.hero-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-500);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
}
.hero-close:hover,
.hero-close:focus-visible {
  background: var(--green-50);
  color: var(--ink-900);
  outline: none;
}

.hero-logo {
  display: block;
  margin: 0 auto 12px;
  max-width: min(280px, 70%);
  height: auto;
}

.hero h2 {
  margin: 0 0 6px;
  color: var(--green-900);
  font-size: 22px;
}

.hero p {
  margin: 0;
  color: var(--ink-700);
}

.content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.content--map {
  padding: 0;
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--green-50);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  align-items: center;
}

.map-search {
  display: flex;
  flex: 1 1 220px;
  gap: 6px;
  min-width: 200px;
  margin: 0;
}

.map-search input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--ink-900);
  min-width: 0;
}
.map-search input:focus-visible {
  outline: 2px solid var(--green-300);
  outline-offset: 1px;
  border-color: var(--green-500);
}

.btn--toolbar {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-900);
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 500;
}
.btn--toolbar:hover:not(:disabled) { background: var(--green-50); border-color: var(--green-300); }
.btn--toolbar:disabled { opacity: 0.6; cursor: progress; }

.map {
  width: 100%;
  height: 55vh;
  min-height: 320px;
  max-height: 560px;
  background: var(--green-50);
}

.hl-pin {
  display: block;
  width: 32px;
  height: 32px;
}

.hl-pin__dot {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.18),
    0 3px 8px rgba(0, 0, 0, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.18);
  margin: 3px;
  transition: transform 0.15s ease;
}

.hl-pin:hover .hl-pin__dot,
.hl-pin:focus .hl-pin__dot {
  transform: scale(1.15);
}

/* Pulsierender Ring fuer aktive Marker (mind. 1 Slot verfuegbar) */
.hl-pin--active .hl-pin__dot::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: #2e7d32;
  opacity: 0.55;
  animation: hl-pin-pulse 1.8s ease-out infinite;
  pointer-events: none;
}

.hl-pin__dot { position: relative; }

@keyframes hl-pin-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(1.7); opacity: 0;    }
  100% { transform: scale(1.7); opacity: 0;    }
}

.section-title {
  margin: 0 0 12px;
  color: var(--green-900);
  font-size: 16px;
  letter-spacing: 0.2px;
}

.muted { color: var(--ink-500); }

.summary {
  display: grid;
  gap: 12px;
}

.station {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--green-50);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.station:hover,
.station:focus-visible {
  background: #e8f3e2;
  border-color: var(--green-300);
  outline: none;
}

.station:active { transform: scale(0.995); }

@media (prefers-color-scheme: dark) {
  .station:hover,
  .station:focus-visible {
    background: #18221b;
  }
}

.station h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--green-900);
}

.station p {
  margin: 2px 0;
  font-size: 13px;
}

.log {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--green-50);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.log-line {
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
  word-break: break-all;
}

.log-line:last-child { border-bottom: 0; }
.log-time    { color: var(--ink-500); margin-right: 6px; }
.log-topic   { color: var(--green-700); font-weight: 600; margin-right: 6px; }
.log-payload { color: var(--ink-700); }

.placeholder {
  color: var(--ink-500);
  text-align: center;
  margin: 0;
  padding: 40px 0;
}

.app-footer {
  text-align: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  color: var(--ink-500);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #131814;
    --green-50:#0f1410;
    --line:    #23302a;
    --ink-900: #e8efe8;
    --ink-700: #b9c4ba;
    --ink-500: #8a948b;
  }
}

/* ------- Profil-Modal (Bottom-Sheet) ------- */

body.modal-open { overflow: hidden; }

.profile {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.profile.is-open { pointer-events: auto; }

.profile-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 28, 18, 0.45);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.profile.is-open .profile-backdrop { opacity: 1; }

.profile-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  padding-bottom: env(safe-area-inset-bottom);
}

.profile.is-open .profile-sheet { transform: translateY(0); }

@media (min-width: 640px) {
  .profile-sheet {
    left: 50%;
    right: auto;
    bottom: 50%;
    transform: translate(-50%, calc(50% + 24px));
    width: min(520px, 92vw);
    border-radius: 18px;
    max-height: 80vh;
  }
  .profile.is-open .profile-sheet {
    transform: translate(-50%, 50%);
  }
}

.profile-header {
  position: relative;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-grip {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

@media (min-width: 640px) {
  .profile-grip { display: none; }
}

.profile-title {
  margin: 0;
  flex: 1;
  font-size: 17px;
  color: var(--green-900);
  padding-right: 8px;
}

.profile-close {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: var(--ink-500);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.profile-close:hover,
.profile-close:focus-visible {
  background: var(--green-50);
  color: var(--ink-900);
  outline: none;
}

.profile-body {
  padding: 14px 18px 4px;
  overflow-y: auto;
  flex: 1;
}

.profile-mac {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--ink-500);
}

.profile-status {
  font-size: 13px;
  color: var(--ink-700);
}

.profile-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0 14px;
  flex-wrap: wrap;
}

.profile-section {
  display: grid;
  gap: 10px;
}

.profile-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.profile-row:last-child { border-bottom: 0; }

.profile-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--ink-500);
}

.profile-value {
  font-size: 14px;
  color: var(--ink-900);
  word-break: break-word;
}

.profile-value a { color: var(--green-700); text-decoration: none; }
.profile-value a:hover { text-decoration: underline; }

.profile-value--white,
.profile-value--white a {
  color: #fff;
  background: var(--green-700);
  border-radius: 8px;
  padding: 6px 10px;
  display: inline-block;
  text-decoration: none;
}
.profile-value--white a:hover { text-decoration: underline; }

.profile-footer {
  display: flex;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}

.btn {
  flex: 1;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:focus-visible { outline: 2px solid var(--green-300); outline-offset: 2px; }

.btn--primary {
  background: var(--green-700);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--green-900); }
.btn--primary:disabled { background: var(--ink-500); cursor: not-allowed; opacity: 0.7; }

.btn--ghost {
  background: transparent;
  color: var(--ink-700);
  border-color: var(--line);
}

.btn--ghost:hover { background: var(--green-50); color: var(--ink-900); }

.btn--nav {
  background: var(--green-500);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  text-align: center;
}
.btn--nav:hover:not(:disabled) { background: var(--green-700); }
.btn--nav:disabled { background: var(--ink-500); cursor: not-allowed; opacity: 0.7; }

/* ------- Produktliste ------- */

.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter {
  display: inline-flex;
  background: var(--green-50);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.filter-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink-700);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.filter-btn.is-active {
  background: var(--green-700);
  color: #fff;
  font-weight: 600;
}

.filter-btn:focus-visible {
  outline: 2px solid var(--green-300);
  outline-offset: 2px;
}

.products-summary {
  font-size: 12px;
  color: var(--ink-500);
}

.products-list {
  display: grid;
  gap: 10px;
  padding-bottom: 8px;
}

.product {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg);
  display: grid;
  gap: 6px;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}

.product:focus-visible {
  outline: 2px solid var(--green-300);
  outline-offset: 2px;
}

.product:active { transform: scale(0.997); }

/* Verfügbar: grünes Tile (Marke). */
.product--available {
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  border-color: var(--green-700);
  color: #fff;
}
.product--available:hover { background: linear-gradient(135deg, var(--green-900), var(--green-700)); }
.product--available .product-slot  { color: rgba(255, 255, 255, 0.85); }
.product--available .product-name  { color: #fff; }
.product--available .product-price { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); }
.product--available .product-meta  { color: rgba(255, 255, 255, 0.85); }

/* Leer: PP16-Lila-Gradient (display_manager.cpp Fach-leer-Buttons). */
.product--empty {
  background: linear-gradient(135deg, #500090, #9800B8);
  border-color: #C800F8;
  color: #fff;
}
.product--empty:hover { background: linear-gradient(135deg, #3a0070, #7a0099); }
.product--empty .product-slot  { color: rgba(255, 255, 255, 0.85); }
.product--empty .product-name  { color: #fff; }
.product--empty .product-price { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.product--empty .product-meta  { color: rgba(255, 255, 255, 0.85); }

.product--locked {
  background: var(--green-50);
  border-color: var(--line);
  opacity: 0.7;
}
.product--locked:hover { background: var(--green-50); }

/* Heart-Pille auf colored Tiles: transparent → fügt sich in den Gradient ein. */
.product--available .heart-btn,
.product--empty .heart-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}
.product--available .heart-btn:hover,
.product--available .heart-btn:focus-visible,
.product--empty .heart-btn:hover,
.product--empty .heart-btn:focus-visible {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.75);
}
.product--available .heart-btn.is-fav,
.product--empty .heart-btn.is-fav {
  background: #fff;
  border-color: #fff;
  color: var(--danger);
}

.product-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.product-head-main {
  min-width: 0;
  flex: 1;
}

.product-slot {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-500);
}

.product-name {
  margin: 2px 0 0;
  font-size: 15px;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--green-900);
  white-space: nowrap;
  line-height: 1.1;
}

.product-meta {
  font-size: 12px;
  color: var(--ink-500);
}

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  align-self: flex-start;
}

.badge--available { background: var(--green-500); color: #fff; }
.badge--empty     { background: var(--line); color: var(--ink-700); }
.badge--locked    { background: #455a64; color: #fff; }

@media (prefers-color-scheme: dark) {
  .product--locked { background: #131814; }
  .badge--empty { background: #2a352e; color: var(--ink-700); }
  /* Available/Empty-Tiles haben eigenen Gradient — Dark-Mode-Overrides nicht überschreiben. */
}

/* ------- Herkunftspass ------- */

.passport-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.passport-price {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
  color: var(--green-900);
}

@media (prefers-color-scheme: dark) {
  .passport-price { color: var(--green-300); }
}

.passport-qr {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.passport-qr-canvas {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 0;
}

.passport-qr-canvas img,
.passport-qr-canvas canvas {
  display: block;
}

.passport-qr-hint {
  margin: 0;
  font-size: 12px;
}

/* ------- Favoriten / Heart-Toggle ------- */

.heart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-700);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.05s ease;
}

.heart-btn:hover,
.heart-btn:focus-visible {
  border-color: var(--green-300);
  background: var(--green-50);
  outline: none;
}

.heart-btn:active { transform: scale(0.96); }

.heart-btn.is-fav {
  background: rgba(198, 40, 40, 0.08);
  border-color: rgba(198, 40, 40, 0.45);
  color: var(--danger);
}

.heart-btn.is-fav:hover,
.heart-btn.is-fav:focus-visible {
  background: rgba(198, 40, 40, 0.14);
}

.heart-btn--icon {
  padding: 6px 8px;
  font-size: 16px;
  min-width: 32px;
  justify-content: center;
}

.heart-icon { line-height: 1; }
.heart-label { white-space: nowrap; }

.product-head-right,
.passport-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Karten-Marker mit Favoriten-Badge */
.hl-pin { position: relative; }
.hl-pin__heart {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 2;
}

/* Favoriten-Bereich auf der Startseite */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-head .section-title { margin: 0; }

.btn-link {
  background: transparent;
  border: 0;
  color: var(--green-700);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-link:hover:not(:disabled) { background: var(--green-50); text-decoration: underline; }
.btn-link:disabled { color: var(--ink-500); cursor: not-allowed; }

.favorites {
  display: grid;
  gap: 16px;
}

.fav-group {
  display: grid;
  gap: 8px;
}

.fav-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-500);
  padding: 0 2px;
}

.fav-product {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.05s ease;
}

.fav-product:hover,
.fav-product:focus-visible {
  background: var(--green-50);
  border-color: var(--green-300);
  outline: none;
}

.fav-product:active { transform: scale(0.997); }

.fav-product-main { display: grid; gap: 2px; min-width: 0; }

.fav-product-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-product-station {
  font-size: 12px;
  color: var(--ink-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-product-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fav-product-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--green-900);
}

@media (prefers-color-scheme: dark) {
  .fav-product { background: #181f1a; }
  .fav-product-name { color: var(--ink-900); }
  .fav-product-price { color: var(--green-300); }
}
