/* Nährstoff-Kompass SH — Prognoserechner
   Palette derived from naehrstoff-kompass-sh.de (portal). */

:root {
  --sh-primary: #365eb8;
  --sh-primary-hover: #284a98;
  --sh-accent: #cc385b;
  --sh-header: #ffffff;
  --sh-page-background: #ffffff;
  --sh-surface: #ffffff;
  --sh-surface-highlight: #eef3ff;
  --sh-border: #c8d2e8;
  --sh-on-primary: #ffffff;
  --sh-footer: #365eb8;
  --sh-text: #26334d;
  --sh-text-muted: #5a6a8a;
  --sh-warn-bg: #fdf2f5;
  --sh-warn-border: #cc385b;
  --sh-ok: #1d7a4f;
  --sh-err: #b02040;
  --focus: #1a46a0;
}

* { box-sizing: border-box; }

html { font-size: 100%; }

body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--sh-text);
  background: var(--sh-page-background);
  line-height: 1.55;
}

/* ---------- header / nav ---------- */

.site-header {
  background: var(--sh-header);
  border-bottom: 3px solid var(--sh-primary);
}

.header-inner {
  max-width: 70rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-logo { height: 52px; width: auto; display: block; }

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sh-primary);
  margin: 0;
  line-height: 1.2;
}
.site-title small {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--sh-text-muted);
}

