:root {
  --fg: #1d1f21;
  --muted: #6a6e73;
  --bg: #fdfdfd;
  --akzent: #1f7a4d;
  --rahmen: #e2e4e7;
  --max-breite: 56rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  border-bottom: 1px solid var(--rahmen);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  max-width: var(--max-breite);
  margin: 0 auto;
}

header h1 {
  font-size: 1.25rem;
  margin: 0;
}

header h1 a { color: var(--fg); }

nav { flex-grow: 1; }
nav a { margin-right: 1rem; color: var(--muted); }
nav a:hover { color: var(--akzent); }

.datum-picker input {
  font: inherit;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--rahmen);
  border-radius: 4px;
}

main {
  max-width: var(--max-breite);
  margin: 1.5rem auto;
  padding: 0 1rem;
}

section { margin-bottom: 2rem; }

h2 { margin-top: 0; }

code {
  background: #f3f4f6;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  font-size: 0.9em;
}

footer {
  border-top: 1px solid var(--rahmen);
  margin-top: 3rem;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  header { flex-direction: column; gap: 0.25rem; }
}

form.konfig details {
  border: 1px solid var(--rahmen);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
}

form.konfig details[open] {
  background: #fafbfc;
}

form.konfig details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
  margin: -0.25rem 0;
}

form.konfig details.mqtt {
  margin-top: 0.75rem;
  background: #f3f4f6;
  border-style: dashed;
}

form.konfig label {
  display: block;
  margin: 0.5rem 0;
  font-size: 0.95rem;
}

form.konfig label.checkbox {
  font-weight: 500;
}

form.konfig label > input[type="text"],
form.konfig label > input[type="number"],
form.konfig label > select {
  display: block;
  width: 100%;
  max-width: 32rem;
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--rahmen);
  border-radius: 3px;
  margin-top: 0.2rem;
  font-family: inherit;
}

form.konfig label.checkbox > input[type="checkbox"] {
  margin-right: 0.4rem;
}

form.konfig .hinweis {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.25rem 0 0.5rem;
}

form.konfig button[type="submit"] {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  background: var(--akzent);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

form.konfig button[type="submit"]:hover {
  filter: brightness(1.05);
}

.meldung {
  padding: 0.5rem 0.75rem;
  border-radius: 3px;
  margin-bottom: 1rem;
}

.meldung.erfolg {
  background: #e3f4ea;
  border: 1px solid #b6dec5;
  color: #135c33;
}

.meldung.fehler {
  background: #fcecec;
  border: 1px solid #e8b3b3;
  color: #7a1818;
}

.hinweis {
  font-size: 0.9rem;
  color: var(--muted);
}

.meldung.hinweis {
  background: #fff4d6;
  border: 1px solid #e9d690;
  color: #6b4f00;
}

.mod-eingabe {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}
.mod-eingabe textarea { flex: 1 1 24rem; min-width: 0; font: inherit; padding: 0.4rem; }
.mod-eingabe label { font-size: 0.9rem; color: var(--muted); }

.vorschlag {
  background: #fff8e1;
  border: 1px solid #e9d690;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-radius: 4px;
}

.constraints { padding-left: 1.25rem; }
.constraints li { margin-bottom: 0.4rem; }

.loesch-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}
.loesch-btn:hover { color: #c93636; }

table.preise {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

table.preise th,
table.preise td {
  padding: 0.2rem 0.6rem;
  border-bottom: 1px solid var(--rahmen);
  text-align: left;
}

table.preise th.num,
table.preise td.num {
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

table.preise td.negativ {
  color: #c93636;
}

nav.subnav {
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rahmen);
}

nav.subnav a {
  margin-right: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

nav.subnav a.aktiv {
  color: var(--fg);
  font-weight: 600;
}

form.profil textarea {
  width: 100%;
  max-width: 24rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rahmen);
  border-radius: 3px;
  resize: vertical;
}

form.profil button[type="submit"] {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  background: var(--akzent);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

form.profil label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
  color: var(--muted);
}

form.nebenbedingungen textarea {
  width: 100%;
  max-width: 56rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rahmen);
  border-radius: 3px;
  resize: vertical;
}

form.nebenbedingungen button[type="submit"] {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  background: var(--akzent);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.charts {
  display: grid;
  gap: 1rem;
  margin: 1rem 0 2rem;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12rem;
  gap: 1rem;
  align-items: start;
  margin: 1rem 0 1.5rem;
}
@media (max-width: 720px) {
  .chart-row { grid-template-columns: 1fr; }
}

.chart h3 {
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-weight: 600;
}

.chart-svg {
  width: 100%;
  max-width: 480px;
  height: auto;
  border: 1px solid var(--rahmen);
  border-radius: 3px;
}

.chart .achs {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.2rem 0 0;
}

.wertebox {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.6rem;
  row-gap: 0.15rem;
  padding: 0.6rem 0.8rem;
  margin: 0;
  border: 1px solid var(--rahmen);
  border-radius: 4px;
  background: #fafbfc;
  font-size: 0.9rem;
}
.wertebox dt { color: var(--muted); }
.wertebox dd { margin: 0; font-variant-numeric: tabular-nums; }
#zeit-box {
  display: inline-grid;
  margin: 1rem 0 1.5rem;
  font-size: 1rem;
}
#zeit-box dd { font-weight: 600; }

table.fahrplan {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  margin-top: 1rem;
}

table.fahrplan th,
table.fahrplan td {
  padding: 0.15rem 0.5rem;
  border-bottom: 1px solid var(--rahmen);
  text-align: left;
}

table.fahrplan th.num,
table.fahrplan td.num {
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

table.fahrplan td.negativ {
  color: #c93636;
}

details.diagnose {
  margin-top: 2rem;
  padding: 0.5rem 1rem;
  background: #f4f5f7;
  border: 1px solid var(--rahmen);
  border-radius: 4px;
  font-size: 0.9rem;
}

details.diagnose > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}

details.diagnose h4 {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

details.diagnose pre.diagnose-zielfunktion,
details.diagnose pre.diagnose-log {
  background: #ffffff;
  border: 1px solid var(--rahmen);
  border-radius: 3px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

details.diagnose table.diagnose-tab {
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.sim-steuer {
  margin-bottom: 1rem;
}

.sim-steuer button,
.mod-eingabe button {
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  background: var(--akzent);
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}

.sim-steuer button:disabled,
.mod-eingabe button:disabled {
  background: #c0c0c0;
  cursor: not-allowed;
}

.sim-status {
  margin-left: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

dl.kennzahlen {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 1rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #fafbfc;
  border: 1px solid var(--rahmen);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

dl.kennzahlen dt {
  font-weight: 600;
  color: var(--muted);
}

dl.kennzahlen dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
