/* ════════════════════════════════════════════════════════════
   Smart City Bocholt – Stylesheet
   Mobile-first, vollständig responsive
   Breakpoints: sm=480, md=600, lg=900, xl=1200
   ════════════════════════════════════════════════════════════ */

/* ── CUSTOM PROPERTIES ───────────────────────────────────── */
:root {
  --accent:       #2d7a4f;
  --accent-rgb:   45,122,79;
  --accent-light: #3a9962;
  --accent-glow:  rgba(45,122,79,0.18);
  --accent-soft:  rgba(45,122,79,0.10);
  --ok:           #52b788;
  --warn:         #f4a261;
  --critical:     #e63946;
  --unknown:      #7a8199;
  --radius:       12px;
  --radius-sm:    8px;
  --font-display: 'Nunito', sans-serif;
  --font-body:    'Source Sans 3', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Mono', monospace;
}

[data-theme="dark"] {
  --bg:         #0f1410;
  --surface:    #161a22;
  --surface2:   #1e2330;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(255,255,255,0.13);
  --text:       #e4e6ee;
  --text-muted: #7a8199;
  --shadow:     0 4px 24px rgba(0,0,0,0.35);
  --header-bg:  rgba(15,20,16,0.90);
  --map-filter: brightness(0.65) saturate(0.45) hue-rotate(10deg);
  --scrollbar:  #2a3a2d;
}
[data-theme="light"] {
  --bg:         #f4f2ed;
  --surface:    #ffffff;
  --surface2:   #edeae4;
  --border:     rgba(0,0,0,0.08);
  --border2:    rgba(0,0,0,0.15);
  --text:       #1a2219;
  --text-muted: #6b7280;
  --shadow:     0 4px 24px rgba(0,0,0,0.10);
  --header-bg:  rgba(244,242,237,0.92);
  --map-filter: brightness(1.0) saturate(0.7);
  --scrollbar:  #cdd5cb;
}

/* ── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}
main { flex: 1; }
img, canvas { display: block; max-width: 100%; }

/* ── CONTAINER ───────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 600px) { .container { padding: 0 20px; } }
@media (min-width: 900px) { .container { padding: 0 28px; } }

/* ── HEADER ──────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  gap: 12px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 0;
}
.logo-icon { font-size: 20px; line-height: 1; flex-shrink: 0; }
.logo-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}
.logo-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 8px;
  white-space: nowrap;
  display: none;
}
@media (min-width: 480px) { .logo-label { display: block; } }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.main-nav a:hover { color: var(--text); background: var(--surface2); }

/* ── THEME TOGGLE ────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.toggle-icon { font-size: 14px; line-height: 1; }
#toggle-label { display: none; }
@media (min-width: 600px) { #toggle-label { display: inline; } }

/* ── PROJECT SUB-NAV ─────────────────────────────────────── */
.project-subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.project-subnav::-webkit-scrollbar { display: none; }
.subnav {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 4px;
  /* allow sub-nav to use container width */
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 600px) { .subnav { padding: 0 20px; } }
@media (min-width: 900px) { .subnav { padding: 0 28px; } }

.subnav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.subnav-item:hover { color: var(--text); }
.subnav-item--active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── HOME HERO ───────────────────────────────────────────── */
.home-hero {
  padding: 36px 0 28px;
  position: relative;
  overflow: hidden;
}
@media (min-width: 600px) { .home-hero { padding: 56px 0 40px; } }
@media (min-width: 900px) { .home-hero { padding: 80px 0 56px; } }

.home-hero::before {
  content: '';
  position: absolute;
  top: -180px; right: -180px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.08) 0%, transparent 68%);
  pointer-events: none;
}

.home-hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 7vw, 54px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.hero-title em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent), #52b788);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 460px;
  line-height: 1.65;
}
@media (min-width: 600px) { .hero-sub { font-size: 15px; } }

/* Hero visual icon grid */
.hero-visual {
  position: relative;
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  display: none;
}
@media (min-width: 760px) { .hero-visual { display: block; } }

.city-icon-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  position: relative;
  z-index: 1;
}
.city-icon-item {
  width: 50px; height: 50px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  animation: floatIn 0.5s ease both;
  animation-delay: var(--delay, 0s);
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(8px) scale(0.88); }
  to   { opacity: 1; transform: none; }
}
.hero-pulse--center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  pointer-events: none;
}

