:root {
  --stone: #eceee9;
  --paper: #f8f9f6;
  --basalt: #1e2622;
  --muted: #5d6862;
  --line: #cdd3cc;
  --signal: #f2c200;
  --soil: #7a5a3f;
  --moss: #2f6b4a;
  --alert: #c2410c;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--stone);
  color: var(--basalt);
  font: 400 16px/1.5 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 32px;
  height: 64px;
  background: var(--basalt);
  color: var(--paper);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  font: 700 26px/1 var(--display);
  letter-spacing: .01em;
}
.brand svg { width: 28px; height: 28px; }
.tabs { display: flex; height: 100%; }
.tabs a {
  display: flex; align-items: center;
  padding: 0 18px;
  text-decoration: none;
  font: 600 18px/1 var(--display);
  color: #aab5ae;
  border-bottom: 4px solid transparent;
  border-top: 4px solid transparent;
}
.tabs a:hover { color: var(--paper); }
.tabs a.active { color: var(--paper); border-bottom-color: var(--signal); }
.botstatus { margin-left: auto; font-size: 14px; color: #aab5ae; display: flex; align-items: center; gap: 8px; }
.bs-text { display: flex; align-items: center; gap: 8px; }
.botstatus .dot { width: 9px; height: 9px; border-radius: 50%; background: #5fbf8a; }
.botstatus .dot.off { background: #7d8781; }

main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px; }
.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 16px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.1; }
h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 21px; font-weight: 600; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 40px;
  align-items: end;
  padding-bottom: 28px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.hero .log { grid-column: 1 / -1; }
.control h1 { margin-bottom: 8px; }
.control p.lead { color: var(--muted); margin: 0; max-width: 62ch; }
.startbtn {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 16px 28px;
  background: var(--signal);
  border: 0; border-radius: 4px;
  font: 700 22px/1 var(--display);
  cursor: pointer;
  box-shadow: 0 3px 0 #b38f00;
}
.startbtn:hover { background: #ffd21a; }
.startbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b38f00; }
.startbtn:disabled { background: var(--line); box-shadow: none; cursor: progress; }
.log {
  padding: 14px 16px;
  background: var(--paper);
  border-left: 4px solid var(--signal);
  font-size: 14px;
  min-height: 0;
}
.log:empty { display: none; }
.log div { padding: 2px 0; }
.log div.done { color: var(--muted); }
.log div.done::before { content: "✓ "; color: var(--moss); }

/* Runs list */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 16px; flex-wrap: wrap; }
.section-head .meta { color: var(--muted); font-size: 14px; }

