/* climateDevice — "Halle 7 / Leitstand"
 * A Baumarkt shop-floor system: concrete-grey ground, structural signal-yellow
 * chrome, mono warehouse tickets. One saturated status color (green = relief).
 */

:root {
  /* Palette */
  --beton: #e4e2dc;       /* app background — cool concrete grey */
  --regal: #fafaf8;       /* panels, cards, list/filter surfaces */
  --stahl: #1a1c1b;       /* ink, header gantry, map bezel, buttons */
  --schiefer: #15212b;    /* readout strip / popup header (slate) */
  --gelb: #f2b705;        /* STRUCTURE ONLY — focus, radius, brand tab */
  --frei: #2e7d32;        /* AVAILABLE — only saturated status color */
  --bernstein: #b06a00;   /* RESERVABILITY: walk-in only (amber, text-safe) */
  --vergriffen: #7a8085;  /* NOT AVAILABLE — dimmed slate */
  --line: #c9c6bd;        /* hairline dividers, field borders */
  --muted: #5c5f5b;       /* secondary text, eyebrows, mono meta */
  --active-bg: #f2f1ea;

  /* Type */
  --display: "Saira Condensed", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;

  --topbar-h: 52px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--body);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--stahl);
  background: var(--beton);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- Brand wordmark (gantry stencil) ---- */
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 10px;
  height: 1.1em;
  background: var(--gelb);
  flex: none;
}

/* ---- Gantry header ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.1rem;
  background: var(--stahl);
  color: var(--regal);
  border-bottom: 3px solid var(--gelb);
}

.topbar .brand {
  color: var(--regal);
}

.preset {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-left: auto;
}

.preset > span {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b9bbb6;
}

.preset select {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--stahl);
  color: var(--regal);
  border: 1px solid #43464a;
  border-radius: 0;
  padding: 0.3rem 0.4rem;
}

/* ---- Filter rail ---- */
.filter-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
  padding: 0.7rem 1.1rem;
  background: var(--regal);
  border-bottom: 1px solid var(--line);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-family: var(--display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.filter-field,
input#plz,
.radius-num {
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--stahl);
  border-radius: 0;
  background: var(--regal);
  color: var(--stahl);
}

select.filter-field {
  min-width: 12rem;
}

input#plz {
  letter-spacing: 0.12em;
  width: 8rem;
}

/* ---- Radius (heat dial) ---- */
.filter-group.radius {
  min-width: 230px;
}

.radius-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Heat dial: yellow track, square white thumb welded with a stahl border —
 * stays inside the no-rounded-corners language. */
#radius {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  margin: 0;
  background: var(--gelb);
  border: 1px solid var(--stahl);
  border-radius: 0;
  cursor: pointer;
}

#radius::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  background: #fff;
  border: 2px solid var(--stahl);
  border-radius: 0;
}

#radius::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--stahl);
  border-radius: 0;
}

#radius::-moz-range-track {
  height: 6px;
  background: var(--gelb);
  border: 1px solid var(--stahl);
  border-radius: 0;
}

.radius-num {
  width: 4.5rem;
}

#radiusLabel {
  font-family: var(--mono);
  font-weight: 600;
}

/* ---- Last-update readout (pushed to the top-right of the filter bar) ---- */
.last-update {
  margin-left: auto;
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 0.15rem;
}

/* ---- Price range ---- */
.price-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.price-num {
  width: 4.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--stahl);
  border-radius: 0;
  background: var(--regal);
  color: var(--stahl);
}

.price-dash {
  font-family: var(--mono);
  color: var(--muted);
}

/* ---- Devices (product chips) ---- */
.filter-group.devices {
  max-width: 320px;
}

.device-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ---- Markets (compact dropdown + retailer chips inside) ---- */
.market-dropdown {
  position: relative;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-width: 11rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--stahl);
  border-radius: 0;
  background: var(--regal);
  color: var(--stahl);
  cursor: pointer;
}

.dropdown-toggle:hover {
  background: #f0efe9;
}

.dropdown-caret {
  color: var(--muted);
  font-size: 0.7rem;
}

.market-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 700;
  background: var(--regal);
  border: 1px solid var(--stahl);
  border-top: 3px solid var(--gelb);
  padding: 0.6rem 0.7rem;
  min-width: 17rem;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(21, 33, 43, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.market-panel.is-hidden {
  display: none;
}

.market-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}