nav.main-nav { margin-left: auto; }
nav.main-nav ul {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
nav.main-nav a {
  display: block;
  padding: 0.5rem 0.8rem;
  color: var(--sh-text);
  text-decoration: none;
  border-radius: 4px;
}
nav.main-nav a:hover,
nav.main-nav a[aria-current="page"] {
  background: var(--sh-surface-highlight);
  color: var(--sh-primary);
  font-weight: 600;
}

/* ---------- layout ---------- */

main {
  max-width: 70rem;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

.card {
  background: var(--sh-surface);
  border: 1px solid var(--sh-border);
  border-radius: 8px;
  padding: 1.2rem 1.4rem;
  margin: 1rem 0;
}

h1 { font-size: 1.6rem; color: var(--sh-primary); margin: 0.4rem 0 1rem; }
h2 { font-size: 1.25rem; color: var(--sh-text); margin: 1.4rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 0.4rem; }

a { color: var(--sh-primary); }
a:hover { color: var(--sh-primary-hover); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.meta { color: var(--sh-text-muted); font-size: 0.9rem; }
code { background: var(--sh-surface-highlight); padding: 0.1em 0.35em; border-radius: 4px; }

/* ---------- banner ---------- */

.demo-banner {
  background: var(--sh-warn-bg);
  border: 1px solid var(--sh-warn-border);
  border-left-width: 5px;
  color: var(--sh-err);
  padding: 0.6rem 1rem;
  margin: 0 0 1rem;
  font-weight: 600;
  border-radius: 4px;
}

.notice {
  background: var(--sh-surface-highlight);
  border: 1px solid var(--sh-border);
  border-left: 5px solid var(--sh-primary);
  padding: 0.6rem 1rem;
  border-radius: 4px;
}

/* ---------- forms ---------- */

fieldset {
  border: 1px solid var(--sh-border);
  border-radius: 8px;
  padding: 0.8rem 1rem 1rem;
  margin: 0 0 1rem;
}
legend { font-weight: 700; padding: 0 0.4rem; color: var(--sh-primary); }

label { display: block; font-weight: 600; margin: 0.7rem 0 0.25rem; }
label.inline, .inline label { display: inline; font-weight: 400; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--sh-border);
  border-radius: 5px;
  background: #fff;
  color: var(--sh-text);
  max-width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus,
input[type="number"]:focus, select:focus {
  border-color: var(--sh-primary);
}

.field-error {
  color: var(--sh-err);
  font-weight: 600;
  margin: 0.2rem 0 0;
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--sh-err);
  border-width: 2px;
}

.crop-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.6rem;
}
.crop-card { display: block; }
.crop-card input { position: absolute; opacity: 0; }
.crop-card span {
  display: block;
  border: 2px solid var(--sh-border);
  border-radius: 8px;
  padding: 0.9rem 0.6rem;
  text-align: center;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  background: var(--sh-surface);
  transition: border-color 0.15s, background 0.15s;
}
.crop-card input:checked + span {
  border-color: var(--sh-primary);
  background: var(--sh-surface-highlight);
  color: var(--sh-primary);
}
.crop-card input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.crop-card span:hover { border-color: var(--sh-primary-hover); }

.btn {
  font: inherit;
  display: inline-block;
  background: var(--sh-primary);
  color: var(--sh-on-primary);
  border: 0;
  border-radius: 5px;
  padding: 0.6rem 1.3rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  margin-top: 0.8rem;
}
.btn:hover { background: var(--sh-primary-hover); color: var(--sh-on-primary); }
.btn.secondary {
  background: var(--sh-surface-highlight);
  color: var(--sh-primary);
  border: 1px solid var(--sh-border);
}
.btn.warn { background: var(--sh-accent); }
.btn.small { padding: 0.3rem 0.7rem; margin-top: 0; font-size: 0.9rem; }
form.inline { display: inline; }
form.inline .btn { margin-top: 0; }

.hint { font-size: 0.88rem; color: var(--sh-text-muted); margin: 0.2rem 0 0; }

/* ---------- result ---------- */

.result {
  border: 1px solid var(--sh-border);
  border-left: 6px solid var(--sh-primary);
  border-radius: 8px;
  padding: 1rem 1.4rem;
  margin: 1.2rem 0;
  background: var(--sh-surface);
}
.result .big {
  font-size: 2rem;
  font-weight: 700;
  color: var(--sh-primary);
  margin: 0.2rem 0;
}
.result .range { font-size: 1.05rem; color: var(--sh-text); }
.warn-list {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
}
.warn-list li {
  background: var(--sh-warn-bg);
  border: 1px solid var(--sh-warn-border);
  border-radius: 5px;
  padding: 0.45rem 0.8rem;
  margin: 0.4rem 0;
  color: var(--sh-err);
}
.warn-inline {
  background: var(--sh-warn-bg);
  border: 1px solid var(--sh-warn-border);
  border-radius: 5px;
  padding: 0.45rem 0.8rem;
  color: var(--sh-err);
}
.ok { color: var(--sh-ok); font-weight: 600; }
.err { color: var(--sh-err); font-weight: 600; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
.badge.demo { background: var(--sh-accent); color: #fff; }

details.model-details { margin-top: 0.8rem; }
details.model-details summary { cursor: pointer; font-weight: 600; color: var(--sh-primary); }

/* ---------- svg charts ---------- */

svg.chart { max-width: 100%; height: auto; display: block; margin: 0.5rem 0; }
svg.chart .ax { stroke: var(--sh-border); stroke-width: 1; }
svg.chart .tick { fill: var(--sh-text-muted); font-size: 11px; }
svg.chart .axlabel { fill: var(--sh-text); font-size: 12px; font-weight: 600; }
svg.chart .band { fill: var(--sh-surface-highlight); }
svg.chart .curve { stroke: var(--sh-primary); stroke-width: 2.5; fill: none; }
svg.chart .curve-old { stroke: var(--sh-text-muted); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
svg.chart .marker { fill: var(--sh-accent); stroke: #fff; stroke-width: 2; }
svg.chart .marker-line { stroke: var(--sh-accent); stroke-width: 1.2; stroke-dasharray: 4 3; }
svg.chart .pt { fill: var(--sh-primary); fill-opacity: 0.55; }
svg.chart .pt.new { fill: var(--sh-accent); fill-opacity: 0.85; }
svg.chart .legend { fill: var(--sh-text-muted); font-size: 11px; }

/* ---------- tables ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8rem 0;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--sh-border);
  vertical-align: top;
}
th { background: var(--sh-surface-highlight); color: var(--sh-text); }
tr:hover td { background: #f7f9fe; }
.table-scroll { overflow-x: auto; }

/* ---------- admin ---------- */

.admin-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid var(--sh-border);
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
}
.admin-nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--sh-text);
}
.admin-nav a[aria-current="page"], .admin-nav a:hover {
  background: var(--sh-surface-highlight);
  color: var(--sh-primary);
}
.admin-nav .who { margin-left: auto; color: var(--sh-text-muted); font-size: 0.9rem; }

/* ---------- footer ---------- */

.site-footer {
  background: var(--sh-footer);
  color: var(--sh-on-primary);
  margin-top: 3rem;
}
.footer-inner {
  max-width: 70rem;
  margin: 0 auto;
  padding: 1.4rem 1rem 2rem;
}
.site-footer a { color: var(--sh-on-primary); }
.funding-logos {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.8rem 0;
}
.funding-logos img {
  height: 56px;
  width: auto;
  background: #fff;
  border-radius: 4px;
  padding: 4px;
}
.footer-links { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: 0.9rem; }

/* ---------- embed mode ---------- */

body.embed .site-header,
body.embed .site-footer,
body.embed .no-embed { display: none; }
body.embed main { padding: 0.4rem 0.4rem 1rem; }
body.embed { font-size: 0.95rem; }

/* ---------- responsive ---------- */

@media (max-width: 40rem) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  nav.main-nav { margin-left: 0; }
  h1 { font-size: 1.3rem; }
  .result .big { font-size: 1.5rem; }
  th, td { padding: 0.35rem 0.4rem; font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .site-header nav, .site-footer, .btn, form { display: none; }
  body { font-size: 11pt; }
}

/* ---- Umrechner additions ---- */
.ampel { display:inline-block; width:.8em; height:.8em; border-radius:50%; }
.ampel-0 { background:#2e7d32; }
.ampel-1 { background:#f9a825; }
.ampel-2 { background:#c62828; }
tr.lvl-1 { background:#fff8e1; }
tr.lvl-2 { background:#ffebee; }
.warn, .warn-row td { color:#8a6d00; }
.warn { background:#fff8e1; padding:.6em; border-left:4px solid #f9a825; }
.ok { background:#e8f5e9; padding:.6em; border-left:4px solid #2e7d32; }
.excluded td { color:#999; text-decoration:line-through; }
.edit-table input { width:95%; }
.logout-form { display:inline; margin:0; }
.linkbtn { background:none; border:none; color:inherit; cursor:pointer;
           text-decoration:underline; font:inherit; padding:0; }
.meta-grid { display:grid; grid-template-columns:12em 1fr; gap:.3em .8em; }
.meta-grid dt { font-weight:bold; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:.6em 1.2em; }
.grid-2 label { display:block; }
.chart-card svg.chart { width:100%; height:auto; }
.chart .grid { stroke:#ddd; stroke-width:1; }
.chart .axis { stroke:#555; stroke-width:1.4; }
.chart .tick { font-size:11px; fill:#555; }
.chart .axis-label { font-size:12px; fill:#333; }
.chart .whisker { stroke:#888; stroke-width:1.2; }
.chart .pt-ok { fill:#2e7d32; }
.chart .pt-hint { fill:#f9a825; }
.chart .pt-bad { fill:#c62828; }
.secondary.small { font-size:.85em; padding:.2em .5em; }
.inline-form { display:inline; }
.admin-nav ul { line-height:1.9; }
textarea#zeilen { width:100%; font-family:monospace; margin-top:.8em; }
.check { display:block; font-weight:normal; }
.vergleich-box { margin-top:.6em; }
.hint { color:#555; font-size:.9em; }
.kultur-wahl { display:flex; gap:.8em; flex-wrap:wrap; }
.kultur-wahl .kachel { flex:1 1 14em; display:block; padding:.7em 1em;
  border:2px solid #cfd8dc; border-radius:8px; text-decoration:none;
  color:inherit; background:#fafafa; }
.kultur-wahl .kachel small { display:block; color:#555; margin-top:.15em; }
.kultur-wahl .kachel.aktiv { border-color:#2e7d32; background:#e8f5e9;
  font-weight:bold; }
