/* Atisk Plattform – Design-System (Grün-Palette, Segoe UI) */
:root {
  --gruen-900: #14301b;
  --gruen-800: #1d4023;
  --gruen-700: #2c5f2d;
  --gruen-500: #4c8c2b;
  --gruen-300: #97bc62;
  --gruen-100: #e8f0e0;
  --creme: #f7f8f4;
  --weiss: #ffffff;
  --text: #21301f;
  --text-muted: #5f6f5c;
  --linie: #dde5d6;
  --warn: #b85042;
  --gelb: #e0a800;
  --radius: 10px;
  --schatten: 0 1px 3px rgba(20, 48, 27, .08), 0 4px 16px rgba(20, 48, 27, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--creme);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--gruen-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 650; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 650; margin: 0 0 10px; }
.untertitel { color: var(--text-muted); margin: 0 0 22px; }

/* ---------- App-Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--gruen-900), var(--gruen-800));
  color: #dfe9d8; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo {
  font-size: 22px; font-weight: 700; color: var(--weiss);
  padding: 22px 20px 4px; letter-spacing: .5px;
}
.sidebar .logo span { color: var(--gruen-300); }
.sidebar .betrieb-name {
  padding: 0 20px 18px; font-size: 12.5px; color: #a8bda0;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 10px;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.nav a {
  color: #cfdec6; padding: 9px 12px; border-radius: 8px;
  font-size: 14.5px; display: flex; gap: 10px; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.aktiv { background: var(--gruen-500); color: var(--weiss); font-weight: 600; }
.sidebar .fuss {
  margin-top: auto; padding: 14px 20px; font-size: 12.5px; color: #93a98b;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar .fuss a { color: #c4d6ba; }
/* min-width:0 ist Pflicht: ohne das weigert sich .inhalt als Flex-Kind, unter die
   Inhaltsbreite zu schrumpfen. Ein breites Kind (Zeitstrahl, weite Tabelle) blaeht
   dann die ganze Seite auf, statt in seinem eigenen overflow-x zu scrollen -
   rechts stehende Bedienelemente rutschen aus dem Fenster. */
.inhalt { flex: 1; min-width: 0; padding: 30px 38px 60px; max-width: 1600px; }

/* ---------- Karten/Boxen ---------- */
.kachel {
  background: var(--weiss); border: 1px solid var(--linie);
  border-radius: var(--radius); box-shadow: var(--schatten); padding: 20px;
}
.kachel + .kachel { margin-top: 18px; }
.raster { display: grid; gap: 16px; }
/* Im Raster regelt der grid-gap den Abstand; der Geschwister-Abstand wuerde
   alle Kacheln ausser der ersten nach unten schieben (unbuendige Kanten). */
.raster > .kachel + .kachel { margin-top: 0; }
.raster.k4 { grid-template-columns: repeat(4, 1fr); }
.raster.k3 { grid-template-columns: repeat(3, 1fr); }
.raster.k2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .raster.k4, .raster.k3 { grid-template-columns: repeat(2, 1fr); } }

/* Wachstumskurve links, Schädlings-/Unkraut-Panel rechts; bricht schmal um */
.wachstum-split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; align-items: start; }
.wachstum-split > div { min-width: 0; }   /* Canvas darf die Spalte nicht aufblähen */
@media (max-width: 1000px) { .wachstum-split { grid-template-columns: 1fr; } }