.link-btn:hover {
  color: var(--stahl);
  text-decoration: underline;
}

.market-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

/* Country bucket: a small mono eyebrow over its retailer chips. */
.market-country {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.market-country-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.market-country-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.market-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--stahl);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.market-check:has(input:checked) {
  border-color: var(--stahl);
  background: #f0efe9;
}

.market-check input {
  accent-color: var(--stahl);
  cursor: pointer;
}

/* ---- Nur verfügbar toggle ---- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--body);
  font-size: 0.9rem;
  color: var(--stahl);
  cursor: pointer;
  padding: 0.35rem 0;
}

.toggle input {
  accent-color: var(--frei);
  cursor: pointer;
  width: 1rem;
  height: 1rem;
}

/* ---- Layout ---- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 10px;
  padding: 10px;
  min-height: 0;
  background: var(--beton);
}

/* Map console: slate bezel */
.map-pane {
  position: relative;
  height: 100%;
  width: 100%;
  border: 6px solid var(--stahl);
  border-radius: 5px;
  overflow: hidden;
}

.map-canvas {
  height: 100%;
  width: 100%;
}

/* Readout strip welded to the bezel's bottom edge */
.map-readout {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  pointer-events: none;
  background: var(--schiefer);
  color: #cfe9da;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  padding: 0.3rem 0.6rem;
}

/* ---- Status board (tabbed right column) ---- */
.board {
  background: var(--regal);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  min-height: 0;
}

.board-tabs {
  display: flex;
  flex: none;
  background: var(--stahl);
}

.board-tab {
  flex: 1;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b9bbb6;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.board-tab:hover {
  color: var(--regal);
}

.board-tab.active {
  color: var(--regal);
  border-bottom-color: var(--gelb);
}

.tab-count {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--stahl);
  background: var(--gelb);
  padding: 0.05rem 0.35rem;
  min-width: 1.4rem;
  text-align: center;
}

.board-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.board-panel.is-hidden {
  display: none;
}

.panel-note {
  margin: 0;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-stats {
  margin: 0;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--stahl);
}

.panel-stats:empty {
  display: none;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 0;
  margin-left: 0.45rem;
}

.dot-available {
  background: var(--frei);
}

.dot-unavailable {
  background: #fff;
  border: 1.5px solid var(--vergriffen);
}

/* ---- Store list — shelf-label cards ---- */
.store-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.store-item {
  position: relative;
  padding: 0.75rem 0.9rem 0.75rem 1.4rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Status spine */
.store-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--vergriffen);
}

.store-item.is-available::before {
  background: var(--frei);
}

.store-item:hover {
  background: var(--active-bg);
}

.store-item.active {
  background: var(--active-bg);
}

.store-item.active::before {
  box-shadow: inset 0 0 0 2px var(--gelb);
}

.store-item .name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.store-item .name {
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.95rem;
}

/* Status ticket */
.status-badge {
  flex: none;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 0;
  background: transparent;
  border: 1px solid var(--vergriffen);
  color: var(--vergriffen);
  white-space: nowrap;
}

.status-badge.available {
  border-color: var(--frei);
  color: var(--frei);
}

/* Reservability ticket — same warehouse-label language as .status-badge.
 * yes = reservable (green), no = walk-in only (amber). */
.resv-badge {
  flex: none;
  align-self: flex-start;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 0;
  background: transparent;
  border: 1px solid var(--bernstein);
  color: var(--bernstein);
  white-space: nowrap;
}

.resv-badge.yes {
  border-color: var(--frei);
  color: var(--frei);
}

.popup .resv-badge {
  display: inline-block;
  margin-bottom: 0.2rem;
}

.store-item .meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.store-item .price {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--stahl);
}

.empty {
  padding: 1.5rem 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---- Store identity (retailer eyebrow + name + distance) ---- */
.store-id {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.store-brand {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.store-dist {
  flex: none;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--stahl);
  white-space: nowrap;
}

/* ---- Product matrix (one row per selected device) ---- */
.pm {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.35rem;
}

.pm-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.18rem 0.3rem;
  background: #f0efe9;
  border-left: 3px solid var(--vergriffen);
}

.pm-row.on {
  border-left-color: var(--frei);
  background: #eef4ee;
}

.pm-name {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--stahl);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-price {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.76rem;
  color: var(--stahl);
  white-space: nowrap;
}

.pm-link {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--frei);
  text-decoration: none;
  padding: 0 0.15rem;
}

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

