/* ==================================================================
   Supplychaingame – Grundlayout im WIBFIN-Stil:
   ruhiges Petrol (#2e6c6b) wie die Strichzeichnungen, viel Weißraum.
   Farben zentral als Variablen.
   ================================================================== */
:root {
    --petrol:   #2e6c6b;   /* Hauptfarbe (Zeichnungen, Buttons) */
    --dunkel:   #1d3f3e;   /* Text, Kopfzeile */
    --hell:     #f5f9f9;   /* Seitenhintergrund */
    --karte:    #ffffff;
    --rand:     #d5e3e2;
    --zart:     #e8f1f0;   /* Flächen, Hover */
    --muted:    #5b7473;   /* Nebentext (Kontrast > 4,5:1 auf Weiß) */
    --ok:       #2e7d32;
    --fehler:   #b3261e;
    --akzent:   #c8860d;   /* sparsam: Hinweise */
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--hell);
    color: var(--dunkel);
    line-height: 1.45;
}

a {
    color: var(--petrol);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: .2em;
    text-decoration-color: rgba(46, 108, 107, .35);
}
a:hover { color: var(--dunkel); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
    outline: 2px solid var(--petrol); outline-offset: 2px; border-radius: 3px;
}

/* ---------- Kopfzeile ---------- */
.topbar {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem;
    padding: .6rem 1rem; background: var(--karte); border-bottom: 3px solid var(--petrol);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--petrol); text-decoration: none;
         font-weight: 700; font-size: 1.15rem; }
.brand:hover { color: var(--dunkel); }
.logo-svg { width: 34px; height: 34px; }
.top-right { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: .9rem; }
.langs { display: inline-flex; border: 1px solid var(--rand); border-radius: 999px; overflow: hidden; }
.langs a { padding: .15rem .6rem; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .8rem; }
.langs a.active { background: var(--petrol); color: #fff; }

.content { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.page-title { display: flex; align-items: center; gap: .6rem; margin: .5rem 0 1rem; color: var(--dunkel); }
.title-icon { width: 40px; height: 40px; color: var(--petrol); flex: none; }

/* ---------- Zeichnungen und Symbole ---------- */
.icon { width: 28px; height: 28px; color: var(--petrol); flex: none; }
.h-icon { width: 30px; height: 30px; vertical-align: middle; margin-right: .45rem; }
.drawing { color: var(--petrol); width: 100%; height: auto; }
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: center; margin-bottom: 1rem; }
.hero-drawing { max-width: 460px; justify-self: center; }
.side-drawing { max-width: 420px; display: block; margin: 1rem auto; opacity: .9; }
.lead { font-size: 1.15rem; }
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li { display: flex; gap: .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--zart); }
.feature-list li:last-child { border-bottom: 0; }
@media (max-width: 700px) { .hero { grid-template-columns: 1fr; } }

