:root {
  --bg: #f3f1ea;
  --panel: #ffffff;
  --ink: #1d2626;
  --muted: #5b6766;
  --line: #dcd8cc;
  --brand: #1f4d4a;
  --brand-2: #2e6f6a;
  --accent: #c98b4b;
  --pos: #1f7a3f;
  --neg: #a8322d;
  --ok-bg: #e2f2e6;
  --ok: #1f6b36;
  --warn-bg: #fff2c7;
  --warn: #7a5a00;
  --stop-bg: #f7dedd;
  --stop: #8c1f1a;
  --water-1: #cfe8f5;
  --water-2: #8cc7e8;
  --water-3: #3f8fc8;
  --water-4: #1d4f86;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 10px rgba(0, 0, 0, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; margin-bottom: .7rem; color: var(--brand); letter-spacing: .01em; }
h3 { font-size: 1rem; }
p { margin: .35rem 0; }
ul { margin: .3rem 0; padding-left: 1.2rem; }

/* Kopfzeile */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem;
  padding: .75rem 1.25rem; background: var(--brand); color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.logo { width: 40px; height: 40px; border-radius: 9px; }
.brand h1 { font-size: 1.15rem; }
.sub { margin: 0; font-size: .8rem; opacity: .85; }
.stats { display: flex; gap: .5rem; flex-wrap: wrap; margin-left: auto; }
.stat { background: rgba(255,255,255,.12); border-radius: 10px; padding: .3rem .7rem; min-width: 6.5rem; }
.stat small { display: block; font-size: .7rem; opacity: .8; text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.menu { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Buttons */
.btn {
  font: inherit; font-size: .9rem; cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  padding: .5rem .9rem; background: var(--brand-2); color: #fff; min-height: 40px;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.45); color: #fff; }
.btn.secondary { background: #fff; color: var(--brand); border-color: var(--brand-2); }
.btn.danger { background: #fff; color: var(--neg); border-color: var(--neg); }
.btn.primary { background: var(--accent); color: #1d1406; font-weight: 600; }
.btn.small { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

#sync-status {
  margin: 0; padding: .55rem 1.25rem; background: var(--warn-bg);
  border-bottom: 1px solid var(--line); color: var(--warn);
}
#sync-status[data-state="saved"] { background: var(--ok-bg); color: var(--ok); }
#sync-status[data-state="conflict"], #sync-status[data-state="error"] { background: var(--stop-bg); color: var(--stop); }
#sync-status .btn { margin: .35rem .35rem 0 0; }
.save-help { padding: .3rem 1.25rem; font-size: .8rem; color: var(--muted); background: #f6f5f0; }
.save-help summary { cursor: pointer; }
.save-help .btn { min-height: 32px; font-size: .8rem; padding: .3rem .6rem; }
#save-status { display: inline-block; margin-left: .5rem; }

/* Tagesleiste */
.days {
  list-style: none; margin: 0; padding: .6rem 1.25rem; display: grid;
  grid-template-columns: repeat(5, 1fr); gap: .4rem; background: #e7e3d6; border-bottom: 1px solid var(--line);
}
.days li { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: .35rem .6rem; font-size: .8rem; color: var(--muted); }
.days li b { display: block; color: var(--ink); font-size: .85rem; }
.days li.now { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.days li.done { background: #f6f5f0; }

/* Layout */
.layout {
  display: grid; grid-template-columns: minmax(320px, 5fr) minmax(340px, 6fr);
  gap: 1rem; padding: 1rem 1.25rem; max-width: 1400px; margin: 0 auto;
}
.col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.col-left { position: sticky; top: 76px; align-self: start; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; border: 1px solid var(--line); }
.panel.today { border-color: var(--accent); }

/* Karte */
.map svg { width: 100%; height: auto; display: block; border-radius: 9px; }
.map-legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .78rem; color: var(--muted); margin-top: .5rem; }
.map-legend span::before { content: ""; display: inline-block; width: 18px; height: 4px; margin-right: .35rem; vertical-align: middle; background: var(--c, #999); border-radius: 2px; }

/* Lage */
.cond-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.cond-card { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; }
.cond-card h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .35rem; }
.cond-card .big { font-size: 1.1rem; font-weight: 700; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin: .45rem 0 .2rem; }
.meter i { height: 10px; border-radius: 3px; background: #eceae3; }
.meter i.on:nth-child(1) { background: var(--water-1); }
.meter i.on:nth-child(2) { background: var(--water-2); }
.meter i.on:nth-child(3) { background: var(--water-3); }
.meter i.on:nth-child(4) { background: var(--water-4); }
.meter-labels { display: flex; justify-content: space-between; font-size: .68rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; border-radius: 8px; padding: .25rem .55rem; font-size: .95rem; }
.badge.geeignet { background: var(--ok-bg); color: var(--ok); }
.badge.vorbehalt { background: var(--warn-bg); color: var(--warn); }
.badge.ungeeignet { background: var(--stop-bg); color: var(--stop); }
.badge.unsicher { background: #eceae3; color: var(--muted); }
.reasons { font-size: .85rem; color: var(--muted); }
.forecast { margin-top: .7rem; font-size: .9rem; }
.forecast dt { font-weight: 600; font-size: .8rem; color: var(--muted); }
.forecast dd { margin: 0 0 .4rem; }
.disclaimer { font-size: .75rem; color: var(--muted); border-top: 1px dashed var(--line); margin-top: .6rem; padding-top: .45rem; }

/* 3-Tage-Prognose */
.fc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; }
.fc-card { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; font-size: .86rem; }
.fc-card.ist { border: 2px solid var(--brand-2); background: #f4f9f8; }
.fc-card.prognose { border-style: dashed; }
.fc-card header { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; margin-bottom: .35rem; }
.fc-card dl { margin: 0; }
.fc-card dt { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: .3rem; }
.fc-card dd { margin: 0; }
.fc-card .badge { font-size: .82rem; padding: .15rem .45rem; }
.fc-termin { font-weight: 600; color: var(--brand); margin-top: .4rem; }
.kind { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; border-radius: 6px; padding: .05rem .4rem; }
.kind.ist { background: var(--brand-2); color: #fff; }
.kind.prognose { background: #fff; color: var(--brand); border: 1px dashed var(--brand-2); }
.unc { font-weight: 700; }
.unc.mittel { color: var(--warn); }
.unc.hoch { color: var(--neg); }
.sub-h { font-size: .9rem; margin-top: .7rem; color: var(--brand); }
.choice { margin: .4rem 0; }

/* Heute */
.callout { border-radius: 10px; padding: .7rem .85rem; margin: .6rem 0; font-size: .92rem; }
.callout.info { background: #eaf3f2; }
.callout.warn { background: var(--warn-bg); color: #4d3a00; }
.callout.stop { background: var(--stop-bg); color: #5b1411; }
.callout.ok { background: var(--ok-bg); color: #16482a; }
.callout h3 { margin-bottom: .25rem; }
.error { background: var(--stop-bg); color: var(--stop); border-radius: 8px; padding: .5rem .7rem; margin-top: .6rem; font-size: .9rem; }
.checklist { list-style: none; padding: 0; margin: .5rem 0; }
.checklist li { padding: .3rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: .5rem; font-size: .92rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { width: 1.3rem; flex: none; text-align: center; font-weight: 700; }
.checklist .yes .mark { color: var(--pos); }
.checklist .no .mark { color: var(--neg); }
.checklist .maybe .mark { color: var(--warn); }
.ack { display: flex; gap: .55rem; align-items: flex-start; margin-top: .6rem; font-size: .92rem; }
.ack input { width: 20px; height: 20px; margin-top: .1rem; flex: none; }
.hint { font-size: .85rem; color: var(--muted); }

/* Buchungen */
.bookings { display: grid; gap: .8rem; }
.booking { border: 1px solid var(--line); border-radius: 10px; padding: .75rem .85rem; }
.booking.inactive { background: #f8f7f3; }
.booking header { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.status { font-size: .75rem; border-radius: 99px; padding: .1rem .55rem; background: #eceae3; color: var(--muted); white-space: nowrap; }
.status.good { background: var(--ok-bg); color: var(--ok); }
.status.bad { background: var(--stop-bg); color: var(--stop); }
.status.mid { background: var(--warn-bg); color: var(--warn); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .8rem; font-size: .88rem; margin: .5rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.chip { display: inline-block; font-size: .78rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 .35rem; margin: 0 .15rem .15rem 0; }
.chip.missing { border-color: var(--neg); color: var(--neg); font-weight: 700; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--brand-2); border-radius: 9px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; border: 0; background: #fff; color: var(--brand); padding: .4rem .65rem; cursor: pointer; min-height: 38px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--brand-2); color: #fff; }
.seg button small { display: block; font-size: .72rem; opacity: .85; }
.offer { display: grid; gap: .5rem; margin-top: .5rem; }
.preview { font-size: .88rem; }

/* Berichte & Kasse */
.report { border: 1px solid var(--line); border-radius: 10px; padding: .75rem .85rem; margin-bottom: .7rem; }
.report h3 { margin-bottom: .35rem; }
.money { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.money td { padding: .22rem 0; border-bottom: 1px dashed var(--line); }
.money td:last-child { text-align: right; white-space: nowrap; }
.money tr.total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .88rem; margin-top: .45rem; }
.steps { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0; padding: 0; list-style: none; }
.steps li { font-size: .78rem; background: #eaf3f2; border-radius: 6px; padding: .1rem .45rem; }
.ledger-wrap { max-height: 260px; overflow: auto; }
details summary { cursor: pointer; font-size: .88rem; color: var(--brand); margin-top: .5rem; }
.log { font-size: .82rem; color: var(--muted); list-style: none; padding: 0; }
.log li { padding: .15rem 0; }

/* Abschluss */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin: .6rem 0; }
.kpi { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; }
.kpi small { display: block; color: var(--muted); font-size: .75rem; }
.kpi b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.compare { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .4rem; font-variant-numeric: tabular-nums; }
.compare th, .compare td { text-align: left; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }

.foot { font-size: .78rem; color: var(--muted); padding: 1rem 1.25rem 2rem; max-width: 1400px; margin: 0 auto; }

/* Responsiv */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .col-left { position: static; }
}
@media (max-width: 560px) {
  .topbar { padding: .6rem .8rem; position: static; }
  .stats { margin-left: 0; width: 100%; }
  .stat { flex: 1; min-width: 0; }
  .layout { padding: .7rem; }
  .days { grid-template-columns: repeat(5, minmax(0, 1fr)); padding: .5rem .7rem; }
  .days li { padding: .3rem; font-size: .7rem; }
  .days li span { display: none; }
  .cond-grid { grid-template-columns: 1fr; }
  .menu .btn { flex: 1; font-size: .8rem; padding: .45rem .5rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .marker { transition: transform .6s ease; }
}