/* Schädling-/Unkraut-Detail (Overlay) */
.sr-overlay { position: fixed; inset: 0; background: rgba(20,28,18,.55); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.sr-overlay.auf { display: flex; }
.sr-dialog { background: var(--weiss); border-radius: var(--radius); max-width: 560px; width: 100%;
  max-height: 86vh; overflow-y: auto; box-shadow: var(--schatten); padding: 22px 24px; }
/* Restrisiko-Overlay scharf (pixelgenau) auf dem Satellitenbild */
.restrisiko-overlay { image-rendering: pixelated; image-rendering: crisp-edges; }

.kpi .wert { font-size: 30px; font-weight: 700; color: var(--gruen-700); }
.kpi .label { font-size: 13px; color: var(--text-muted); }

/* ---------- Tabellen ---------- */
/* border-collapse: separate (statt collapse), damit die Kopf-Unterkante beim Sticky-
   Scrollen mitwandert — bei collapse bleibt der Rahmen an der alten Position hängen. */
table.liste { width: 100%; border-collapse: separate; border-spacing: 0; }
table.liste th {
  text-align: left; font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 2px solid var(--linie);
}
/* Spaltenköpfe bleiben beim Scrollen oben stehen (wie eine fixierte Zeile in Excel).
   Seiten mit eigener Sticky-Leiste (z. B. Parameter: Speichern-Leiste) setzen
   --tabelle-kopf-top auf deren Höhe, damit die Köpfe DARUNTER andocken.
   In horizontalen Scroll-Wrappern (overflow-x) wirkt Sticky nicht — dort bleibt
   die Tabelle unverändert. */
table.liste thead th {
  position: sticky; top: var(--tabelle-kopf-top, 0px);
  background: var(--creme); z-index: 3;
}
.kachel table.liste thead th, .sr-dialog table.liste thead th { background: var(--weiss); }
table.liste td { padding: 9px 10px; border-bottom: 1px solid var(--linie); }
table.liste tr:hover td { background: var(--gruen-100); }

/* ---------- Status-Pillen ---------- */
.pille {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pille.gruen { background: var(--gruen-100); color: var(--gruen-700); }
.pille.grau { background: #eceeea; color: var(--text-muted); }
.pille.gelb { background: #fdf3d7; color: #8a6d00; }
.pille.rot { background: #fbe4e1; color: var(--warn); }

/* ---------- Formulare & Buttons ---------- */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--linie);
  border-radius: 8px; font: inherit; background: var(--weiss); color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gruen-300); border-color: var(--gruen-500);
}
/* Einheitliches Suchfeld (überall gleiches Aussehen & Verhalten): Lupen-Icon links.
   Selektor `input.suche` (gleiche Spezifität wie input[type=search], danach notiert). */
input.suche {
  -webkit-appearance: none; appearance: none;
  max-width: 300px; padding: 9px 12px 9px 34px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%238a8f86" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><line x1="20.5" y1="20.5" x2="16.5" y2="16.5"/></svg>');
  background-repeat: no-repeat; background-position: 11px center;
}
input.suche::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
label { font-size: 13px; font-weight: 600; color: var(--text-muted); display: block; margin: 12px 0 4px; }
.btn {
  display: inline-block; background: var(--gruen-700); color: var(--weiss);
  border: none; border-radius: 8px; padding: 10px 18px; font: inherit;
  font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--gruen-500); text-decoration: none; color: var(--weiss); }
.btn.sekundaer { background: var(--weiss); color: var(--gruen-700); border: 1px solid var(--gruen-500); }
.btn.klein { padding: 6px 12px; font-size: 13px; }
.btn-link {
  background: none; border: none; padding: 2px 4px; font: inherit; cursor: pointer;
  color: var(--gruen-700); text-decoration: underline; text-underline-offset: 2px;
}
.btn-link:hover { color: var(--gruen-500); }
.fehlerbox {
  background: #fbe4e1; color: var(--warn); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}

/* ---------- Oeffentliche Seiten ---------- */
.public-bg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--gruen-900) 0%, var(--gruen-700) 60%, var(--gruen-500) 100%);
  padding: 30px;
}
.public-card {
  background: var(--weiss); border-radius: 16px; padding: 38px 42px;
  width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.public-card .logo { font-size: 30px; font-weight: 700; color: var(--gruen-800); }
.public-card .logo span { color: var(--gruen-500); }
.landing-hero { max-width: 760px; color: var(--weiss); text-align: center; }
.landing-hero .logo { font-size: 54px; font-weight: 700; letter-spacing: 1px; }
.landing-hero .logo span { color: var(--gruen-300); }
.landing-hero h1 { font-size: 30px; font-weight: 600; margin: 10px 0 14px; color: var(--weiss); }
.landing-hero p { font-size: 17px; color: #e3ecd9; margin: 0 0 30px; }
.landing-punkte {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin: 34px 0; text-align: left;
}
.landing-punkte div {
  background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px; padding: 16px; font-size: 14px; color: #eef4e7;
}
.landing-punkte b { display: block; margin-bottom: 4px; color: var(--weiss); }

/* ---------- Schlag-Karte (SVG) ---------- */
.karte-wrap { background: #f0f3ec; border-radius: var(--radius); overflow: hidden; }
.karte-wrap svg { display: block; width: 100%; height: auto; }
.feld-poly { fill: var(--gruen-300); stroke: var(--gruen-800); stroke-width: 1; opacity: .75; cursor: pointer; }
.feld-poly:hover { fill: var(--gruen-500); opacity: 1; }
.feld-poly.ohne-grid { fill: #c9cfc2; }

/* ---------- Raster-Viewer ---------- */
.viewer { display: grid; grid-template-columns: 1fr 300px; gap: 18px; }
@media (max-width: 1000px) { .viewer { grid-template-columns: 1fr; } }
.viewer .bild {
  background: #2a3328; border-radius: var(--radius); min-height: 420px;
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.viewer .bild img { max-width: 100%; max-height: 560px; image-rendering: pixelated; }
.legende { height: 12px; border-radius: 6px; margin: 8px 0 4px;
  background: linear-gradient(90deg,#a50026,#f46d43,#ffffbf,#a6d96a,#006837); }
.legende-werte { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* ---------- Pipeline ---------- */
.stationen { display: flex; align-items: center; gap: 0; margin: 10px 0 18px; flex-wrap: wrap; }
.station { display: flex; align-items: center; }
.station .punkt {
  background: var(--gruen-100); color: var(--gruen-700); border: 2px solid var(--gruen-300);
  border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 600;
}
.station .pfeil { color: var(--gruen-300); padding: 0 8px; font-size: 18px; }
details.ds-log { border: 1px solid var(--linie); border-radius: 8px; margin-bottom: 8px; background: var(--weiss); }
details.ds-log summary {
  cursor: pointer; padding: 10px 14px; display: flex; gap: 12px; align-items: center;
  list-style: none; flex-wrap: wrap;
}
details.ds-log summary::-webkit-details-marker { display: none; }
.ds-log .log-zeilen { padding: 4px 16px 12px; border-top: 1px solid var(--linie); }
.ds-log .log-zeilen div { font-size: 13.5px; padding: 4px 0; color: var(--text-muted); }
.ds-log .log-zeilen b { color: var(--gruen-700); }
.mono { font-family: Consolas, monospace; font-size: 13px; }

/* ---------- Icon-Badges (statt Emojis) ---------- */
.icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--gruen-100); color: var(--gruen-700);
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.icon-badge.klein { width: 26px; height: 26px; font-size: 10.5px; border-radius: 7px; }

/* ---------- Drop-Zone ---------- */
.dropzone {
  border: 2px dashed var(--gruen-300); border-radius: var(--radius);
  background: var(--gruen-100); padding: 44px 24px; text-align: center;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.aktiv { background: #dcebc9; border-color: var(--gruen-500); }
.dropzone .gross { font-size: 17px; font-weight: 650; color: var(--gruen-800); }
.dropzone .klein { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Suche ---------- */
.suchfeld { max-width: 340px; }

/* ---------- Leaflet-Karte ---------- */
#karte.leaflet-container, #wkarte.leaflet-container { height: 520px; border-radius: var(--radius); }

/* ---------- Operations-Center-Layout (Liste links, Karte rechts) ---------- */
.oc-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .oc-layout { grid-template-columns: 1fr; } }
.oc-liste { padding: 14px; }
/* Im Grid stehen die Kacheln nebeneinander – kein vertikaler Abstand zwischen ihnen. */
.oc-layout > .kachel + .kachel { margin-top: 0; }
.oc-scroll { max-height: 640px; overflow-y: auto; }
.oc-layout #karte.leaflet-container { height: 700px; }
.oc-zeile {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-bottom: 1px solid var(--linie); border-radius: 8px;
}
.oc-zeile:hover { background: var(--gruen-100); }
.oc-zeile.oc-aktiv { background: var(--gruen-100); box-shadow: inset 0 0 0 2px var(--gruen-500); }
.leaflet-container .feld-tooltip { font-family: "Segoe UI", sans-serif; }

/* ---------- Schnittstellen ---------- */
.quelle-karte { display: flex; gap: 14px; }
.quelle-karte .icon { font-size: 30px; }
.quelle-karte h3 { margin: 0 0 2px; font-size: 16px; }
.quelle-karte p { margin: 4px 0 10px; font-size: 13.5px; color: var(--text-muted); }

/* ---------- Mehrfach-Auswahl-Dropdown „Verbotene Produkte" ---------- */
/* Geschlossen wie ein <select> (gleiche Größe wie Wunsch-Produkt), Pfeil klappt auf/zu. */
.vp { position: relative; display: inline-block; }
.vp-trigger {
  width: 170px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 3px 6px; font: inherit; font-size: 13px; line-height: 1.5;
  background: #fff; color: var(--text); border: 1px solid var(--linie);
  border-radius: 4px; cursor: pointer; text-align: left;
}
.vp-trigger:hover { border-color: var(--gruen-300); }
.vp.open .vp-trigger { border-color: var(--gruen-500); box-shadow: 0 0 0 2px var(--gruen-100); }
.vp-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1 1 auto; }
.vp-label:empty::before { content: "\00a0"; }
.vp-arrow { flex: none; font-size: 10px; color: var(--text-muted); transition: transform .12s; }
.vp.open .vp-arrow { transform: rotate(180deg); }
.vp-panel {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; z-index: 30;
  min-width: 100%; width: max-content; max-width: 300px; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid var(--linie); border-radius: 4px;
  box-shadow: var(--schatten); padding: 3px;
}
.vp.open .vp-panel { display: block; }
.vp-opt {
  display: block; padding: 5px 9px;
  font-size: 13px; border-radius: 3px; cursor: pointer; user-select: none;
}
.vp-opt:hover { background: var(--gruen-100); }
.vp-opt.aktiv, .vp-opt.aktiv:hover { background: #0b70d1; color: #fff; }
.vp-opt input { display: none; }
.vp-opt span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