/* Hero stats bar */
.hero-stats {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero-stat {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 14px 8px;
}
@media (min-width: 600px) { .hero-stat { padding: 18px 12px; } }

.hero-stat-val {
  font-family: var(--font-display);
  font-size: clamp(18px, 4vw, 30px);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 480px) { .hero-stat-label { font-size: 11px; } }

.hero-stat-sep {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── PROJECT HERO ────────────────────────────────────────── */
.project-hero {
  padding: 20px 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 600px) { .project-hero { padding: 32px 0 24px; } }
@media (min-width: 900px) { .project-hero { padding: 44px 0 32px; } }

.back-link {
  display: inline-block;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 12px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.project-hero-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.project-hero-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }
.project-hero-inner h1 {
  font-family: var(--font-display);
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 800;
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}
.project-hero-inner p { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.project-meta { display: flex; gap: 6px; flex-wrap: wrap; }

.meta-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.meta-badge.ok       { color: var(--ok);       border-color: rgba(82,183,136,0.4); }
.meta-badge.warn     { color: var(--warn);     border-color: rgba(244,162,97,0.4); }
.meta-badge.critical { color: var(--critical); border-color: rgba(230,57,70,0.4); }

/* ── SECTION TITLES ──────────────────────────────────────── */
.section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.section-title-large {
  font-family: var(--font-display);
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.section-sub { font-size: 13px; color: var(--text-muted); }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-header .section-title { margin-bottom: 0; }
.section-link {
  font-size: 12px; font-weight: 700;
  color: var(--accent); text-decoration: none; white-space: nowrap;
}
.section-link:hover { color: var(--ok); }

/* ── DASHBOARD LAYOUT ────────────────────────────────────── */
.dashboard-section { padding: 16px 0 40px; }
@media (min-width: 600px) { .dashboard-section { padding: 24px 0 48px; } }
@media (min-width: 900px) { .dashboard-section { padding: 32px 0 60px; } }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
  }
}
@media (min-width: 1100px) {
  .dashboard-grid { grid-template-columns: 320px 1fr; }
}

/* ── PANELS ──────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
@media (min-width: 600px) { .panel-header { padding: 13px 16px; } }

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  padding-top: 2px;
}

/* History-Controls: Tabs + Custom-Range untereinander, ab 700px nebeneinander */
.history-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
@media (min-width: 700px) {
  .history-controls {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

.refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, transform 0.2s;
}
.refresh-btn:hover { color: var(--text); border-color: var(--accent); }
.refresh-btn.spinning { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SENSOR LIST ─────────────────────────────────────────── */
.sensor-list {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}
@media (min-width: 900px) { .sensor-list { max-height: 500px; } }

.sensor-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px 54px;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  min-height: 44px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
@media (max-width: 479px) {
  .sensor-item { grid-template-columns: minmax(0, 1fr) 36px 50px; gap: 6px; }
}
.sensor-item:hover { transform: translateX(2px); border-color: rgba(var(--accent-rgb),0.3); }
.sensor-item.ok       { border-left-color: var(--ok); }
.sensor-item.warn     { border-left-color: var(--warn); }
.sensor-item.critical { border-left-color: var(--critical); }
.sensor-item.unknown  { border-left-color: var(--unknown); }
.sensor-item--active  {
  background: rgba(var(--accent-rgb),0.07) !important;
  border-color: rgba(var(--accent-rgb),0.35) !important;
  border-left-color: var(--accent) !important;
}
.sensor-item-avg {
  margin-top: 4px;
  border-top: 1px dashed var(--border);
  background: rgba(45, 138, 85, 0.08);
  border-left-color: #2d8a55 !important;
  font-style: italic;
}
.sensor-item-avg .sensor-label {
  color: var(--text-muted);
  font-size: 0.82em;
  letter-spacing: 0.02em;
}

.sensor-label-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}
.sensor-label {
  font-size: 12px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sensor-time {
  font-size: 10px; color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sensor-time--stale { color: var(--warn); font-weight: 600; }

.sensor-bar-wrap { width: 100%; flex-shrink: 0; }
.sensor-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sensor-bar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

.sensor-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sensor-value.ok       { color: var(--ok); }
.sensor-value.warn     { color: var(--warn); }
.sensor-value.critical { color: var(--critical); }
.sensor-value.unknown  { color: var(--unknown); }

/* Pegelseite: neutrale Farbe ohne Warnschwellen */
/* Winterdienst: breitere Wertspalte für Zustandstext */
.sensor-list--winter .sensor-item {
  grid-template-columns: minmax(0, 1fr) 120px;
}
@media (max-width: 479px) {
  .sensor-list--winter .sensor-item { grid-template-columns: minmax(0, 1fr) 100px; }
}
.sensor-value--winter {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
/* KPI-Grid Winter */
.detail-current-grid--winter {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}
.detail-current-grid--winter .detail-kpi {
  flex: 0 0 auto;
  min-width: 110px;
}
.detail-current-grid--winter .detail-kpi--wide {
  flex: 1 1 160px;
}

/* Pegelseite */
.sensor-item.pegel-neutral  { border-left-color: #4895ef; }
.sensor-value.pegel-neutral { color: #4895ef; }
.sensor-list--pegel .sensor-item {
  grid-template-columns: minmax(0, 1fr) 90px;
}
@media (max-width: 479px) {
  .sensor-list--pegel .sensor-item { grid-template-columns: minmax(0, 1fr) 82px; }
}

/* KPI-Grid für Pegelseite: Pegel-Kachel groß, Standort daneben */
.detail-current-grid--pegel {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-start;
  width: fit-content;
  max-width: 100%;
}
.detail-current-grid--pegel .detail-kpi {
  flex: 0 0 auto;
  width: auto;
  min-width: 100px;
  max-width: 200px;
}
.detail-current-grid--pegel .detail-kpi-val {
  font-size: clamp(18px, 3.5vw, 24px);
  white-space: nowrap;
}

/* ── MAP ─────────────────────────────────────────────────── */
.panel-map { display: flex; flex-direction: column; }
#map {
  flex: 1;
  min-height: 260px;
  width: 100%;
}
@media (min-width: 600px)  { #map { min-height: 360px; } }
@media (min-width: 900px)  { #map { min-height: 460px; } }

.panel-map--full #map { min-height: 300px; }
@media (min-width: 600px)  { .panel-map--full #map { min-height: 420px; } }
@media (min-width: 900px)  { .panel-map--full #map { min-height: 520px; } }

.leaflet-container { background: var(--bg) !important; }
[data-theme="dark"] .leaflet-tile { filter: var(--map-filter) !important; }

.leaflet-popup-content-wrapper {
  background: var(--surface2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border2) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2) !important;
  border-radius: 10px !important;
}
.leaflet-popup-tip { background: var(--surface2) !important; }

.popup-name { font-family: var(--font-display); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.popup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.popup-metric { background: var(--surface); border-radius: 7px; padding: 7px 9px; }
.popup-metric-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 2px; }
.popup-metric-val { font-family: var(--font-mono); font-size: 15px; font-weight: 500; }
.popup-metric-unit { font-size: 10px; color: var(--text-muted); }
.popup-action {
  display: block; width: 100%; padding: 7px;
  background: rgba(var(--accent-rgb),0.1);
  border: 1px solid rgba(var(--accent-rgb),0.3);
  border-radius: 7px; color: var(--ok);
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  cursor: pointer; text-align: center; transition: background 0.15s;
}
.popup-action:hover { background: rgba(var(--accent-rgb),0.2); }

/* ── RANGE TABS ──────────────────────────────────────────── */
.range-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.range-tabs::-webkit-scrollbar { display: none; }
.range-tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.range-tab:hover { color: var(--text); border-color: var(--accent); }
.range-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── CUSTOM DATE RANGE ───────────────────────────────────── */
.custom-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 6px 14px 10px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  overflow-x: auto;
  scrollbar-width: none;
}
.custom-range::-webkit-scrollbar { display: none; }
.range-arrow { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
input[type="datetime-local"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text);
  outline: none;
  min-width: 140px;
  max-width: 175px;
  width: 100%;
  flex-shrink: 1;
  transition: border-color 0.15s;
}
input[type="datetime-local"]:focus { border-color: var(--accent); }
.range-apply {
  background: var(--accent);
  border: none;
  border-radius: 7px;
  padding: 5px 13px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.range-apply:hover { opacity: 0.85; }

/* ── HISTORY CHARTS ──────────────────────────────────────── */
.history-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  transition: opacity 0.2s ease;
}
@media (min-width: 600px) {
  .history-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 14px; }
}
@media (min-width: 1100px) {
  .history-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px; }
}

.chart-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px 10px;
}
.chart-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.chart-unit { font-size: 10px; font-weight: 500; color: var(--text-muted); }
.chart-wrap { position: relative; height: 140px; }
@media (min-width: 600px) { .chart-wrap { height: 160px; } }
@media (min-width: 900px) { .chart-wrap { height: 180px; } }

/* ── SEARCH ──────────────────────────────────────────────── */
.search-wrap { flex: 1; min-width: 0; max-width: 180px; }
.sensor-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.sensor-search-input::placeholder { color: var(--text-muted); }
.sensor-search-input:focus { border-color: var(--accent); }

/* ── SUBGROUP HEADER ─────────────────────────────────────── */
.subgroup-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 2px 4px;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
}
.subgroup-header:first-child { margin-top: 0; }

/* ── DETAIL PANEL ────────────────────────────────────────── */
.detail-panel { display: none; margin-top: 16px; }
.detail-panel--open { display: block; }
.detail-panel--fadein { animation: panelFadeIn 0.3s cubic-bezier(0.22,1,0.36,1) both; }
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.detail-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
  overflow: hidden;
}
.detail-panel-icon { font-size: 17px; flex-shrink: 0; }
.detail-panel-title h2 {
  font-size: 14px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}

.detail-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  min-width: 0;
}

.detail-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.detail-close:hover { color: var(--critical); border-color: var(--critical); }

.detail-current { padding: 10px 14px 0; }
.detail-current-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  align-items: stretch;
}
.detail-kpi {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--kpi-color, var(--accent));
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.detail-kpi-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 2px;
}
.detail-kpi-val {
  font-family: var(--font-display);
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.detail-kpi-unit { font-size: 11px; color: var(--text-muted); margin-left: 2px; font-weight: 400; }
.detail-kpi-avg {
  background: rgba(45, 138, 85, 0.08);
  border-style: dashed;
}
.detail-kpi-avg .detail-kpi-label {
  font-style: italic;
}

/* ── TOPICS SECTION ──────────────────────────────────────── */
.topics-section { padding: 0 0 40px; }
@media (min-width: 600px) { .topics-section { padding: 0 0 56px; } }

.topics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: stretch;
}
@media (min-width: 600px) { .topics-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (min-width: 960px) { .topics-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; } }

.topics-grid--single {
  grid-template-columns: 1fr;
  max-width: 480px;
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.topic-card--active { border-color: rgba(var(--accent-rgb),0.3); cursor: pointer; }
.topic-card--active:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 32px rgba(0,0,0,0.12);
}
.topic-card--featured { grid-column: span 1; }
@media (min-width: 600px) { .topic-card--featured { grid-column: span 2; } }
@media (min-width: 960px) { .topic-card--featured { grid-column: span 2; } }

.topic-card-header { display: flex; align-items: center; justify-content: space-between; }
.topic-icon { font-size: 26px; line-height: 1; }
.topic-status {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20px;
}
.topic-status--live {
  display: flex; align-items: center; gap: 5px;
  background: rgba(var(--accent-rgb),0.12);
  color: var(--ok);
  border: 1px solid rgba(var(--accent-rgb),0.3);
}
.topic-status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.65); }
}

