:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #6a6f76;
  --line: #e3e1dc;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e6efeb;
  --danger: #a23b2c;
  --warn-bg: #fff4dc;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

header.site { background: var(--surface); border-bottom: 1px solid var(--line); padding: 28px 0 24px; margin-bottom: 28px; }
header.site h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
.lead { margin: 6px 0 0; color: var(--muted); }

/* Geräteauswahl */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding-bottom: 40px; }
.device-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; cursor: pointer; font: inherit; color: inherit; min-height: 130px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.device-card:hover, .device-card:focus-visible { border-color: var(--accent); box-shadow: 0 4px 16px rgba(0,0,0,.06); outline: none; transform: translateY(-1px); }
.device-name { font-size: 1.25rem; font-weight: 650; }
.device-desc { color: var(--muted); font-size: .92rem; }
.device-cta { margin-top: auto; color: var(--accent); font-weight: 600; font-size: .92rem; }
.empty { color: var(--muted); }

/* Berechnungsfenster */
dialog {
  border: none; border-radius: 14px; padding: 0; width: min(900px, calc(100vw - 24px));
  box-shadow: 0 24px 64px rgba(0,0,0,.25); color: var(--ink);
}
dialog::backdrop { background: rgba(20, 24, 28, .45); }
dialog form { padding: 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dlg-head h2 { margin: 0; font-size: 1.5rem; }
.eyebrow { margin: 0; color: var(--accent); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.close { border: none; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.hint { color: var(--muted); font-size: .9rem; margin: 8px 0 16px; }

.calc-table { width: 100%; border-collapse: collapse; }
.calc-table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 0 6px 8px; }
.calc-table td { padding: 4px 6px; }
.calc-table .idx { color: var(--muted); width: 24px; font-variant-numeric: tabular-nums; }
.calc-table input {
  width: 100%; padding: 9px 10px; font: inherit; border: 1px solid var(--line); border-radius: 8px;
  background: #fbfbfa; font-variant-numeric: tabular-nums;
}
.calc-table input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.calc-table input.invalid { border-color: var(--danger); background: #fdf1ef; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.out { font-weight: 600; min-width: 96px; }
.calc-table input[name=days] { max-width: 90px; }
.err { color: var(--danger); font-size: .84rem; padding-top: 0 !important; }

.totals { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; margin-top: 20px; }
.tot { background: var(--bg); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.tot.main { background: var(--accent); color: var(--accent-ink); }
.tot .lbl { font-size: .82rem; opacity: .85; }
.tot .val { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tot.main .val { font-size: 1.6rem; }
.warn { background: var(--warn-bg); padding: 10px 14px; border-radius: 8px; margin: 14px 0 0; font-size: .9rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Buttons */
.btn {
  display: inline-block; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: #e6c4be; }
.btn.small { padding: 5px 10px; font-size: .85rem; }

/* Admin */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.card h2 { margin: 0 0 14px; font-size: 1.15rem; }
.card.narrow { max-width: 420px; }
details.card summary { cursor: pointer; font-weight: 600; }
details.card[open] summary { margin-bottom: 14px; }
.stack { display: grid; gap: 12px; }
.grid-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: end; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
label { display: grid; gap: 4px; font-size: .86rem; color: var(--muted); font-weight: 500; }
label input { font: inherit; color: var(--ink); padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.list th { font-size: .8rem; color: var(--muted); }
.list th.num, .list td.num { text-align: right; }
.list small { color: var(--muted); }
.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }
.actions-cell form { margin: 0; }
.tag { font-size: .78rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.tag.on { background: var(--accent-soft); color: var(--accent); }
.flash { background: var(--accent-soft); color: var(--accent); padding: 10px 14px; border-radius: 8px; }
.flash.error { background: #fdf1ef; color: var(--danger); }
.muted { color: var(--muted); }
.muted a { color: var(--accent); }

@media (max-width: 640px) {
  .totals { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr; }
  .calc-table th { font-size: .7rem; }
  .calc-table td { padding: 3px 2px; }
  .calc-table input { padding: 8px 6px; }
  .list .num:nth-child(3) { display: none; }
}

@media print {
  body { background: #fff; }
  header.site, main, .dlg-foot, .close, .hint { display: none !important; }
  dialog { position: static; box-shadow: none; width: 100%; }
  dialog::backdrop { display: none; }
  .tot.main { color: #000; background: #eee; }
}

/* Sprachumschalter */
.lang { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 3px; flex-shrink: 0; align-self: flex-start; }
.lang a, .lang span { font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; text-decoration: none; color: var(--muted); }
.lang span { background: var(--accent); color: var(--accent-ink); }
.lang a:hover { color: var(--accent); }
.head-right { display: flex; gap: 12px; align-items: center; }
.grid-form { grid-template-columns: repeat(6, 1fr); }
.grid-form > label { grid-column: span 2; }
.grid-form > label.half { grid-column: span 3; }
.grid-form > label.check { grid-column: 1 / -1; }
.lng { display: inline-block; font-size: .68rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-right: 4px; }
@media (max-width: 640px) { .grid-form > label, .grid-form > label.half { grid-column: 1 / -1; } }
