/* Stammbaum – Keplinger Corporate Design: Arial, Navy #183E74, Gelb #FFEA00, Amber #FABB0C,
   Hellblau #B9C4D4, Zeilengrau #F4F6F9, Grau #EDEDED. Bewusst ohne Framework (kleine Datei). */
:root {
  --navy: #183E74; --navy-dark: #10294d; --yellow: #FFEA00; --amber: #FABB0C;
  --lightblue: #B9C4D4; --rowgray: #F4F6F9; --gray: #EDEDED; --text: #1d2430; --muted: #66707f;
  --ok: #1d7a3a; --err: #b42318; --warn: #a15c00; --radius: 4px;
  /* Ergänzt mit Namen und Werten aus den Tokens von docs/ui/stammbaum-ui.css (Designsystem v0.1, noch nicht
     eingebunden): Flächen der Bedeutungsfarben, Navy-Abstufungen, Linien, Vorschlagswerte. Modul-CSS nutzt nur diese. */
  --navy-050: #e8eef7; --navy-100: #d3deee; --amber-050: #fff4d6;
  --bg: #fff; --surface: #fff; --line: #d5dbe5; --placeholder: #7d8899;
  --ok-bg: #e6f2e9; --warn-bg: #fff4d6; --err-bg: #fdecea; --info: #183E74; --info-bg: #e8eef7;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: var(--text); background: #fff; }
a { color: var(--navy); }
h1 { font-size: 22px; color: var(--navy); margin: 0 0 12px; }
h2 { font-size: 17px; color: var(--navy); margin: 18px 0 8px; }
h3 { font-size: 15px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Kopfzeile */
.topbar { display: flex; align-items: center; gap: 16px; background: var(--navy); color: #fff; padding: 0 16px; min-height: 46px; flex-wrap: wrap; }
.topbar .brand { color: #fff; font-weight: bold; text-decoration: none; font-size: 17px; letter-spacing: .5px; }
.topbar .brand span { color: var(--yellow); }
.topbar .menu { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar .menu a { color: #fff; text-decoration: none; padding: 14px 10px; border-bottom: 3px solid transparent; }
.topbar .menu a:hover { background: var(--navy-dark); }
.topbar .menu a.active { border-bottom-color: var(--yellow); }
.topbar .userbox { display: flex; gap: 12px; font-size: 12px; }
.topbar .userbox a { color: var(--lightblue); }
.topbar .userbox a.mail-anmeldung { color: var(--warn); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }  /* UI-K09 */
.topbar .userbox a.mail-anmeldung:hover { text-decoration: underline; }
.topbar .userbox form.abmelden { display: inline; margin: 0; }
.topbar .userbox form.abmelden button { background: none; border: 0; padding: 0; font: inherit; color: var(--lightblue); cursor: pointer; }
.topbar .userbox form.abmelden button:hover { text-decoration: underline; }
.content { padding: 16px; max-width: 1500px; margin: 0 auto; }

/* Tabellen */
table.list { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
table.list th { background: var(--navy); color: #fff; text-align: left; padding: 6px 8px; font-weight: normal; white-space: nowrap; }
table.list td { padding: 5px 8px; border-bottom: 1px solid var(--gray); vertical-align: top; }
table.list tr:nth-child(even) td { background: var(--rowgray); }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #e6ebf3; }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }
table.list tfoot td { font-weight: bold; border-top: 2px solid var(--navy); background: #fff; }
.table-wrap { overflow-x: auto; }

/* Formulare */
form.grid, .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field > span { font-size: 12px; color: var(--muted); }
.field.wide { grid-column: span 2; }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row; align-items: center; gap: 6px; padding-top: 18px; }
.field small { color: var(--muted); font-size: 11px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--lightblue); border-radius: var(--radius); background: #fff; width: 100%; }
.field.check input { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); border-color: var(--amber); }
.field.num input, input.num { text-align: right; }
input[readonly] { background: var(--rowgray); }

/* Schaltflächen */
.btn { display: inline-block; font: inherit; padding: 7px 14px; border: 1px solid var(--navy); border-radius: var(--radius); background: #fff; color: var(--navy); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--rowgray); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.btn.accent { background: var(--yellow); border-color: var(--amber); color: var(--text); }
.btn.danger { border-color: var(--err); color: var(--err); }
/* Gesperrte Schaltfläche sichtbar von aktiver unterscheiden (Grund steht im title) */
.btn:disabled, .btn:disabled:hover { opacity: .45; cursor: not-allowed; }
.btn.primary:disabled:hover { background: var(--navy); }
.btn:not(.primary):not(.accent):disabled:hover { background: var(--surface); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.big { padding: 12px 20px; font-size: 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0 12px; }
.toolbar .spacer { flex: 1; }
.toolbar form { display: flex; gap: 8px; align-items: center; }
.toolbar input, .toolbar select { width: auto; }

/* Karten, Meldungen, Plaketten */
.card { border: 1px solid var(--gray); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; background: #fff; }
.card h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.kpi { font-size: 24px; color: var(--navy); font-weight: bold; }
.flash { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; border-left: 4px solid var(--ok); background: #eef7f0; }
.flash.error { border-color: var(--err); background: #fdf0ef; }
.flash.warn { border-color: var(--amber); background: #fff8e5; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--gray); }
.badge-draft { background: #fff8c4; }
.badge-final { background: #dbe8d8; }
.badge-cancelled { background: #f6d6d3; text-decoration: line-through; }
.badge-offen { background: var(--navy-050); }
.badge-teil { background: var(--warn-bg); }
.badge-voll { background: var(--ok-bg); }
.badge-erledigt { background: var(--gray); color: var(--muted); }
.badge-gebucht { background: var(--navy-100); }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--navy); margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; text-decoration: none; background: var(--gray); border-radius: var(--radius) var(--radius) 0 0; }
.tabs a.active { background: var(--navy); color: #fff; }
.pager { display: flex; gap: 12px; align-items: center; margin: 8px 0; }

/* Dialog (HTMX lädt Inhalte nach #modal) */
.modal-bg { position: fixed; inset: 0; background: rgba(16, 41, 77, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--radius); padding: 18px; width: min(900px, 100%); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.modal h2 { margin-top: 0; }

/* Anmeldung */
.login-box { max-width: 420px; margin: 60px auto; border: 1px solid var(--gray); padding: 24px; border-radius: var(--radius); }
.login-box details { margin-top: 18px; }
.login-box summary { cursor: pointer; color: var(--navy); }

/* HTMX */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

@media (max-width: 700px) {
  .content { padding: 10px 16px; }
  .field.wide { grid-column: auto; }
  .topbar .menu a { padding: 10px 6px; }
}

/* Formatierter Text (Editor und Anzeige) */
.rt { white-space: pre-wrap; line-height: 1.35; }
.rt p { margin: 0; }
.rt img { max-width: 100%; height: auto; vertical-align: middle; }
.rt table { margin: 0; max-width: 100%; }
.rt table td { box-sizing: border-box; padding: 1px 4px; overflow-wrap: break-word; white-space: normal; }
.rt table td p { white-space: pre-wrap; }
.rte { border: 1px solid var(--lightblue); border-radius: var(--radius); background: #fff; }
.rte:focus-within { outline: 2px solid var(--amber); border-color: var(--amber); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-bottom: 1px solid var(--gray); background: var(--rowgray); }
.rte-bar button { font: inherit; font-size: 12px; min-width: 26px; height: 24px; border: 1px solid transparent; background: transparent; border-radius: 3px; cursor: pointer; color: var(--text); }
.rte-bar button:hover { border-color: var(--lightblue); background: #fff; }
.rte-bar .rte-text { padding: 0 8px; color: var(--navy); }
.rte-sep { width: 1px; background: var(--lightblue); margin: 2px 4px; }
.rte-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.rte-area { padding: 6px 8px; outline: none; }
.rte-area img { cursor: pointer; }
.rte-area img.rte-img-aktiv { outline: 2px solid var(--amber); outline-offset: 1px; }
.rte-bild { display: contents; }
.rte-bild[hidden] { display: none; }
.rte-bild-label { align-self: center; padding: 0 2px 0 4px; font-size: 12px; color: var(--muted); }
.rte-view { padding: 6px 8px; border: 1px solid var(--gray); border-radius: var(--radius); background: var(--rowgray); min-height: 2em; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.picker-list li { border-bottom: 1px solid var(--gray); padding: 6px 4px; cursor: pointer; }
.picker-list li:hover { background: #e6ebf3; }
.picker-list .preview { color: var(--muted); font-size: 12px; max-height: 3.2em; overflow: hidden; }
/* Verwaltung: Rollen und Rechte */
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.check-inline { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.check-inline input { width: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 4px; }
.inline-form select, .inline-form input { width: auto; }
.rollen-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 16px; margin: 0 0 10px; }
.rollen-info dt { font-weight: bold; color: var(--navy); }
.rollen-info dd { margin: 0; font-size: 12px; }
table.list tr.ohne-rolle td { background: var(--warn-bg); }
table.list td.center, table.list th.center { text-align: center; }
.gesperrt-hinweis { font-size: 12px; color: var(--warn); }
fieldset.fs-contents { display: contents; }
/* Verwaltung → Benutzer: Eingabefelder schmal, damit die Zeile samt „Speichern“ auf 1366 px passt */
.benutzer-tabelle input[name="name"] { width: 11em; }
.benutzer-tabelle input[name="email"] { width: 16em; }
.benutzer-tabelle input[name="short"] { width: 4em; }
.benutzer-tabelle input[name="password"] { width: 9em; }

/* Testbetrieb (TESTBETRIEB=1, E67): Hinweis, dass die Daten nachts aus LIGNA neu aufgebaut werden */
.testbetrieb-banner { background: var(--warn-bg); border-bottom: 2px solid var(--amber); color: var(--warn); padding: 6px 16px;
  font-size: 13px; text-align: center; }

/* Bestandsarten (§ 11a.6): Ampel, kompakte Zahlen „physisch · verfügbar · zusagbar“, Kennzeichen im Verlauf */
.ampel { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; margin-right: 4px;
  border: 1px solid var(--placeholder); }
.ampel-gruen { background: var(--ok); }
.ampel-gelb { background: var(--amber); }
.ampel-rot { background: var(--err); }
.verf-info { font-size: 13px; line-height: 1.5; }
.verf-info .warnung { color: var(--err); }
.verf-kompakt { white-space: nowrap; }
.verf-kompakt .sep { color: var(--lightblue); margin: 0 3px; }
.kennz { display: inline-block; padding: 0 6px; border-radius: 10px; font-size: 11px; background: var(--gray); margin: 0 3px 2px 0; }
.kennz-rot { background: var(--err-bg); color: var(--err); }
.kennz-gelb { background: var(--warn-bg); }
.kennz-ok { background: var(--ok-bg); }
table.list tr.nicht-gezaehlt td { color: var(--muted); }
/* Überschrift in einer aufklappbaren Karte (<details><summary><h2 class="summary-titel">) – steht neben dem Pfeil */
.summary-titel { display: inline; }
