:root {
  --kopf: 60px;          /* Höhe der Kopfzeile: Seitenleiste und Log-Karte rechnen damit */
  --bg: #f3f5f2;
  --card: #ffffff;
  --sidebar: #eef2ec;
  --text: #1e281e;
  --muted: #6c786c;
  --border: #dde4dc;
  --primary: #2e7d32;
  --primary-soft: #e3f1e4;
  --primary-text: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #b26a00;
  --ok: #2e7d32;
  --log-bg: #111713;
  --log-text: #d6e0d6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  /* Wachstum eines Feldes in zehn Stufen: frisch gesetzt hell und zart, je reifer desto
     satter und dunkler das Grün. Reif ist das dunkelste Grün mit hellem Rand. */
  --w0: #d3e9a6;
  --w1: #c4df9a;
  --w2: #b6d58f;
  --w3: #a7cb83;
  --w4: #98c178;
  --w5: #8ab76c;
  --w6: #7bad61;
  --w7: #6ca355;
  --w8: #5e994a;
  --w9: #4f8f3e;
  --reif: #1f5c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131713;
    --card: #1b211b;
    --sidebar: #171c17;
    --text: #e6ece6;
    --muted: #93a093;
    --border: #2b342b;
    --primary-soft: #1f3321;
    --danger-soft: #3a1f1d;
    --log-bg: #0b0e0b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 16px; margin: 0; line-height: 1.2; }
h2 { font-size: 15px; margin: 0 0 12px; }
button {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
button:hover { filter: brightness(0.96); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
button.danger { color: var(--danger); }
button.small { padding: 3px 9px; font-size: 12px; }
input, select, textarea {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
/* Auswahllisten ohne Browser-Optik: eigener Pfeil, gleiche Höhe wie Knöpfe */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236c786c' stroke-width='1.8' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
}
select.small { padding: 3px 26px 3px 8px; font-size: 12px; }
select option { background: var(--card); color: var(--text); }
@media (prefers-color-scheme: dark) {
  select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2393a093' stroke-width='1.8' stroke-linecap='round'/></svg>"); }
}

/* Eigene Auswahllisten (siehe app.js, enhanceSelect); das Original bleibt unsichtbar im Formular */
.dd { position: relative; display: inline-block; vertical-align: middle; min-width: 0; }
.dd .dd-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: 0; bottom: 0; }
.dd-btn {
  display: inline-flex; align-items: center; gap: 7px; width: 100%;
  padding: 6px 30px 6px 9px; text-align: left; white-space: nowrap; position: relative;
}
.dd.small .dd-btn { padding: 3px 26px 3px 8px; font-size: 12px; }
.dd-btn .dd-text { overflow: hidden; text-overflow: ellipsis; }
.dd-chevron {
  position: absolute; right: 10px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(45deg);
  transition: transform 0.15s;
}
.dd.open .dd-chevron { transform: rotate(-135deg); margin-top: -1px; }
.dd.open .dd-btn { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dd-menu {
  position: absolute; z-index: 900; left: 0; top: calc(100% + 4px); min-width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); padding: 4px; overflow: hidden;
}
.dd-menu.up { top: auto; bottom: calc(100% + 4px); }
.dd-search { display: block; width: 100%; margin: 2px 0 4px; padding: 5px 8px; font-size: 13px; }
.dd-list { max-height: 300px; overflow-y: auto; }
.dd-item {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none;
  padding: 6px 9px; border-radius: 6px; text-align: left; white-space: nowrap; font-size: 13px;
}
.dd.small .dd-item { padding: 4px 8px; font-size: 12px; }
.dd-item:hover, .dd-item:focus { background: var(--primary-soft); outline: none; filter: none; }
.dd-item.active { font-weight: 600; }
.dd-item.active::after { content: '✓'; margin-left: auto; color: var(--primary); }
.dd-ico { display: inline-flex; align-items: center; width: 24px; height: 18px; flex: 0 0 auto; }
.dd-ico .sicon { margin: 0; }
.dd-ico:empty { display: none; }
.dd-emoji { font-size: 14px; }
.dd-empty { padding: 6px 9px; }
.inline .dd { flex: 1 1 180px; }
.map-assign .dd { max-width: 280px; }
#account-select + .dd, .brand .dd { margin-left: 8px; max-width: 240px; }
.player-stats .dd, .settings .dd { min-width: 160px; }

/* Upjers-Portalkonten */
.portal { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.portal h3 { font-size: 14px; margin: 0; }
.stats-chart svg { width: 100%; height: 70px; display: block; }
.stats-chart { margin-bottom: 8px; }
a.button, label.button { display: inline-block; text-decoration: none; cursor: pointer; }
h3.sub { font-size: 13px; margin: 6px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.portal .card-head { margin-bottom: 6px; }
.portal-actions { display: grid; gap: 8px; margin-top: 8px; }
.portal-actions .inline input { flex: 1 1 140px; }
#portal-form { margin-top: 6px; }
#portal-form input { flex: 1 1 160px; }

/* Eigener Tooltip (siehe app.js, data-tip) */
#tip {
  position: fixed;
  z-index: 1000;
  max-width: 340px;
  padding: 7px 10px;
  border-radius: 7px;
  background: #1e281e;
  color: #f2f6f2;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-line;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
#tip.multi::first-line { font-weight: 600; }
@media (prefers-color-scheme: dark) {
  #tip { background: #2c372c; border: 1px solid #3c483c; }
}

/* Sortierbare Spaltenköpfe */
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th[data-sort]::after { content: ''; display: inline-block; width: 0; margin-left: 4px; opacity: 0.5; }
th[data-sort].sorted::after { content: '▲'; width: auto; font-size: 9px; opacity: 1; color: var(--primary); }
th[data-sort].sorted.desc::after { content: '▼'; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); font-weight: normal; }

/* ---- Kopfzeile ------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
#account-select { margin-left: 8px; max-width: 220px; }
.pill.queued { border-color: var(--warn); color: var(--warn); }
.logo { font-size: 22px; }
.topbar-status { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: center; flex-wrap: wrap; }
.player-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.player-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.controls { display: flex; gap: 8px; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
}
.pill.running { border-color: var(--ok); color: var(--ok); background: var(--primary-soft); }
.pill.sleeping { border-color: var(--primary); color: var(--primary); }
.pill.stopped { color: var(--muted); }
.pill.stopping { color: var(--warn); border-color: var(--warn); }
.pill.error, .pill.blocked { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.pill.warn { border-color: var(--warn); color: var(--warn); }

/* ---- Layout ---------------------------------------------------------- */
.shell { display: flex; min-height: calc(100vh - var(--kopf)); }
.sidebar {
  width: 210px;
  flex: none;
  padding: 14px 10px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: var(--kopf);
  height: calc(100vh - var(--kopf));
}
.sidebar button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.sidebar button span { width: 20px; text-align: center; }
.sidebar button:hover { background: var(--card); filter: none; }
.sidebar button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  text-align: center;
  line-height: 18px;
}
.content { flex: 1; min-width: 0; padding: 18px 22px 40px; max-width: 1900px; }
.tab { display: none; flex-direction: column; gap: 16px; }
.tab.active { display: flex; }
/* Ein Bereich aus mehreren Abschnitten (Markt & Laden): gleicher Abstand wie zwischen Karten */
.tab.active + .tab.active { margin-top: 16px; }

/* Ungespeicherte Formulare: Hinweis mit Verwerfen; bei den Einstellungen bleibt die Leiste sichtbar */
.form-account { font-size: 12px; color: var(--muted); font-weight: normal; }
.draft-bar {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 10px; border-radius: 8px; font-size: 12px;
  background: color-mix(in srgb, var(--warn) 15%, transparent);
}
.draft-bar b { color: var(--warn); }
.settings-actions {
  position: sticky; bottom: 0; margin: 0 -16px -16px; padding: 10px 16px 16px;
  background: var(--card); border-top: 1px solid var(--border); border-radius: 0 0 10px 10px;
}
.goals-ignored { color: var(--muted); }
.goals-ignored .chip { padding-right: 4px; }
.goals-ignored .chip button { margin-left: 4px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 560px; }
/* Log-Karte: so hoch wie das Fenster hergibt, damit im Log selbst gescrollt wird
   und Kopfzeile, Filter und Unterreiter stehen bleiben. */
.card.fill { display: flex; flex-direction: column; height: calc(100vh - var(--kopf) - 130px); min-height: 320px; }
.card.fill .log { flex: 1; height: auto; min-height: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
/* Einklappbare Karten: der Knopf sitzt ganz rechts, der Rumpf verschwindet beim Zuklappen */
.card.foldable .card-head { flex-wrap: nowrap; align-items: flex-start; }
.card.foldable .card-head > .muted { flex: 1; min-width: 0; }
.fold-btn { flex: 0 0 auto; padding: 2px 8px; line-height: 1.2; align-self: center; }
/* Prozentfeld in Tabellen (Saatgut-Freigabe je Ziel) */
input.pct { width: 62px; text-align: right; padding: 3px 6px; font-size: 12px; }

/* Schmale Seitenleiste: nur Symbole, Beschriftung im Tooltip */
.nav-toggle { margin-top: auto; color: var(--muted); }
body.nav-schmal .sidebar { width: 58px; }
body.nav-schmal .sidebar button { justify-content: center; padding: 9px 0; gap: 0; }
body.nav-schmal .sidebar button span:not(.nav-toggle-text) { width: auto; }
body.nav-schmal .nav-toggle-text { display: none; }
/* die Beschriftung verschwindet, das Symbol und die Plakette bleiben */
body.nav-schmal .sidebar button[data-tab] { font-size: 0; }
body.nav-schmal .sidebar button[data-tab] span { font-size: 17px; }
body.nav-schmal .sidebar button[data-tab] .badge { font-size: 11px; margin-left: -8px; margin-top: -14px; padding: 0 4px; min-width: 16px; line-height: 16px; }

/* Live-Ansicht über alle Accounts: links die Gärten, rechts was ansteht */
.live-alle { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 18px; align-items: start; }
/* Accounts nebeneinander, sobald der Platz reicht; ein Garten ist 17 Felder breit */
.live-gaerten { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); gap: 14px; align-items: start; }
.live-account { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg); min-width: 0; }
.live-account.arbeitet { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.live-account header { margin-bottom: 8px; }
/* Name und Plaketten in einer Zeile, Zahlen und "was gerade läuft" darunter */
.live-kopf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-zeile2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 3px; }
.live-tut { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.live-tut .dot { width: 8px; height: 8px; border-radius: 50%; background: #22d3ee; flex: none; animation: cursor-blink 1.2s ease-in-out infinite; }
.live-gaerten-reihe { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.live-garten { margin: 0; flex: 1 1 240px; min-width: 0; max-width: 340px; }  /* figure bringt von Haus aus 40px Rand mit */
.live-garten figcaption { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.live-garten svg { display: block; width: 100%; height: auto; border-radius: 4px; background: #2f4a2a; }
/* dieselben Bausteine wie auf der großen Karte, nur kleiner: Etiketten dürfen etwas zierlicher sein */
.live-karte .label text { font-size: 0.3px; }
.live-karte svg { max-width: none; }

.live-garten .cursor-mark.busy { stroke-width: 0.34; }
.live-garten .cursor-mark.soon { stroke-width: 0.2; stroke-dasharray: 0.3 0.22; }
.live-jobs { position: sticky; top: calc(var(--kopf) + 12px); }
.live-job { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.live-job:last-child { border-bottom: 0; }
.live-job.running { color: var(--primary); }
.live-job-zeit { color: var(--muted); font-size: 12px; }
.live-job.running .live-job-zeit { color: var(--primary); }
@media (max-width: 1100px) { .live-alle { grid-template-columns: 1fr; } .live-jobs { position: static; } }
@media (prefers-reduced-motion: reduce) { .live-tut .dot { animation: none; } }

/* Karte: woran der Bot gerade arbeitet. "busy" pulsiert, "soon" ist das, was gleich drankommt. */
.map-cursor { margin: 0 0 10px; font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.map-cursor .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; animation: cursor-blink 1.2s ease-in-out infinite; }
/* Türkis, weil die Karte sonst kein Türkis benutzt: Grün, Gelb und Blau sind Feldzustände,
   Weiß ist die Umrandung geplanter Felder, Rot die des aktiven Layouts. */
.cursor-mark { fill: none; pointer-events: none; stroke: #22d3ee; }
.cursor-mark.busy { stroke-width: 0.2; animation: cursor-pulse 1s ease-in-out infinite; }
.cursor-mark.soon { stroke-width: 0.12; stroke-dasharray: 0.16 0.12; stroke-opacity: 0.7; }
.map-cursor .dot { background: #22d3ee; }
@keyframes cursor-pulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.3; } }
@keyframes cursor-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
  .cursor-mark.busy, .map-cursor .dot { animation: none; }
}

/* Stammtisch: Beiträge wie ein Chatverlauf, eigene abgesetzt */
.chat-feed { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px 2px; }
.chat-msg { display: flex; align-items: flex-start; gap: 8px; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
/* Zwergenbild des Spiels: nur der Kopf, sonst füllt die ganze Figur die Zeile */
.chat-avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; object-fit: cover; object-position: top center; background: var(--bg); border: 1px solid var(--border); }
.chat-avatar.leer { display: block; }
.chat-bubble { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.chat-msg.mine .chat-bubble { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.chat-msg header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.chat-msg header .chat-title { font-weight: 600; }
.chat-msg header button { margin-left: auto; }
.chat-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.smiley { height: 1.15em; vertical-align: -0.2em; margin: 0 0.15em; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; align-items: end; }
.chat-form input { grid-column: 1 / -1; }
.chat-form textarea { resize: vertical; min-height: 44px; }
.mail-body { margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.mail-body p:last-child { margin-bottom: 0; overflow-wrap: anywhere; }
tr.unread td { background: color-mix(in srgb, var(--primary) 6%, transparent); }
pre.raw { font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; overflow-x: auto; }
.linklike { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }

.card.folded { padding-bottom: 12px; }
.card.folded .card-head { margin-bottom: 0; align-items: center; }
.card.folded .card-head > .muted { display: none; } /* zugeklappt reicht die Überschrift */
.card.folded .fold-body { display: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.banner { margin: 0; padding: 10px 14px; border-radius: 8px; }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.info { background: var(--primary-soft); color: var(--text); }
.banner.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--text); }
.tag.advice.buy { color: var(--primary); border-color: var(--primary); }
.season-task { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.season-task.done { opacity: 0.6; }
.season-task .progress { width: 90px; }
.price-chart { width: 100%; height: auto; display: block; color: var(--text); }
.hbars { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding-top: 6px; }
.hbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; }
.hbar span { display: block; width: 100%; background: var(--border); border-radius: 3px 3px 0 0; min-height: 2px; }
.hbar.best span { background: var(--ok); }
.hbar i { font-style: normal; font-size: 9px; color: var(--muted); }
#shop tr[data-name] td:first-child { cursor: pointer; }
.tag.advice.grow { color: var(--ok); border-color: var(--ok); }
.section-title { margin: 8px 0 0; }
.quest-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.quest-reward { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.progress { display: inline-block; width: 80px; height: 6px; border-radius: 3px; background: var(--border); vertical-align: middle; overflow: hidden; margin-right: 6px; }
.progress span { display: block; height: 100%; background: var(--primary); }
.tag.source { color: var(--warn); border-color: var(--warn); margin-left: 6px; }
.tag.covered { color: var(--ok); border-color: var(--ok); }
.tag.planting { color: var(--primary); border-color: var(--primary); }
.tag.waiting { color: var(--warn); border-color: var(--warn); }
.tag.blocked, .tag.off { color: var(--danger); border-color: var(--danger); }
.metrics { margin: 8px 0 0; color: var(--muted); }
.metrics b { color: var(--ok); }
td.actions-cell { white-space: nowrap; }
td.actions-cell button { display: block; width: 100%; text-align: left; margin: 2px 0; }
#dealers td.wrap { min-width: 200px; max-width: 280px; }
#dealers td .countdown { margin-left: 0; }
.chip {
  display: inline-block;
  white-space: nowrap;
  margin: 2px 6px 2px 0;
  padding: 1px 8px 1px 4px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 12px;
}
.chip b { font-weight: 600; }
.chip.pos { color: var(--ok); }
#goals td.wrap { min-width: 260px; }
#goals td.eta, #goals td.status { white-space: normal; }
#goals td.eta .countdown, #overview td.eta .countdown { display: block; margin: 2px 0 0; }
#goals tbody tr[draggable] { cursor: grab; }
#goals tbody tr.dragging { opacity: 0.4; }
#goals tbody tr.drop-before td { box-shadow: inset 0 2px 0 var(--primary); }
#goals tbody tr.drop-after td { box-shadow: inset 0 -2px 0 var(--primary); }
#goals .drag-handle { color: var(--muted); margin-right: 6px; user-select: none; letter-spacing: -2px; }
#overview td.eta .block { display: block; margin-top: 2px; }
#overview td.goal-need .goal-icon { cursor: default; margin-left: 2px; }
#goals td.eta .nowrap, .tag, .countdown { white-space: nowrap; }
#goals td.actions-cell { white-space: nowrap; }
#goals td.actions-cell button { display: inline-block; width: auto; margin: 0 2px 0 0; }

/* ---- Kennzahlen ------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); min-height: 16px; }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--primary); width: 0; transition: width 0.4s; }

/* ---- Formulare ------------------------------------------------------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; display: grid; gap: 6px; }
.form legend { font-size: 12px; color: var(--muted); padding: 0 4px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: normal !important; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.card-head .inline { margin: 0; }
.inline input[name="name"] { flex: 1 1 160px; }
.inline input[name="quantity"] { width: 110px; }
.inline select { flex: 1 1 180px; }
#need-search { width: 180px; }

/* ---- Tabellen -------------------------------------------------------- */
.table-wrap { overflow-x: auto; scrollbar-width: thin; }
/* Quest-Tabellen sollen in schmalen Karten umbrechen statt zu scrollen */
.quest-table th, .quest-table td { white-space: normal; padding: 5px 4px; }
.quest-table td:first-child { min-width: 110px; }
.quest-table .progress { width: 56px; display: block; margin: 0 0 2px; }
.quest-table .small { white-space: nowrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
table.compact th, table.compact td { padding: 5px 6px; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.neg { color: var(--danger); }
td.pos { color: var(--ok); }
td input[type="number"] { width: 90px; padding: 3px 6px; text-align: right; }
td.wrap { white-space: normal; }
tr.declined td { opacity: 0.55; }
tr.history td { opacity: 0.75; }
tr.running td { font-weight: 600; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 10px; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.tag.planned { color: var(--primary); border-color: var(--primary); }
.tag.running { color: var(--ok); border-color: var(--ok); background: var(--primary-soft); }
.tag.done { color: var(--muted); }
.tag.failed { color: var(--danger); border-color: var(--danger); }
.tag.skipped { color: var(--warn); border-color: var(--warn); }

.countdown {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.countdown.chain { background: var(--bg); color: var(--muted); }
/* Faktor-Plakette neben einem Wert: grün ab 1, rot darunter */
.factor {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--primary-soft);
  color: var(--ok);
}
.factor.bad { background: var(--danger-soft); color: var(--danger); }
.kpi-value .countdown { font-size: 12px; vertical-align: middle; }

/* ---- Karte ----------------------------------------------------------- */
.map { display: flex; flex-wrap: wrap; gap: 0; }
.map svg { width: 100%; max-width: 1100px; height: auto; display: block; background: #2f4a2a; border-radius: 8px; }
.map .cell { stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.02; }
.map .cell.growing { fill: #5f9d47; }
.map .cell.ripe { fill: var(--reif); }
.map .cell.growing.w0 { fill: var(--w0); }
.map .cell.growing.w1 { fill: var(--w1); }
.map .cell.growing.w2 { fill: var(--w2); }
.map .cell.growing.w3 { fill: var(--w3); }
.map .cell.growing.w4 { fill: var(--w4); }
.map .cell.growing.w5 { fill: var(--w5); }
.map .cell.growing.w6 { fill: var(--w6); }
.map .cell.growing.w7 { fill: var(--w7); }
.map .cell.growing.w8 { fill: var(--w8); }
.map .cell.growing.w9 { fill: var(--w9); }
.map .mark.thirsty { fill: rgba(77, 143, 214, 0.5); pointer-events: none; }
.map .cell.empty { fill: #7a5b3a; }
.map .cell.obstacle { fill: #4a4a4a; }
.map image.obstacle-icon { pointer-events: none; }
.map .cell.mixed { fill: #9cb85c; }
.map .cell:hover { stroke: #fff; stroke-width: 0.06; }
.map .outline { fill: none; stroke: #ff5a3c; stroke-width: 0.12; stroke-linecap: round; pointer-events: none; }
.map .outline.empty, .map .outline.obstacle { stroke: rgba(255, 255, 255, 0.35); stroke-width: 0.06; }
.map .outline.locked { stroke: rgba(255, 255, 255, 0.7); stroke-width: 0.08; }
.map .outline.planned { stroke: #fff; stroke-width: 0.1; stroke-dasharray: 0.25 0.15; }
.map .mark { pointer-events: none; }
.map .mark.locked { fill: url(#hatch-locked); }
.map .mark.planned { fill: url(#hatch-planned); }
.map .mark.assigned { fill: url(#hatch-assigned); }
/* Feld mit Pflanzenbild: die Zustandsfarbe liegt als Schleier darüber, damit beides zu sehen ist */
.map .plant { pointer-events: none; }
.map .cell.mitbild { fill-opacity: 0.34; }
/* Reif deckt stärker: das Bild der fertigen Pflanze ist das hellste von allen, ein dünner
   Schleier würde das dunkelste Grün wieder aufhellen und den Verlauf umdrehen */
.map .cell.mitbild.ripe { fill-opacity: 0.55; }
/* Reife Felder atmen: zwischen den vielen grünen Pflanzenbildern geht ein ruhiges Grün unter.
   Mit Bild schwankt der Schleier, ohne Bild die Farbe selbst - sonst schiene der Seitengrund
   durch. Langsam und gleichphasig, damit es nicht flimmert. */
.map .cell.ripe.mitbild { animation: reif-puls 2.4s ease-in-out infinite; }
.map .cell.ripe:not(.mitbild) { animation: reif-farbe 2.4s ease-in-out infinite; }
@keyframes reif-puls { 0%, 100% { fill-opacity: 0.42; } 50% { fill-opacity: 0.82; } }
@keyframes reif-farbe { 0%, 100% { fill: var(--reif); } 50% { fill: #32922b; } }
@media (prefers-reduced-motion: reduce) {
  .map .cell.ripe.mitbild, .map .cell.ripe:not(.mitbild) { animation: none; }
}
.map .outline.reserved { stroke: #c14bd6; stroke-width: 0.1; stroke-dasharray: 0.2 0.12; }
.map-legend .sw.assigned { background: repeating-linear-gradient(45deg, rgba(0,0,0,0.12) 0 3px, #c14bd6 3px 4px), var(--w5); }
.map-assign { display: inline-flex; gap: 6px; align-items: center; }
.map-assign select { max-width: 260px; }
.map .label.planned rect { fill: #ffffff; stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.03; }
.map .label.planned text { fill: #1f3a1a; }
.map-legend .sw.locked { background: repeating-linear-gradient(45deg, #3a4a36 0 3px, #e24a3a 3px 4px); }
.map-legend .sw.planned { background: repeating-linear-gradient(-45deg, #7a5b3a 0 3px, #fff 3px 4px); }
.map-preview { margin-bottom: 8px; color: var(--text); }
.map-layouts { margin-bottom: 8px; }
.map-layouts .dd { min-width: 180px; }
#schedule-form label.small { display: inline-flex; align-items: center; gap: 4px; }
#schedule-form input[type="time"], #schedule-form input[type="date"] { padding: 3px 6px; font-size: 12px; }
.map .label { pointer-events: none; }
/* helles Etikett: die Produktbilder des Spiels bringen einen weißen Grund mit, auf einem
   dunklen Etikett stünde jedes Symbol in einem weißen Kasten */
.map .label rect { fill: #ffffff; rx: 0.15; }  /* voll deckend: die Symbole des Spiels haben weißen Grund */
.map .label text { fill: #1e281e; font-size: 0.4px; font-weight: 600; dominant-baseline: middle; text-anchor: start; }
.map .label image { image-rendering: pixelated; }
.map-legend { font-size: 12px; color: var(--muted); }
.map-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.map-legend .sw.growing { background: #5f9d47; }
.map-legend .sw.wachstum { background: linear-gradient(90deg, var(--w0), var(--w9)); }
.map-legend .sw.ripe { background: var(--reif); }
/* Durst liegt als Schleier über der Reifefarbe, das zeigt das Farbfeld genauso */
.map-legend .sw.thirsty { background: linear-gradient(rgba(77, 143, 214, 0.5), rgba(77, 143, 214, 0.5)), var(--w5); }
.map-legend .sw.empty { background: #7a5b3a; }
.map-legend .sw.obstacle { background: #4a4a4a; }
.map-info { margin-top: 10px; min-height: 20px; }
.map-tools { margin-top: 8px; }
.map .cell.selected { stroke: #fff; stroke-width: 0.08; }
.map .rubber { fill: rgba(255, 255, 255, 0.15); stroke: #fff; stroke-width: 0.05; stroke-dasharray: 0.15 0.1; pointer-events: none; }
.map .garden-frame { fill: none; stroke: rgba(255, 255, 255, 0.25); stroke-width: 0.06; }
.map .garden-title { fill: rgba(255, 255, 255, 0.7); font-size: 0.5px; font-weight: 600; }
.map .placeholder rect.bg { fill: #3a3f3a; stroke: rgba(255, 255, 255, 0.2); stroke-width: 0.06; stroke-dasharray: 0.3 0.2; }
.map .placeholder text { fill: rgba(255, 255, 255, 0.75); font-size: 0.6px; text-anchor: middle; dominant-baseline: middle; }
.map .placeholder .buy { cursor: pointer; }
.map .placeholder .buy rect { fill: var(--primary); rx: 0.2; }
.map .placeholder .buy text { fill: #fff; font-size: 0.5px; font-weight: 600; }
.map .placeholder .buy.off rect { fill: #666; }
.map svg { user-select: none; }

/* ---- Log ------------------------------------------------------------- */
.log {
  margin: 0;
  height: 360px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: var(--log-bg);
  color: var(--log-text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.log .warn { color: #f0c36d; }
.log .error { color: #ff8a80; }
.log .debug { color: #8fa38f; }

.live { min-height: 60px; }
.live img { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #000; }
.icon { width: 22px; height: 22px; vertical-align: middle; margin-right: 6px; object-fit: contain; }
.icon.big { width: 32px; height: 32px; }
/* Regal-Etikett: 32×24 aus der Sprite-Karte, auf 75 % verkleinert */
/* Maße stehen am Element selbst, sie hängen von der Sprite-Karte ab (siehe icon() in 00-basis.js) */
.sicon { display: inline-block; overflow: hidden; vertical-align: middle; margin-right: 6px; border-radius: 3px; flex: none; }
.sicon i { display: block; transform-origin: 0 0; }
table.compact td:last-child { white-space: nowrap; }
button.icon-btn { padding: 2px 7px; font-size: 12px; line-height: 1.2; }
.screens { display: flex; gap: 10px; flex-wrap: wrap; }
.screens a { display: block; width: 180px; }
.screens img { width: 100%; border: 1px solid var(--border); border-radius: 6px; }
.screens small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; width: min(720px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); }
.modal-box .actions { margin-top: 14px; justify-content: flex-end; }
.purchase-table td.src { color: var(--muted); font-size: 12px; }
.purchase-table tr.total td { font-weight: 600; border-top: 2px solid var(--border); }
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 10;
}
.toast.error { background: var(--danger); color: #fff; }

/* ---- Schmale Bildschirme --------------------------------------------- */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto;
    height: auto;
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar button { width: auto; white-space: nowrap; }
  .content { padding: 14px; }
  .topbar-status { justify-content: flex-start; }
  /* schmale Bildschirme: die Menüleiste liegt waagerecht über dem Inhalt, feste Höhe passt nicht */
  .card.fill { height: 70vh; }
}

/* ---- Anmeldeseite ------------------------------------------------------ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); }
.login-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.login-box .form { display: grid; gap: 12px; }
.login-box label { display: grid; gap: 4px; font-size: 13px; }
.login-box input { width: 100%; }
.login-box .banner { margin: 12px 0 0; }
/* Angemeldeter Nutzer in der Kopfzeile */
.user-box { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.user-box b { color: var(--text); }

/* Ziele: Ware, die zwar reicht, aber noch wächst (nicht grün, weil sie heute nicht lieferbar ist) */
.chip.wait { color: var(--warn); }
.tag.growing { color: var(--warn); border-color: var(--warn); }
.warn { color: var(--warn); }

/* ---- Unterreiter innerhalb eines Bereichs ------------------------------ */
.subtabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin-bottom: 16px; padding-bottom: 0;
  border-bottom: 1px solid var(--border);
}
.subtabs button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
  background: none; color: var(--muted); padding: 8px 14px; font-weight: 500;
}
.subtabs button:hover { background: var(--primary-soft); color: var(--text); filter: none; }
.subtabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.subtab { display: none; }
.subtab.active { display: block; }
.subtab > .card + .card { margin-top: 14px; }

/* ---- Einstellungen als Raster: Gruppen nebeneinander statt einer langen Spalte ---- */
/* Spaltensatz statt Raster: die Gruppen fließen und lassen keine Löcher, wenn eine kürzer ist */
.settings-grid {
  display: block;
  column-width: 330px;
  column-gap: 14px;
}
.settings-grid fieldset {
  break-inside: avoid;
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px 14px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.settings-grid legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.settings-grid > label { display: grid; gap: 4px; }
/* Speichern immer über die ganze Breite und sichtbar am Ende */
/* Speichern über die ganze Breite, unabhängig von den Spalten */
.settings-grid .settings-actions { column-span: all; margin-top: 4px; }
@media (max-width: 700px) { .settings-grid { column-width: auto; column-count: 1; } }
/* In der schmalen Spalte gehört der Hinweis unter das Ankreuzfeld, nicht daneben */
.settings-grid label.check {
  display: grid !important;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: start;
}
.settings-grid label.check input[type="checkbox"] { margin-top: 3px; }
.settings-grid label.check .hint { grid-column: 2; margin-top: 2px; }
/* Formular-Dialoge sind schmaler als Tabellen-Dialoge */
.modal-box.narrow-box { width: min(520px, 100%); }
.modal-box .form { display: grid; gap: 12px; }
.modal-box fieldset { margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }

/* ---- Eigene Dialoge (05-dialog.js) ------------------------------------- */
.dialog .modal-box { width: min(440px, 100%); }
.dialog-text { margin: 0 0 4px; line-height: 1.5; }
.dialog-body { display: grid; gap: 12px; }
.dialog-body label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.dialog-body input, .dialog-body select { width: 100%; font-weight: normal; }
.dialog-actions { margin-top: 16px; justify-content: flex-end; gap: 8px; }