.topic-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 800;
  color: var(--text); line-height: 1.2;
}
.topic-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; flex: 1; }

.topic-kpis {
  display: flex; gap: 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.topic-kpi {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 7px 4px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.topic-kpi:last-child { border-right: none; }
.topic-kpi-val {
  font-family: var(--font-display);
  font-size: clamp(12px, 2.5vw, 15px);
  font-weight: 800; color: var(--text); line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.topic-kpi-label {
  font-size: 9px; color: var(--text-muted); margin-top: 2px;
  text-align: center; white-space: nowrap;
}

.topic-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--ok);
  padding-top: 4px; border-top: 1px solid var(--border); margin-top: auto;
}
.topic-arrow { transition: transform 0.2s; }
.topic-card--active:hover .topic-arrow { transform: translateX(4px); }

/* ── PROJECTS GRID ───────────────────────────────────────── */
.projects-section { padding: 0 0 48px; }
.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 480px) { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 760px) { .projects-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1100px){ .projects-grid { grid-template-columns: repeat(4, 1fr); } }

.project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent, var(--accent));
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  min-width: 0;
}
.project-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.project-card-icon { font-size: 24px; flex-shrink: 0; }
.project-card-body { flex: 1; min-width: 0; }
.project-card-body h3 {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 2px;
}
.project-card-body p { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.project-card-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.project-card-val {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 500;
  background: var(--surface2);
  border-radius: 4px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.project-card-val.ok       { color: var(--ok);       border-color: rgba(82,183,136,0.3); }
.project-card-val.warn     { color: var(--warn);     border-color: rgba(244,162,97,0.3); }
.project-card-arrow {
  color: var(--text-muted); flex-shrink: 0; font-size: 14px;
  transition: transform 0.15s, color 0.15s;
}
.project-card:hover .project-card-arrow { color: var(--card-accent, var(--accent)); transform: translateX(3px); }

/* ── ABOUT SECTION ───────────────────────────────────────── */
.about-section { padding: 0 0 48px; }
.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding-top: 28px;
}
@media (min-width: 600px) { .about-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; } }
.about-card { display: flex; flex-direction: column; gap: 7px; }
.about-icon { font-size: 24px; line-height: 1; }
.about-card h3 { font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.about-card p  { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── HOME HERO VISUAL ────────────────────────────────────── */
.home-hero-inner { margin-bottom: 24px; }

/* ── COMPARE PAGE ────────────────────────────────────────── */
.compare-controls {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.compare-control-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.compare-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  padding-top: 5px; min-width: 72px; flex-shrink: 0;
}
@media (max-width: 599px) { .compare-label { min-width: 100%; padding-top: 0; } }

.compare-chart-wrap {
  padding: 14px;
  height: 280px;
  position: relative;
}
@media (min-width: 600px) { .compare-chart-wrap { height: 340px; } }
@media (min-width: 900px) { .compare-chart-wrap { height: 400px; } }

.compare-table-wrap { overflow-x: auto; }
.compare-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  min-width: 480px;
}
.compare-table th {
  padding: 9px 12px; text-align: left;
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.compare-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--surface2); }
.td-mono { font-family: var(--font-display); font-weight: 600; font-size: 12px; }
.td-muted { color: var(--text-muted); font-weight: 400; }