.runs { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.run {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  gap: 24px;
  align-items: center;
  padding: 18px 20px;
  text-decoration: none;
  border-top: 1px solid var(--line);
}
.runs li:first-child .run { border-top: 0; }
.run:hover { background: #fffbe6; }
.run .when strong { display: block; font: 600 20px/1.1 var(--display); }
.run .when span { font-size: 13px; color: var(--muted); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 10px;
  border-radius: 3px;
  background: var(--stone);
  font-size: 14px;
  white-space: nowrap;
}
.badge b { font: 700 17px/1 var(--display); }
.badge.new { background: var(--signal); }
.badge.tender { background: #ffe1d1; color: #8a2d06; }
.badge.ton { background: #efe6dc; color: var(--soil); }
.run .go { font: 600 16px var(--display); color: var(--muted); }
.run.unseen .when strong::after { content: "neu"; margin-left: 8px; font: 600 12px var(--body); background: var(--basalt); color: var(--signal); padding: 2px 6px; border-radius: 3px; vertical-align: 3px; }

/* Run detail */
.back { display: inline-block; margin-bottom: 16px; font: 600 17px var(--display); color: var(--muted); text-decoration: none; }
.back:hover { color: var(--basalt); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  font-size: 14px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--basalt); color: var(--paper); border-color: var(--basalt); }

.finds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.find-card { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; }
.find-card.open { border-color: var(--basalt); }
.find-head {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.score {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 50%;
  font: 700 28px/1 var(--display);
  background: var(--stone);
  border: 4px solid var(--line);
}
.score.hi { border-color: var(--signal); }
.score.mid { border-color: #d9c98a; }
.find-head .title { font: 600 20px/1.2 var(--display); }
.find-head .sub { font-size: 14px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.find-head .right { text-align: right; }
.find-head .ton { font: 700 22px/1 var(--display); color: var(--soil); }
.find-head .ton small { font-size: 14px; font-weight: 500; }
.frist { display: inline-block; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--alert); }

.find-body { display: none; padding: 4px 18px 20px 100px; }
.find-card.open .find-body { display: block; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 24px; margin: 0 0 18px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.dist { margin-bottom: 16px; max-width: 520px; }
.dist-row { display: grid; grid-template-columns: 90px 1fr 54px; gap: 10px; align-items: center; font-size: 14px; margin: 4px 0; }
.dist-row .bar { height: 8px; background: var(--stone); border-radius: 4px; overflow: hidden; }
.dist-row .bar i { display: block; height: 100%; background: var(--line); }
.dist-row.best .bar i { background: var(--moss); }
.dist-row.best { font-weight: 600; }
.action { background: #fffbe6; border-left: 4px solid var(--signal); padding: 10px 14px; margin-bottom: 12px; }
.src { font-size: 14px; color: var(--muted); word-break: break-all; }

.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--paper); border: 1px dashed var(--line); border-radius: 6px; }

/* Settings */
.settings { display: grid; grid-template-columns: 220px 1fr; gap: 40px; }
.settings-nav { position: sticky; top: 24px; align-self: start; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-left: 3px solid transparent; }
.settings-nav a:hover { color: var(--basalt); border-left-color: var(--line); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 24px 28px; margin-bottom: 20px; scroll-margin-top: 24px; }
.panel h2 { font-size: 24px; margin-bottom: 4px; }
.panel > p { margin: 0 0 20px; color: var(--muted); font-size: 15px; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="time"], select, textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  width: 100%;
  max-width: 420px;
}
textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.toggle-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.toggle-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle-item small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 13px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--moss); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--signal); outline-offset: 2px; }
.plant-radius { display: grid; grid-template-columns: 200px 1fr 64px; gap: 14px; align-items: center; margin-bottom: 10px; }
.plant-radius output { font: 600 18px var(--display); text-align: right; }
input[type="range"] { accent-color: var(--basalt); width: 100%; }
.chips-select { display: flex; flex-wrap: wrap; gap: 8px; }
.save-bar {
  position: sticky; bottom: 0;
  display: flex; justify-content: flex-end; gap: 12px;
  padding: 16px 0;
  background: linear-gradient(transparent, var(--stone) 30%);
}
.btn { padding: 10px 20px; border-radius: 4px; border: 1px solid var(--basalt); background: transparent; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--basalt); color: var(--paper); }
.btn.primary:hover { background: #33403a; }

.toast {
  position: fixed; left: 50%; bottom: 96px;
  transform: translate(-50%, 20px);
  background: var(--basalt); color: var(--paper);
  padding: 12px 20px; border-radius: 4px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .topbar { padding: 0 16px; gap: 12px; height: auto; flex-wrap: wrap; }
  .brand { padding: 14px 0; }
  .botstatus .bs-text { display: none; }
  .tabs { order: 3; width: 100%; height: 48px; }
  .tabs a { padding: 0 12px; }
  main { padding: 20px 16px; }
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .startbtn { justify-self: start; }
  .run { grid-template-columns: 1fr; gap: 10px; }
  .run .go { display: none; }
  .find-head { grid-template-columns: 52px 1fr; }
  .score { width: 52px; height: 52px; font-size: 22px; }
  .find-head .right { grid-column: 2; text-align: left; }
  .find-body { padding-left: 18px; }
  .settings { grid-template-columns: 1fr; }
  .settings-nav { display: none; }
  .panel { padding: 20px 16px; }
  .plant-radius { grid-template-columns: 1fr 56px; }
  .plant-radius label { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* Login, Vertrieb, Herkunft */
.login { max-width: 420px; margin: 40px auto; }
.login h1 { margin-bottom: 8px; }
.login .lead { color: var(--muted); margin: 0 0 24px; }
.fehler { color: var(--alert); font-weight: 600; }
.badge.fehler { background: #fde2d6; color: #8a2d06; }
.herkunft { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; margin-left: 4px; }
.action.warn { background: #fdeee6; border-left-color: var(--alert); }
.score-erklaerung { margin: 8px 0 16px; font-size: 14px; color: var(--muted); }
.score-erklaerung summary { cursor: pointer; }
.vertrieb { display: grid; grid-template-columns: 220px 1fr; gap: 16px; margin-bottom: 14px; }
.vertrieb label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.vertrieb textarea { min-height: 60px; max-width: none; }
.vertrieb select { max-width: none; }
.vertrieb-irrelevant { text-decoration: line-through; }
.vertrieb-gewonnen { color: var(--moss); font-weight: 600; }
.toggle-item.bald, .panel.bald { opacity: .55; }
.abmelden { margin-left: 12px; background: none; border: 1px solid #55625b; color: #aab5ae; border-radius: 3px; padding: 2px 8px; cursor: pointer; font-size: 13px; }
.abmelden:hover { color: var(--paper); }
.meta { color: var(--muted); font-size: 14px; }
@media (max-width: 860px) { .vertrieb { grid-template-columns: 1fr; } }
.tabs[hidden] { display: none; }

.lauf-aktionen { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.btn.loeschen { border-color: var(--alert); color: var(--alert); }
.btn.loeschen:hover { background: #fdeee6; }
