/* ===========================================================
   Beer Inventory Game – Layout im Stil von wibfin.de
   Farben und Schrift wie in der WIBFIN-Website (style.css).
   =========================================================== */
:root {
  --teal: #2e6c6b;
  --teal-dark: #1f4d4c;
  --teal-light: #e8f1f1;
  --teal-mid: #d5e6e4;
  --text: #222222;
  --soft: #555555;
  --line: #d5e3e2;
  --bg: #ffffff;
  --amber: #c8860d;          /* Regionallager */
  --amber-light: #f8ecd4;
  --c-inv: #2e6c6b;          /* Bestandskosten */
  --c-tra: #7fb3b0;          /* Transportkosten */
  --c-loc: #c8860d;          /* Standortkosten */
  --good: #2f7d4a;
  --bad: #b23a2a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Verdana, Arial, sans-serif;
  --max: 1100px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.55; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }
h1 { font-size: 26px; line-height: 1.25; color: var(--teal-dark); margin: 0 0 .5rem; text-wrap: balance; }
h2 { font-size: 18px; color: var(--teal-dark); margin: 0 0 .8rem; }
h3 { font-size: 16px; color: var(--teal-dark); margin: 1.4rem 0 .3rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--soft); }
.mt { margin-top: 1.6rem; }

/* ---------- Kopfband ---------- */
.band { background: var(--teal-light); position: sticky; top: 0; z-index: 10; }
.band__inner, .foot__inner, .wrap { max-width: var(--max); margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.band__inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 8px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--teal-dark); min-width: 0; }
.brand__mark { height: 40px; width: auto; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__text strong { font-size: 16px; }
.brand__text span { font-size: 13px; color: var(--soft); }
.band__right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.mainnav { display: flex; gap: 16px; font-size: 15px; }
.mainnav a { color: var(--teal-dark); padding: 4px 0; border-bottom: 2px solid transparent; }
.mainnav a.is-active { border-bottom-color: var(--teal); font-weight: 600; }
.langs { display: flex; gap: 4px; align-items: center; font-size: 13px; font-weight: 600; color: rgba(0,0,0,.3); }
.langs a { color: var(--soft); padding: 2px 4px; }
.langs a.is-active { color: var(--teal-dark); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.logout { font-size: 13px; color: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; background: #fff; }

.wrap { padding-block: 28px 48px; }

/* ---------- Schaltflächen ---------- */
.btn {
  display: inline-block; font: 600 14px/1 var(--font); padding: 11px 18px; border-radius: 8px;
  border: 1.5px solid var(--teal); background: var(--teal); color: #fff; cursor: pointer;
}
.btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn--ghost { background: var(--teal-light); color: var(--teal-dark); border-color: #b9d3d1; }
.btn--ghost:hover { background: var(--teal-mid); color: var(--teal-dark); }
.btn--small { padding: 7px 12px; font-size: 13px; }
.btn--big { padding: 14px 24px; font-size: 16px; }
.btn:focus-visible, .linkbtn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--teal); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; }
.js .nojs-only { display: none; }

/* ---------- Meldungen ---------- */
.msg { padding: 8px 12px; border-radius: 8px; margin: 0 0 12px; font-size: 14px; }
.msg--error { background: #fbeceb; color: var(--bad); border: 1px solid #efc4c0; }
.msg--ok { background: #e9f4ec; color: var(--good); border: 1px solid #bfe0c9; }

/* ---------- Login ---------- */
.login { max-width: 460px; margin: 3rem auto; text-align: center; }
.login__img { width: 220px; max-width: 70%; margin-bottom: 1rem; }
.login__form { margin: 1.4rem 0 1rem; text-align: left; }
.login__form label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.login__row { display: flex; gap: 8px; }
.login__row input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; }
.login__row input:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.login__note { font-size: 13px; color: var(--soft); }

/* ---------- Startseite ---------- */
.story { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.story__text { max-width: 68ch; }
.story__text p { margin: 0 0 1rem; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); }
.story__side { position: sticky; top: 90px; }
.story__side img { width: 100%; height: auto; margin-bottom: 1rem; }
.learn { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.learn li { background: var(--teal-light); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; font-size: 14px; }
.learn strong { color: var(--teal-dark); }
@media (max-width: 860px) { .story { grid-template-columns: minmax(0, 1fr); } .story__side { position: static; } .story__side img { max-width: 360px; } }

/* ---------- Spielseite ---------- */
.game-head { margin-bottom: 18px; max-width: 75ch; }
.game-head p { margin: 0; color: var(--soft); }
.game { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.game__left, .game__right { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 900px) { .game { grid-template-columns: minmax(0, 1fr); } }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; background: #fff; min-width: 0; }
.card--wide { margin-top: 20px; }

/* Entscheidungsmatrix */
.matrix { display: grid; gap: 8px; }
.matrix__row { display: grid; grid-template-columns: 90px repeat(3, minmax(0, 1fr)); gap: 8px; align-items: center; }
.matrix__row--head span { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--teal); text-align: center; }
.matrix__row--head span:first-child { text-align: left; }
.matrix__region { font-weight: 600; color: var(--teal-dark); }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; margin: 0; padding: 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { flex: 1; text-align: center; padding: 8px 4px; font-size: 13px; cursor: pointer; color: var(--soft); background: #fff; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg label + input + label { border-left: 1.5px solid var(--line); }
.seg input:checked + label { font-weight: 600; }
.seg input[value="0"]:checked + label { background: var(--teal); color: #fff; }
.seg input[value="1"]:checked + label { background: var(--amber); color: #fff; }
.seg input:focus-visible + label { outline: 3px solid var(--teal-dark); outline-offset: -3px; }
.decide__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
@media (max-width: 520px) {
  .matrix__row { grid-template-columns: 64px repeat(3, minmax(0, 1fr)); gap: 5px; }
  .seg { flex-direction: column; }
  .seg label { font-size: 12px; padding: 6px 2px; }
  .seg label + input + label { border-left: 0; border-top: 1.5px solid var(--line); }
}

/* Gesamtkosten */
.total { background: var(--teal-light); border-radius: 14px; padding: 18px 20px; display: grid; gap: 2px; }
.total__label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); }
.total__value { font-size: 40px; font-weight: 700; color: var(--teal-dark); line-height: 1.1; font-variant-numeric: tabular-nums; }
.total__unit { font-size: 13px; color: var(--soft); }
.total__delta { font-size: 13px; font-weight: 600; margin-top: 4px; }
.total__delta.is-better { color: var(--good); }
.total__delta.is-worse { color: var(--bad); }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 14px 0 10px; background: #fff; }
.bar span { display: block; height: 100%; transition: width .3s ease; }
.c-inv { background: var(--c-inv); } .c-tra { background: var(--c-tra); } .c-loc { background: var(--c-loc); }
.split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.split div { background: #fff; border-radius: 8px; padding: 8px 10px; min-width: 0; }
.split dt { font-size: 12px; color: var(--soft); display: flex; align-items: center; gap: 6px; }
.split dd { margin: 2px 0 0; font-weight: 700; font-size: 17px; color: var(--teal-dark); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; margin-right: 6px; vertical-align: -1px; }
@media (max-width: 520px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* Netzwerk */
.net { width: 100%; height: auto; max-width: 380px; display: block; margin: 0 auto; }
.net line, .net polyline { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.net .l-central { stroke: var(--teal); }
.net .l-regional { stroke: var(--amber); }
.net .l-off { stroke: #d9e2e1; stroke-dasharray: 3 7; stroke-width: 3; }
.net .wh path, .net .wh rect { stroke-width: 3; stroke-linejoin: round; }
.net .wh.is-on path { fill: var(--amber-light); stroke: var(--amber); }
.net .wh.is-on rect { fill: #fff; stroke: var(--amber); }
.net .wh.is-off path, .net .wh.is-off rect { fill: #fff; stroke: #c9d6d5; }
.net .cust circle { fill: var(--teal-light); stroke: var(--teal-dark); stroke-width: 3; }
.net .cust path { fill: none; stroke: var(--teal-dark); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.net .plant path, .net .plant rect { fill: var(--teal-light); stroke: var(--teal-dark); stroke-width: 3; stroke-linejoin: round; }
.net .lbl { font: 600 13px var(--font); fill: var(--teal-dark); text-anchor: middle; }
.net .lbl--strong { font-weight: 700; text-anchor: start; }
.net .chip rect { stroke-width: 1.5; }
.net .chip text { font: 700 11px var(--font); text-anchor: middle; }
.net .chip--c rect { fill: #fff; stroke: var(--teal); } .net .chip--c text { fill: var(--teal-dark); }
.net .chip--r rect { fill: #fff; stroke: var(--amber); } .net .chip--r text { fill: #8a5a00; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 8px 0 0; font-size: 13px; color: var(--soft); }
.legend li { display: flex; align-items: center; gap: 6px; }
.ln { display: inline-block; width: 22px; height: 0; border-top: 4px solid; border-radius: 2px; }
.ln--c { border-color: var(--teal); } .ln--r { border-color: var(--amber); } .ln--off { border-top: 3px dotted #c9d6d5; }

/* Tabellen */
.tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tables--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .tables, .tables--3 { grid-template-columns: minmax(0, 1fr); } }
.tbl-wrap { overflow-x: auto; min-width: 0; }
.tbl { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl caption { text-align: left; font-weight: 600; color: var(--teal-dark); padding-bottom: 6px; }
.tbl th, .tbl td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child { text-align: left; }
.tbl thead th { font-size: 12px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--teal); }
.tbl tbody th { font-weight: 500; color: var(--text); }
.tbl td.is-zero { color: #b7c4c3; }
.tbl td.sum, .tbl .sumrow td, .tbl .sumrow th { font-weight: 700; color: var(--teal-dark); }
.tbl .sumrow td, .tbl .sumrow th { border-top: 2px solid var(--teal); border-bottom: 0; }

/* Versuche */
.tries-wrap { max-height: 330px; overflow-y: auto; margin-bottom: 8px; }
.tries td { vertical-align: middle; }
.tries .code { text-align: left; }
.tries td:last-child { white-space: nowrap; }
.code__grp { display: inline-flex; align-items: center; gap: 2px; margin: 2px 8px 2px 0; font-size: 12px; white-space: nowrap; }
.code__grp b { font-weight: 600; color: var(--soft); margin-right: 2px; }
.code__grp i { font-style: normal; width: 16px; height: 18px; line-height: 18px; text-align: center; border-radius: 3px; background: var(--teal); color: #fff; font-size: 11px; font-weight: 700; }
.code__grp i.on { background: var(--amber); }
.tries .code small { display: block; font-size: 11px; }
.tries tr.is-current td { background: #f4f9f8; }
.badge { display: inline-block; background: var(--good); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; vertical-align: 1px; }

/* Aufklappbereiche */
details.card > summary { cursor: pointer; font-size: 17px; font-weight: 600; color: var(--teal-dark); list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; display: inline-block; width: 1.2em; color: var(--teal); transition: transform .2s; }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: .8rem; }
.how ul { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; max-width: 80ch; }

/* Parameterformular */
.pform { display: grid; gap: 18px; }
.tbl--form input { width: 100%; min-width: 70px; max-width: 120px; font: inherit; font-size: 14px; padding: 6px 8px; border: 1.5px solid var(--line); border-radius: 6px; text-align: right; }
.tbl--form input:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
.tbl--form tbody th small { display: block; font-size: 11.5px; color: var(--soft); font-weight: 400; }
.tbl--form tr.calc td { color: var(--teal-dark); font-weight: 600; }
.tbl--form tr.grp th, .tbl--form tr.grp td { border-top: 2px solid var(--teal-mid); }
.pform__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Lädt gerade */
.is-busy [data-part] { opacity: .65; transition: opacity .15s; }

/* ---------- Fußzeile ---------- */
.foot { border-top: 1px solid var(--line); background: var(--teal-light); }
.foot__inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-block: 16px; font-size: 13px; color: var(--soft); }
.foot nav { display: flex; gap: 16px; flex-wrap: wrap; }

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