/* ── SENSOR DETAIL PANEL HISTORY ─────────────────────────── */
.panel-history {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ── FOOTER ──────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 16px 0; }
.site-footer p { color: var(--text-muted); font-size: 12px; text-align: center; }

/* ── LOADING ─────────────────────────────────────────────── */
.loading-spinner {
  text-align: center; color: var(--text-muted);
  padding: 28px 16px; font-size: 13px;
}

/* ── PULSE ANIMATION ─────────────────────────────────────── */
.pulse-dot {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
}
.pulse-ring {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 16px; height: 16px;
  border: 2px solid var(--accent); border-radius: 50%;
  animation: pulseRing 2.4s ease-out infinite; opacity: 0;
}
.pulse-ring:nth-child(2) { animation-delay: 1.2s; }
@keyframes pulseRing {
  0%   { width: 16px; height: 16px; opacity: 0.7; }
  100% { width: 80px; height: 80px; opacity: 0; }
}

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

/* ── TRANSITIONS ─────────────────────────────────────────── */
.panel, .sensor-item, .project-card, .topic-card, .meta-badge {
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

/* ── LOGIN ───────────────────────────────────────────────── */
.login-section {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  text-align: center;
}

.login-logo {
  margin-bottom: 20px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 6px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 24px;
}

.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid var(--critical);
  color: var(--critical);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 20px;
  text-align: left;
}

.login-form {
  text-align: left;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s;
  outline: none;
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-pw-wrap {
  position: relative;
}

.login-pw-wrap input {
  padding-right: 44px;
}

.login-pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.login-pw-toggle:hover { opacity: 1; }

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s, transform 0.1s;
}

.login-btn:hover  { opacity: 0.9; }
.login-btn:active { transform: scale(0.98); }

.login-btn--outline {
  display: block;
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}
.login-btn--outline:hover { background: var(--surface2); opacity: 1; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 16px 0;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-footer {
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .login-card { padding: 28px 20px 24px; }
}

/* ── ADMIN: Benutzer-/Gruppenformulare ──────────────────────── */
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 16px;
  padding: 14px 16px;
  align-items: end;
}
.admin-form-grid .login-field { margin-bottom: 0; }
.admin-form-grid select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
}
.admin-form-submit { display: flex; align-items: flex-end; }
.admin-form-submit .range-apply { width: 100%; }

.admin-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}
.admin-checkbox-list--row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding-top: 6px;
}
.admin-checkbox-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}
.admin-actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Logout-Button im Header ─────────────────────────────── */
.logout-btn {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.logout-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