/* ---------- Karten und Raster ---------- */
.card {
    background: var(--karte); border: 1px solid var(--rand); border-radius: 10px;
    padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.card h2 { margin-top: 0; font-size: 1.1rem; display: flex; align-items: center; }
.card h3 { font-size: 1rem; margin: .2rem 0 .6rem; display: flex; align-items: center; }
.narrow { max-width: 420px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid > * { min-width: 0; }   /* breite Tabellen scrollen in .table-scroll statt überzulaufen */
@media (max-width: 420px) { .grid.two { grid-template-columns: 1fr; } }

/* ---------- Formulare ---------- */
label { display: block; margin-bottom: .75rem; font-size: .9rem; }
input, select {
    display: block; width: 100%; margin-top: .25rem; padding: .5rem;
    border: 1px solid var(--rand); border-radius: 6px; font-size: 1rem; background: #fff; color: var(--dunkel);
}
input:disabled, select:disabled { background: var(--zart); color: var(--muted); }
button, a.button {
    display: inline-block; background: var(--petrol); color: #fff; border: 0; border-radius: 6px;
    padding: .6rem 1.2rem; font-size: 1rem; cursor: pointer; text-decoration: none;
}
button:hover, a.button:hover { background: var(--dunkel); color: #fff; }
button.secondary { background: #fff; color: var(--petrol); border: 1px solid var(--petrol); }
button.secondary:hover { background: var(--zart); color: var(--dunkel); }
button.danger { background: var(--fehler); }
button.small, a.button.small { padding: .25rem .6rem; font-size: .85rem; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.actions form { margin: 0; }
.actions label { margin: 0; }
label.check { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
label.check input { width: auto; margin: 0; }
fieldset.checks { border: 1px solid var(--rand); border-radius: 8px; padding: .5rem .9rem .3rem; margin: .5rem 0 .8rem; }
fieldset.checks legend { font-size: .9rem; padding: 0 .3rem; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; }
.inline-form { display: flex; gap: .4rem; align-items: center; margin: 0; }
.inline-form input { margin: 0; min-width: 8rem; padding: .3rem .4rem; font-size: .9rem; }
.row-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.input-table input { margin: 0; min-width: 110px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--hell); padding: .75rem 0; border-top: 1px solid var(--rand); }
.param-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.param-grid label.changed span { font-weight: 700; }
.param-grid label.changed input, .param-grid label.changed select { border-color: var(--petrol); background: var(--zart); }
.param-group summary { cursor: pointer; list-style: none; }
.param-group summary h2 { display: inline; }
.param-group summary::before { content: "▸ "; color: var(--petrol); }
.param-group[open] summary::before { content: "▾ "; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .4rem .5rem; border-bottom: 1px solid var(--rand); text-align: left; vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
tr.sum td { font-weight: 700; border-top: 2px solid var(--dunkel); }
tr.sub td { font-weight: 600; }
tr.group th { padding-top: .8rem; color: var(--dunkel); font-size: .95rem; }
tr.detail td { font-size: .9rem; }
tr.detail td:first-child { padding-left: 1.2rem; }
.table-scroll { overflow-x: auto; }
table.journal td { font-size: .88rem; }
.neg { color: var(--fehler); }
.hint { font-size: .85rem; color: var(--muted); }
code { background: var(--zart); padding: .05rem .35rem; border-radius: 4px; }

/* ---------- GuV mit Aufklappen bis zur Buchung ---------- */
.pl > * { border-bottom: 1px solid var(--rand); }
.pl summary, .pl-line.static, .pl-sub { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem .5rem; }
.pl summary { cursor: pointer; list-style: none; }
.pl summary::-webkit-details-marker { display: none; }
.pl summary span:first-child::before { content: "▸ "; color: var(--petrol); }
.pl details[open] summary span:first-child::before { content: "▾ "; }
.pl summary:hover { background: var(--zart); }
.pl-line.static span:first-child { padding-left: 1rem; }
.pl-sub { font-weight: 600; background: var(--zart); }
.pl-total { font-weight: 700; border-top: 2px solid var(--dunkel); }
.pl-detail { padding: .2rem .5rem .6rem 1.4rem; font-size: .88rem; }
.acc-row { display: flex; justify-content: space-between; font-weight: 600; padding: .2rem 0; }
ul.bookings { list-style: none; margin: 0 0 .4rem; padding: 0 0 0 .8rem; color: var(--muted); }
ul.bookings li { display: flex; justify-content: space-between; gap: 1rem; padding: .1rem 0; }

/* ---------- Kacheln ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--karte); border: 1px solid var(--rand); border-left: 4px solid var(--petrol);
       border-radius: 8px; padding: .7rem .85rem; min-width: 0; position: relative; }
.kpi > span { display: block; font-size: .85rem; color: var(--muted); }
.kpi strong { font-size: 1.25rem; white-space: nowrap; }
.kpi-icon { position: absolute; right: .6rem; top: .6rem; width: 26px; height: 26px; opacity: .55; }

/* ---------- Hinweise, Meldungen, Status ---------- */
.callout { background: var(--zart); border: 1px solid var(--petrol); border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem; }
.callout p { margin: .4rem 0; }
.msg { padding: .75rem 1rem; border-radius: 8px; }
.msg.ok { background: #e8f5e9; color: var(--ok); }
.msg.error { background: #fdecea; color: var(--fehler); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 10px; font-size: .85rem; background: var(--zart); }
.badge-running { background: #e8f5e9; color: var(--ok); }
.badge-setup { background: #fff3cd; }
.light { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle;
         margin-right: .35rem; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.light-open { background: #d93025; }
.light-draft { background: #f2b600; }
.light-submitted { background: #2e9d43; }
ul.players { list-style: none; padding: 0; margin: 0; }
ul.players li { padding: .35rem 0; border-bottom: 1px solid var(--rand); }
.card.danger { border-color: var(--fehler); }
.bar { display: inline-block; width: 80px; height: 8px; background: var(--zart); border-radius: 4px; vertical-align: middle; overflow: hidden; }
.bar.wide { width: 100%; }
.bar > span { display: block; height: 100%; background: var(--petrol); }

/* ---------- ⓘ-Erklärungen ---------- */
.info {
    display: inline-flex; align-items: center; justify-content: center; position: relative;
    width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 1.5px solid var(--petrol); color: var(--petrol);
    font-size: .72rem; font-weight: 700; font-style: italic; cursor: help; vertical-align: middle; font-family: Georgia, serif;
}
.info .tip {
    display: none; position: absolute; z-index: 20; left: 50%; top: 1.5rem; transform: translateX(-50%);
    width: min(300px, 80vw); background: var(--dunkel); color: #fff; padding: .6rem .75rem; border-radius: 8px;
    font: 400 .85rem/1.4 system-ui, sans-serif; text-align: left; white-space: normal;
}
.info:hover .tip, .info:focus .tip, .info.open .tip { display: block; }

/* ---------- Reiter (Spieler) und Quartalsauswahl ---------- */
.tabs { background: var(--karte); border-bottom: 1px solid var(--rand); position: sticky; top: 0; z-index: 10; }
.tabs-wrap { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; }
.tabs-game { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.tabs-links { display: flex; overflow-x: auto; scrollbar-width: none; }
.tabs-links::-webkit-scrollbar { display: none; }
.tabs a { display: flex; align-items: center; gap: .35rem; padding: .6rem .8rem .55rem; text-decoration: none;
          color: var(--dunkel); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { background: var(--zart); }
.tabs a.active { border-bottom-color: var(--petrol); font-weight: 700; }
.tab-icon { width: 20px; height: 20px; }
.tabs .dot { width: 8px; height: 8px; border-radius: 50%; background: #d93025; display: inline-block; }
@media (max-width: 700px) {
    .tabs-wrap { display: block; padding: 0; }
    .tabs-game { display: block; max-width: none; padding: .35rem 1rem 0; }
    .tabs a { padding: .5rem .6rem; font-size: .9rem; }
}
.quarter-nav { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.quarter-nav a { padding: .25rem .65rem; border: 1px solid var(--rand); border-radius: 999px; text-decoration: none; background: #fff; }
.quarter-nav a.active { background: var(--petrol); color: #fff; border-color: var(--petrol); }

/* ---------- Fußzeile und Rechtliches ---------- */
.footer { text-align: center; font-size: .85rem; color: var(--muted); padding: 1.5rem 1rem; border-top: 1px solid var(--rand); margin-top: 2rem; }
dialog.legal-dialog { width: min(760px, 94vw); max-height: 88vh; padding: 0; border: 0; border-radius: 12px; }
dialog.legal-dialog[open] { display: flex; flex-direction: column; }
dialog.legal-dialog::backdrop { background: rgba(29, 63, 62, .45); }
dialog .cd-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--rand); }
dialog .cd-head h2 { margin: 0; font-size: 1.15rem; }
.cd-close { background: none; color: var(--dunkel); font-size: 1.5rem; padding: 0 .4rem; }
.cd-close:hover { background: var(--zart); color: var(--dunkel); }
.legal-body { padding: .5rem 1.25rem 1.25rem; overflow-y: auto; }
.legal-body h3, .legal-page h3 { font-size: 1rem; margin: 1rem 0 .3rem; }

/* Feinschliff nach Test: Beträge nie umbrechen, Balken in Tabellen unter dem Wert,
   Bestelltabelle am Handy schmaler */
.num { white-space: nowrap; }
.report td .bar { display: block; width: 100%; margin-top: .35rem; }
@media (max-width: 600px) {
    .input-table input { min-width: 5.5rem; }
    .input-table th, .input-table td { padding: .35rem .3rem; }
    .title-icon { width: 32px; height: 32px; }
    .page-title { font-size: 1.5rem; }
}

/* ==================================================================
   Historie: Quartale als Spalten, erste Spalte bleibt beim Wischen stehen
   (übernommen aus dem Beerbusinessgame, Farben angepasst)
   ================================================================== */
.htable th, .htable td { white-space: nowrap; }
.htable tr > th:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--karte); text-align: left; font-weight: 400; color: var(--dunkel); font-size: .9rem;
    box-shadow: 1px 0 0 var(--rand);
}
.htable tr:first-child th { font-weight: 700; }
.htable tr.group th, .htable tr.group td {
    background: var(--zart); font-weight: 700; font-size: .8rem;
    text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding-top: .7rem;
}
@media (max-width: 600px) {
    .htable tr > th:first-child { white-space: normal; min-width: 9.5rem; max-width: 9.5rem; font-size: .85rem; line-height: 1.25; }
    .htable td { font-size: .9rem; }
}
.htable td.empty { color: #b4c7c6; }
.htable tbody tr:hover td { background: var(--hell); }
.htable .lbl { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
button.row-chart {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; border-radius: 5px;
    background: transparent; border: 1px solid var(--rand); color: var(--petrol); cursor: pointer;
}
button.row-chart svg { fill: currentColor; }
button.row-chart:hover, button.row-chart:focus-visible { background: var(--petrol); color: #fff; border-color: var(--petrol); }
[hidden] { display: none !important; }

/* Diagramme (app/charts.php, js/charts.js) */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem 1.5rem; }
.charts > * { min-width: 0; }
figure.chart { margin: 0 0 .5rem; }
figure.chart figcaption { font-weight: 700; font-size: .95rem; margin-bottom: .4rem; }
.chart-box { position: relative; height: 220px; }
figure.chart .hint { margin: .3rem 0 0; }
@media (max-width: 600px) { .charts { grid-template-columns: 1fr; } .chart-box { height: 200px; } }
dialog.chart-dialog {
    width: min(640px, 94vw); padding: 1rem 1.25rem; border: 0; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--dunkel);
}
dialog.chart-dialog::backdrop { background: rgba(29, 63, 62, .45); }
dialog.chart-dialog .cd-head { padding: 0 0 .5rem; border: 0; }
.cd-box { height: 280px; }
dialog.chart-dialog .hint { margin: .5rem 0 0; }
@media (max-width: 600px) { .cd-box { height: 240px; } dialog.chart-dialog { padding: .85rem; } }

/* Hilfe */
details.help summary { cursor: pointer; list-style: none; }
details.help summary::-webkit-details-marker { display: none; }
details.help summary h2 { display: inline; }
details.help summary::before { content: "▸ "; color: var(--petrol); font-weight: 700; }
details.help[open] summary::before { content: "▾ "; }
details.help[open] summary { margin-bottom: .6rem; display: block; }
details.help dt { font-weight: 700; margin-top: .6rem; }
details.help dd { margin: .15rem 0 0 0; }
details.help li { margin-bottom: .35rem; }
details.help table { max-width: 640px; }
.formula { background: var(--zart); border-left: 4px solid var(--petrol); padding: .5rem .75rem; border-radius: 4px; font-weight: 600; }

/* Moderator-Hilfe */
.toc a { margin: 0 .1rem; }
.help-section h3 { margin: 1rem 0 .4rem; }
.help-section dt, .kpi-list dt { font-weight: 700; margin-top: .5rem; }
.help-section dd, .kpi-list dd { margin: .1rem 0 0; }
.help-section li { margin-bottom: .3rem; }
.help-section table.report { max-width: 760px; }

/* Solo-Modus */
.solo-toggle { margin-top: .25rem; font-weight: 600; }
.solo-fields { border-left: 3px solid var(--petrol); padding: .2rem 0 .2rem .8rem; margin-bottom: .8rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
tr.highlight td { background: var(--zart); font-weight: 600; }
.bot { font-size: .8rem; color: var(--muted); }
.template-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto auto; gap: .75rem; align-items: end;
                border-top: 1px solid var(--rand); padding-top: .75rem; }
.template-row label { margin-bottom: 0; }
.template-delete { margin: .4rem 0 .9rem; }
.new-template { border-top: 1px solid var(--rand); padding-top: .9rem; align-items: end; }
.new-template label { margin: 0; min-width: 240px; }
a.button.secondary-link { background: #fff; color: var(--petrol); border: 1px solid var(--petrol); }
a.button.secondary-link:hover { background: var(--zart); color: var(--dunkel); }
@media (max-width: 700px) { .template-row { grid-template-columns: 1fr 1fr; } }
.kpi > span { padding-right: 2rem; }

/* Reiterleiste Moderatoren/Superuser: Hilfe und Passwort rechts */
.staff-tabs .tabs-links { flex: 1; }
.tabs-spacer { flex: 1; min-width: 1rem; }
.tab-game-name { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
@media (max-width: 700px) { .tabs-spacer { flex: 0 0 1rem; } .tab-game-name { max-width: 9rem; } }

/* ==================================================================
   Supplychaingame: Cockpit, Kette, Chat, Nachfrage
   ================================================================== */
table.kv th { width: 45%; color: var(--dunkel); font-weight: 400; }
table.kv td { font-weight: 600; }
.report th.mine { color: var(--petrol); border-bottom: 3px solid var(--petrol); }
.logistics td:first-child { min-width: 14rem; }
.order-card { border: 2px solid var(--petrol); }
.order-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .25rem 1rem; }
.order-grid label span { font-weight: 700; }
.order-grid input { font-size: 1.25rem; font-weight: 700; }
.order-grid small { display: block; margin-top: .3rem; }
ul.chain-status { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: 0; margin: 0; }
ul.chain-status li { display: flex; align-items: center; gap: .1rem; padding: .3rem .6rem; border: 1px solid var(--rand); border-radius: 999px; }
ul.chain-status li.mine { border-color: var(--petrol); font-weight: 700; }
ul.chain-status .light-text { margin-left: .35rem; font-weight: 400; font-size: .85rem; }
.callout.final { border-width: 2px; }
.chain-sum { font-weight: 400; font-size: .95rem; margin-left: .3rem; }
.demand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .4rem .6rem; margin-bottom: .5rem; }
.demand-grid label { margin: 0; font-size: .8rem; color: var(--muted); }
.demand-grid input { padding: .35rem; }
.demand-grid label.locked input { background: var(--zart); }
.gen-form label { width: 7rem; }
.chat-list { height: 230px; overflow-y: auto; border: 1px solid var(--rand); border-radius: 8px; padding: .5rem .7rem; background: var(--hell); margin-bottom: .6rem; }
.chat-msg { margin: 0 0 .35rem; font-size: .92rem; overflow-wrap: anywhere; }
.chat-head { color: var(--muted); font-size: .8rem; }
.chat-all .chat-head { color: var(--petrol); font-weight: 700; }
.chat-form { display: flex; gap: .4rem; }
.chat-form input { margin: 0; }
.chat-form select { width: auto; margin: 0; }
.template-row { grid-template-columns: 2fr 1.3fr .8fr .8fr auto auto; }
@media (max-width: 700px) { .template-row { grid-template-columns: 1fr 1fr; } }

/* Logistiktabelle: Beschriftung links, Diagrammknopf rechts in der ersten Spalte */
.logistics .lbl { display: flex; align-items: center; justify-content: flex-start; gap: .4rem; }
.logistics button.row-chart { width: 24px; height: 24px; }
/* Geschichte zum Spiel (Moderator/M1) */
.story { white-space: pre-line; }
.story-card summary { cursor: pointer; font-weight: 700; }
textarea { display: block; width: 100%; margin-top: .25rem; padding: .5rem; border: 1px solid var(--rand);
           border-radius: 6px; font: inherit; color: var(--dunkel); min-height: 9rem; }