/* ---- History feed ("Letzte Verfügbarkeiten") ---- */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hist-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.hist-item:hover {
  background: var(--active-bg);
}

.hist-when {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  min-width: 4.6rem;
}

.hist-body {
  min-width: 0;
}

.hist-line {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.hist-store {
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-line2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.1rem;
}

.hist-prod {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---- Map markers (square warehouse tickets) ---- */
.cd-marker {
  width: 16px;
  height: 16px;
  box-sizing: border-box;
}

/* Available = the only saturated mark on the Positron canvas. White border
 * + a faint dark lift separate the green square from the grey site plan. */
.cd-marker.available {
  background: var(--frei);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(21, 33, 43, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
}

.cd-marker.unavailable {
  width: 13px;
  height: 13px;
  margin: 1px;
  background: #fff;
  border: 2px solid var(--vergriffen);
}

/* ---- Leaflet popup (square, slate header) ---- */
.leaflet-popup-content-wrapper {
  background: var(--regal);
  border: 1px solid var(--stahl);
  border-radius: 0;
  box-shadow: none;
}

.leaflet-popup-content {
  margin: 0;
  font-family: var(--body);
}

.leaflet-popup-tip {
  background: var(--regal);
  border: 1px solid var(--stahl);
  box-shadow: none;
}

.leaflet-popup-close-button {
  color: #cfd6da !important;
  z-index: 1;
}

.popup {
  min-width: 170px;
}

.popup-head {
  background: var(--schiefer);
  color: #fff;
  font-family: var(--body);
  font-weight: 600;
  padding: 0.45rem 0.6rem;
}

.popup-brand {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9fb4c0;
}

.popup-name {
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.1;
}

.popup .pm {
  margin-top: 0.4rem;
}

.popup-body {
  padding: 0.5rem 0.6rem 0.6rem;
}

.popup .meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.popup-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--frei);
  text-decoration: none;
}

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

/* ---- Login ---- */
.login-body {
  display: grid;
  place-items: center;
  background: var(--beton);
  min-height: 100vh;
  position: relative;
}

/* Floor vernacular: a mono baseline welded to the bottom edge anchors the
 * card so it doesn't float in a dead-centered void. */
.login-baseline {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--stahl);
  color: #b9bbb6;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.4rem 0.6rem;
  border-top: 3px solid var(--gelb);
}

.login-card {
  background: var(--regal);
  border: 1px solid var(--stahl);
  border-top: 6px solid var(--gelb);
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  max-width: 360px;
  padding: 2rem;
}

.login-card .brand {
  color: var(--stahl);
}

.login-sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.6rem 0 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form .control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.login-form .control > span {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-form input[name="password"] {
  font-family: var(--mono);
  font-size: 0.95rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--stahl);
  border-radius: 0;
  background: var(--regal);
  color: var(--stahl);
}

.login-error {
  font-family: var(--body);
  font-size: 0.85rem;
  color: var(--stahl);
  border: 1px solid var(--vergriffen);
  border-left: 4px solid var(--vergriffen);
  padding: 0.5rem 0.6rem;
  margin: 0 0 1.1rem;
}

.btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--stahl);
  color: var(--regal);
  border: none;
  border-radius: 0;
  padding: 0.6rem 1rem;
  cursor: pointer;
}

.btn:hover {
  background: #000;
}

/* ---- Focus (never removed) ---- */
:focus-visible {
  outline: 3px solid var(--gelb);
  outline-offset: 1px;
}

.store-item:focus-visible {
  outline-offset: -3px;
}

/* ---- Reduced motion / marker pulse ---- */
@media (prefers-reduced-motion: no-preference) {
  .cd-marker.available.marker-pulse:hover {
    animation: pulse 1.2s ease-out 1;
  }
  @keyframes pulse {
    from {
      box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.5);
    }
    to {
      box-shadow: 0 0 0 12px rgba(46, 125, 50, 0);
    }
  }
}

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .filter-panel {
    gap: 0.9rem;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh 45vh;
  }

  .board {
    border: 1px solid var(--line);
  }
}
