:root {
  --bg: #f6f5f1; --panel: #ffffff; --fg: #1d1d1b; --muted: #6b6a64; --line: #e3e1da;
  --accent: #2f6fdd; --ok: #2b8a3e; --warn: #b7791f; --bad: #c92a2a;
  --ok-bg: #e8f5ec; --warn-bg: #fdf3e1; --bad-bg: #fdeaea;
  --grid: #ecebe5; --band: rgba(43, 138, 62, .08);
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614; --panel: #201f1d; --fg: #ecebe6; --muted: #a09e96; --line: #34332f;
    --accent: #6b9cf0; --ok: #69c27f; --warn: #e3a948; --bad: #f07171;
    --ok-bg: #1d2e22; --warn-bg: #33291a; --bad-bg: #3a1f1f;
    --grid: #2c2b28; --band: rgba(105, 194, 127, .10);
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
code { font-size: .9em; background: var(--grid); padding: 1px 5px; border-radius: 4px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: 1.9rem; margin: .2rem 0 .4rem; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .5rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 0; }
section { margin-bottom: 1.4rem; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* Kopfzeile */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 600; color: var(--fg); text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.logo { width: 22px; height: 22px; display: block; }
.nav { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; }
.nav a, .linkbtn { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font: inherit; }
.nav a:hover, .linkbtn:hover { color: var(--fg); background: var(--grid); }
.nav a.on { color: var(--fg); background: var(--grid); }
.linkbtn { background: none; border: 0; cursor: pointer; }
.linkbtn.danger { color: var(--bad); padding: 2px 4px; }
form.inline { display: inline; margin: 0; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 1rem; padding-bottom: 2rem; }

/* Karten & Buttons */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); color: var(--ok); }
.flash-bad { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }

/* Formulare */
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.stack { display: flex; flex-direction: column; gap: .8rem; max-width: 28rem; }
.auth { max-width: 420px; margin: 3rem auto; }
.auth form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }

/* Dashboard */
.hero { display: flex; justify-content: space-between; gap: 1rem 2rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: .3rem; }
.lede { margin: 0; color: var(--muted); max-width: 52rem; font-size: 1.05rem; }
.period { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.custom { display: flex; gap: .4rem; align-items: center; }
.custom input { padding: 5px 8px; font-size: .85rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel); flex-wrap: wrap; }
.seg a, .seg button { font: inherit; font-size: .85rem; padding: 4px 11px; border-radius: 999px; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; }
.seg a.on, .seg button.on { background: var(--fg); color: var(--bg); }
.seg.small a, .seg.small button { font-size: .8rem; padding: 3px 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pill { font-size: .75rem; padding: 1px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); } .pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); } .pill.muted { color: var(--muted); }
.big { font-family: var(--serif); font-size: 2rem; line-height: 1.15; font-variant-numeric: tabular-nums; margin: 4px 0; }
.big small { font-family: var(--sans); font-size: 1rem; color: var(--muted); margin-left: 4px; }
.sub { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.recs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 12px; }
.rec { border-left: 4px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.rec.p1 { border-left-color: var(--bad); } .rec.p2 { border-left-color: var(--warn); }
.rec p { margin: 0; }
.rec .meta { font-size: .78rem; color: var(--muted); display: flex; gap: 6px; }
.rec .why { font-size: .82rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: 12px; margin-bottom: 1.4rem; }
.grid2 > section { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; gap: .6rem 1rem; align-items: flex-start; flex-wrap: wrap; }
.note { color: var(--muted); font-size: .82rem; margin: 0 0 .6rem; }
.method { font-size: .85rem; color: var(--muted); }
.method p { margin: 0 0 .5rem; }

/* Diagramme */
.chartbox { position: relative; }
.chart { position: relative; height: 300px; }
.chartbox.tall .chart { height: 340px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--line); }
.chart .band { fill: var(--band); }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .rule { stroke: var(--muted); stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 2px 6px; margin-bottom: 4px; }
.legend button { font: inherit; font-size: .8rem; color: var(--muted); background: none; border: 0; padding: 2px 6px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.legend button:hover { background: var(--grid); }
.legend button.off { opacity: .4; text-decoration: line-through; }
.legend i, .tip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: absolute; display: none; pointer-events: none; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 6px 10px; font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tip .tip-h { color: var(--muted); margin-bottom: 2px; }
.tip i { margin-right: 6px; }

/* Tabellen */
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.tbl .l { text-align: left; }
.tbl td.l { white-space: normal; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl select, .tbl input { padding: 4px 8px; font-size: .85rem; }
.tbl .newroom { margin-top: 4px; width: 12rem; }

/* Import */
.drop { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: var(--radius); padding: 2.2rem 1rem;
  text-align: center; cursor: pointer; color: var(--muted); margin: 1rem 0 .5rem; position: relative; }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--fg); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.strategy { border: 1px solid var(--line); border-radius: 8px; margin: 1rem 0 0; padding: .6rem 1rem; display: flex; gap: .4rem 1.4rem; flex-wrap: wrap; }
.strategy legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }
.strategy label { flex-direction: row; align-items: center; gap: .4rem; color: var(--fg); }
.empty { text-align: center; padding: 3rem 1rem; }

/* Räume */
.roomlist { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 12px; }
.room-edit { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.room-edit label:first-of-type { flex: 1; min-width: 10rem; }
.room details { margin-top: .6rem; }
.room summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-top: .8rem; }
.inline-form.danger label { color: var(--bad); }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .card { padding: 14px; }
  .chart { height: 260px; }
  .chartbox.tall .chart { height: 280px; }
}
