/* =====================================================================================================
   Autopilot Staging · Helveticor
   Designsystem: CI-Farben (Dunkelblau #0F3C5A, Hellblau #4197CB, Grau #A7A8A9, Weiss), Arial.
   Signalfarben Gruen/Gelb/Rot nur fuer Zustaende, immer mit Symbol (nie Farbe allein).
   Schriftgroessen 12/13/14/16/20/24/32 px, Abstaende im 4-px-Raster, zwei Radien (6 und 10 px).
   Kontraste nach WCAG 2.2 AA in beiden Darstellungen gerechnet (Text >= 4.5:1, Bedienelemente >= 3:1).
   ===================================================================================================== */

:root {
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 24px; --fs-3xl: 32px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --r-sm: 6px; --r: 10px;
  --blue: #0F3C5A; --accent: #4197CB; --grey: #A7A8A9;
  --primary: #2A6A94; --primary-h: #23597C;           /* abgedunkeltes CI-Hellblau: weisse Schrift 5.9:1 */
  --font: Arial, "Liberation Sans", Helvetica, sans-serif;
  --mono: Consolas, "Liberation Mono", Menlo, monospace;

  /* Dunkel (Standard) */
  --bg: #07131D; --bg-2: #0A1A27; --side: #0B1D2B; --top: #0C2232; --surface: #0E2131; --surface-2: #12293C; --hover: #16314A;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14); --field: #5A7083;
  --text: #E8EEF3; --text-2: #B7C3CD; --muted: #8FA1B0; --strong: #FFFFFF; --ph: #8296A6;
  --link: #6CB4E0; --focus: #7CC4EE;
  --ok: #5CC398; --warn: #E3B25A; --err: #F08A86; --info: #6CB4E0;
  --ok-bg: rgba(92,195,152,.12); --warn-bg: rgba(227,178,90,.12); --err-bg: rgba(240,138,134,.12); --info-bg: rgba(108,180,224,.12); --muted-bg: rgba(255,255,255,.06);
  --chip-bg: rgba(65,151,203,.14); --chip-line: rgba(65,151,203,.35); --chip-t: #8CC6EA;
  --track: #3B5266; --bar: rgba(255,255,255,.10); --on-err: #2A0B0A;
  --shadow: 0 18px 48px rgba(0,0,0,.5);
  --auth-bg: #07131D;
  color-scheme: dark;
}
html[data-theme=light] {
  --bg: #F3F5F7; --bg-2: #F7F9FA; --side: #FFFFFF; --top: #FFFFFF; --surface: #FFFFFF; --surface-2: #EDF3F8; --hover: #E6EEF5;
  --line: #E1E7ED; --line-2: #CFD8E0; --field: #7A8794;
  --text: #0F3C5A; --text-2: #3D5C73; --muted: #5F6B76; --strong: #0F3C5A; --ph: #6D6E70;
  --link: #1F6A9A; --focus: #2A6A94;
  --ok: #1E7A55; --warn: #8A5A0C; --err: #B23530; --info: #1F6A9A;
  --ok-bg: #E5F4ED; --warn-bg: #FBF1DE; --err-bg: #FBE8E7; --info-bg: #E6F0F7; --muted-bg: #EEEEEF;
  --chip-bg: #E6F0F7; --chip-line: #BBD6EA; --chip-t: #1F6A9A;
  --track: #8A97A3; --bar: #E3EAF0; --on-err: #FFFFFF;
  --shadow: 0 18px 48px rgba(15,60,90,.16);
  --auth-bg: #F3F5F7;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  html[data-theme=system] {
    --bg: #F3F5F7; --bg-2: #F7F9FA; --side: #FFFFFF; --top: #FFFFFF; --surface: #FFFFFF; --surface-2: #EDF3F8; --hover: #E6EEF5;
    --line: #E1E7ED; --line-2: #CFD8E0; --field: #7A8794;
    --text: #0F3C5A; --text-2: #3D5C73; --muted: #5F6B76; --strong: #0F3C5A; --ph: #6D6E70;
    --link: #1F6A9A; --focus: #2A6A94;
    --ok: #1E7A55; --warn: #8A5A0C; --err: #B23530; --info: #1F6A9A;
    --ok-bg: #E5F4ED; --warn-bg: #FBF1DE; --err-bg: #FBE8E7; --info-bg: #E6F0F7; --muted-bg: #EEEEEF;
    --chip-bg: #E6F0F7; --chip-line: #BBD6EA; --chip-t: #1F6A9A;
    --track: #8A97A3; --bar: #E3EAF0; --on-err: #FFFFFF;
    --shadow: 0 18px 48px rgba(15,60,90,.16);
    --auth-bg: #F3F5F7;
    color-scheme: light;
  }
}
.on-light { display: none !important; }
html[data-theme=light] .on-light { display: block !important; } html[data-theme=light] .on-dark { display: none !important; }
@media (prefers-color-scheme: light) { html[data-theme=system] .on-light { display: block !important; } html[data-theme=system] .on-dark { display: none !important; } }

/* ---------- Grundlagen */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 88px; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs-md)/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: bold; color: var(--strong); }
h1 { font-size: var(--fs-3xl); line-height: 1.15; letter-spacing: -.015em; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
h2 { font-size: var(--fs-xl); line-height: 1.3; }
h3, .h3 { font-size: var(--fs-lg); line-height: 1.35; }
p { margin: 0; }
ul, ol { margin: 0; }
.muted { color: var(--muted); } .small { font-size: var(--fs-xs); } .strong { font-weight: bold; color: var(--text); } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: var(--fs-sm); letter-spacing: .01em; }
.err-text { color: var(--err); display: block; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only, .visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.top-gap { margin-top: var(--s4); }

/* Fokus: immer sichtbar, 2 px, Abstand zum Element */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
.skip { position: absolute; left: var(--s4); top: -60px; z-index: 100; background: var(--primary); color: #fff; padding: var(--s2) var(--s4); border-radius: var(--r-sm); font-weight: bold; }
.skip:focus { top: var(--s3); }
main:focus { outline: none; }

/* ---------- Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 40; height: 64px; display: flex; align-items: center; justify-content: space-between; background: var(--top); border-bottom: 1px solid var(--line-2); }
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s6); color: var(--text); height: 100%; text-decoration: none !important; }
.brand .app { font-size: var(--fs-lg); font-weight: bold; }
.crest { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; }
.crest img { display: block; width: 100%; height: 100%; object-fit: contain; }
.top-right { display: flex; align-items: center; height: 100%; }
.wordmark-box { height: 100%; display: flex; align-items: center; padding: 0 var(--s8); border-left: 1px solid var(--line-2); }
.wordmark { height: 19px; width: auto; display: block; }
.usermenu { position: relative; margin-right: var(--s5); }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: var(--s3); cursor: pointer; padding: 6px var(--s2); border-radius: var(--r-sm); }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--hover); }
.usermenu .uname { font-weight: bold; }
.usermenu .role { font-size: 11px; font-weight: bold; letter-spacing: .06em; border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 6px; color: var(--text-2); }
.usermenu summary > .i { width: 16px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); border: 1px solid rgba(65,151,203,.5); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: bold; color: #fff; flex: none; }
.avatar.sm { width: 32px; height: 32px; }

/* ---------- Rahmen: Seitenleiste ueber die ganze Hoehe, Inhalt rechts */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { background: var(--side); border-right: 1px solid var(--line-2); padding: var(--s6) var(--s3); display: flex; flex-direction: column; position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; }
.nav-label { padding: 0 var(--s3); margin: 0 0 var(--s2); font-size: var(--fs-xs); font-weight: bold; color: var(--muted); }
.nav-label:not(:first-child) { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--line); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); border-radius: var(--r-sm); color: var(--text-2); font-weight: bold; position: relative; text-decoration: none; }
.sidebar nav a:hover { background: var(--hover); color: var(--text); }
.sidebar nav a.on { background: var(--surface-2); color: var(--strong); }
.sidebar nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar nav a .i { color: var(--muted); } .sidebar nav a.on .i { color: var(--link); }
.sidebar nav em { margin-left: auto; font-style: normal; font-size: var(--fs-xs); background: var(--primary); color: #fff; border-radius: 10px; padding: 0 8px; line-height: 20px; }
.side-foot { margin-top: auto; padding: 0 var(--s3); font-size: var(--fs-xs); color: var(--muted); }
.main { padding: var(--s10) var(--s12) var(--s12); max-width: 1320px; width: 100%; min-width: 0; }

/* ---------- Seitenkopf und Bloecke */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s6); margin-bottom: var(--s8); flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head .sub { color: var(--text-2); margin-top: var(--s2); max-width: 70ch; }
.meta { display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap; margin-top: var(--s3); color: var(--text-2); }
.meta > span:not(.chip):not(.badge) + span:not(.chip):not(.badge)::before { content: "·"; margin-right: var(--s3); color: var(--muted); }
.head-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: bold; font-size: var(--fs-sm); margin-bottom: var(--s3); }
.back:hover { color: var(--text); } .back .i { width: 16px; }
.section { margin-top: var(--s10); }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); margin-bottom: var(--s3); flex-wrap: wrap; }
.block-head h2 { font-size: var(--fs-lg); }
.eyebrow { font-size: var(--fs-xs); font-weight: bold; color: var(--link); letter-spacing: .02em; }
.section-label { font-size: var(--fs-sm); font-weight: bold; color: var(--text-2); margin: var(--s8) 0 var(--s3); }
.section-label.nomargin { margin: 0; }
.label { font-size: var(--fs-sm); font-weight: bold; color: var(--text-2); margin-bottom: var(--s2); }

/* ---------- Flaechen */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s6) var(--s8); }
.panel.flush { padding: 0; }
.panel.narrow { max-width: 720px; }
.panel.narrow + .panel.narrow { margin-top: var(--s6); }
.panel h2 + .muted { margin: 6px 0 var(--s6); }
.divider { height: 1px; background: var(--line); margin: var(--s6) 0; } .divider.tight { margin: var(--s1) 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5) var(--s6); }
.kpi-l { font-size: var(--fs-sm); font-weight: bold; color: var(--text-2); }
.kpi-v { font-size: var(--fs-3xl); font-weight: bold; margin-top: var(--s2); line-height: 1; color: var(--strong); }
.kpi.attention { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.empty { padding: var(--s12) var(--s6); text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: var(--s4); }
.empty .i { width: 28px; height: 28px; }
.empty-filter { padding: var(--s6); text-align: center; }

/* ---------- Tabellen */
.table-wrap { overflow-x: auto; position: relative; }
.table-wrap.panel { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line-2); background: var(--bg-2); font-size: var(--fs-sm); font-weight: bold; color: var(--text-2); white-space: nowrap; }
.table td { padding: 14px var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.link { cursor: pointer; }
.table tr.link:hover td { background: var(--surface-2); }
.table tr.idle td { color: var(--muted); }
.table .num { width: 56px; }
.table .sel { width: 44px; padding-right: 0; }
.table .sel input { width: 18px; height: 18px; accent-color: var(--primary); }
.rowlink { font: inherit; font-weight: bold; color: var(--strong); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.rowlink.mono { font-family: var(--mono); font-size: var(--fs-sm); }
.rowlink:hover { color: var(--link); text-decoration: underline; }
.progress-cell { width: 220px; }
.bar { height: 6px; background: var(--bar); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.person { display: flex; align-items: center; gap: var(--s3); }
.ptxt { font-size: var(--fs-sm); color: var(--text-2); }
.ptxt.err { color: var(--err); font-weight: bold; } .ptxt.ok { color: var(--ok); font-weight: bold; }
.table.log .dayrow th { background: var(--surface); color: var(--strong); font-size: var(--fs-sm); padding-top: var(--s5); border-bottom-color: var(--line); }
.details .kvp { display: inline-block; margin: 0 var(--s4) 2px 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s4); margin-top: var(--s5); }

/* ---------- Zustaende: Chip mit Symbol und Farbe */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: bold; padding: 3px 10px 3px 7px; border-radius: 999px; white-space: nowrap; line-height: 1.4; background: var(--muted-bg); color: var(--text-2); vertical-align: middle; }
.badge .i { width: 14px; height: 14px; stroke-width: 2.2; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); } .badge.info { background: var(--info-bg); color: var(--info); }
.badge.pulse .i { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
h1 .badge { font-size: var(--fs-sm); }
/* aeltere Schreibweise (Systempruefung, Ladesatz-Versionen) */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: bold; color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--muted); }
.status.ok { color: var(--ok); } .status.ok::before { background: var(--ok); border-radius: 50%; }
.status.warn { color: var(--warn); } .status.warn::before { background: var(--warn); transform: rotate(45deg); }
.status.err { color: var(--err); } .status.err::before { background: var(--err); border-radius: 0; }
.status.info { color: var(--info); } .status.info::before { background: var(--info); border-radius: 50%; }
.chip { display: inline-block; font-size: var(--fs-xs); font-weight: bold; padding: 2px 10px; border-radius: 999px; background: var(--chip-bg); color: var(--chip-t); border: 1px solid var(--chip-line); line-height: 1.5; }
.chip.solid { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Formulare */
.stack { display: flex; flex-direction: column; gap: var(--s5); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); } .grid3 .span2 { grid-column: span 2; }
.field { min-width: 0; }
fieldset.field { border: 0; padding: 0; margin: 0; }
.field > label:not(.switch):not(.check), legend { display: block; font-size: var(--fs-sm); font-weight: bold; color: var(--text-2); margin-bottom: 6px; padding: 0; }
.hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 6px; }
.hint.strong { color: var(--text-2); font-size: var(--fs-sm); }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--field); border-radius: var(--r-sm); padding: 10px 12px; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--ph); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(108,180,224,.25); }
input[readonly] { background: var(--surface-2); }
input.short { max-width: 160px; }
input.code { font-size: 22px; letter-spacing: .3em; text-align: center; font-family: var(--mono); }
input[type=checkbox], input[type=radio] { width: auto; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { resize: vertical; }
.static { padding: 10px 0; color: var(--text); }
.pw { position: relative; } .pw input { padding-right: 44px; } .pw .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.switch { display: flex; align-items: center; gap: var(--s3); cursor: pointer; font-weight: bold; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: var(--track); position: relative; transition: background .15s; flex: none; border: 1px solid var(--field); }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: var(--s2); margin-top: var(--s2); color: var(--text-2); }
.checkgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px var(--s5); padding: var(--s2) 0; }
.checkgrid .check { margin: 0; padding: 6px 0; color: var(--text); } .checkgrid .check .mono { margin-left: auto; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s1); flex-wrap: wrap; } .form-actions.left { justify-content: flex-start; }

/* ---------- Schaltflaechen: genau ein Hauptknopf pro Bereich */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); font: inherit; font-weight: bold; font-size: var(--fs-md); min-height: 40px; padding: 8px 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--hover); border-color: var(--muted); }
.btn .i { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn.lg { min-height: 48px; padding: 10px 22px; font-size: var(--fs-lg); }
.btn.sm { min-height: 32px; padding: 5px 12px; font-size: var(--fs-sm); }
.btn.block { width: 100%; min-height: 48px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { background: var(--err); border-color: var(--err); color: var(--on-err); }
.btn.danger-outline { background: transparent; border-color: var(--err); color: var(--err); }
.btn.danger-outline:hover { background: var(--err-bg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer; list-style: none; text-decoration: none !important; }
.icon-btn:hover { background: var(--hover); color: var(--text); } .icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger:hover { color: var(--err); }
summary.icon-btn::-webkit-details-marker, .menu summary::-webkit-details-marker, .addbox summary::-webkit-details-marker { display: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; font-weight: bold; cursor: pointer; }
.danger-text { color: var(--err) !important; }

/* Menues */
.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px; z-index: 50; box-shadow: var(--shadow); text-align: left; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 10px var(--s3); border: 0; background: transparent; color: var(--text); font: inherit; font-weight: bold; font-size: var(--fs-md); border-radius: var(--r-sm); cursor: pointer; text-align: left; text-decoration: none !important; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); }
.menu-pop button.danger { color: var(--err); }
.menu-pop .i { width: 16px; color: var(--muted); }
.menu-head { padding: 10px var(--s3) var(--s3); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-pop form { margin: 0; }
.inline-form { margin: 0; display: inline; }
.theme-pick { padding: var(--s2) var(--s3) var(--s3); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: var(--s2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.menu-pop .seg button { flex-direction: column; gap: 3px; padding: 7px 4px; font-size: var(--fs-xs); justify-content: center; align-items: center; color: var(--text-2); text-align: center; }
.menu-pop .seg button.on { background: var(--surface); color: var(--strong); box-shadow: 0 0 0 1px var(--line-2); }
.menu-pop .seg .i { width: 16px; color: inherit; }

/* ---------- Meldungen */
.toast { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--ok-bg); border: 1px solid var(--ok); color: var(--ok); font-weight: bold; transition: opacity .4s; }
.toast.err { background: var(--err-bg); border-color: var(--err); color: var(--err); }
.toast.info { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.toast .icon-btn { margin-left: auto; color: inherit; }
.toast.gone { opacity: 0; }
.toast.floating { position: fixed; right: var(--s6); bottom: var(--s6); z-index: 90; margin: 0; max-width: min(460px, calc(100vw - 32px)); background: var(--surface-2); box-shadow: var(--shadow); }
.alert { padding: var(--s3) 14px; border-radius: var(--r-sm); font-weight: bold; font-size: var(--fs-md); margin-bottom: var(--s5); background: var(--info-bg); color: var(--info); border: 1px solid var(--info); }
.alert.err { background: var(--err-bg); color: var(--err); border-color: var(--err); } .alert.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.freshbar { position: fixed; left: 50%; bottom: var(--s6); transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: var(--s4); padding: var(--s2) var(--s2) var(--s2) var(--s5); border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: bold; }

/* ---------- Lieferung: Ablauf */
.flow { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stages { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.stage { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s5) var(--s6); position: relative; min-width: 0; }
.stage:not(:last-child)::after { content: ""; position: absolute; right: 0; top: 22%; bottom: 22%; width: 1px; background: var(--line); }
.stage-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: bold; font-size: var(--fs-sm); border: 2px solid var(--field); color: var(--muted); }
.stage-n .i { width: 15px; height: 15px; stroke-width: 2.6; }
.stage-t { display: flex; flex-direction: column; min-width: 0; }
.stage-l { font-weight: bold; color: var(--text-2); }
.stage-s { font-size: var(--fs-sm); color: var(--muted); }
.stage.done .stage-n { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.stage.part .stage-n { border-color: var(--accent); color: var(--link); }
.stage.now { background: var(--info-bg); box-shadow: inset 0 -3px 0 var(--accent); }
.stage.now .stage-n { border-color: var(--accent); background: var(--primary); color: #fff; }
.stage.now .stage-l { color: var(--strong); }
.next { display: flex; align-items: center; gap: var(--s5); padding: var(--s6) var(--s8); }
.next-i { flex: none; width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--info-bg); color: var(--info); }
.next-i .i { width: 24px; height: 24px; }
.next.review .next-i { background: var(--warn-bg); color: var(--warn); }
.next.close .next-i, .next.done .next-i { background: var(--ok-bg); color: var(--ok); }
.next.wait .next-i { background: var(--muted-bg); color: var(--muted); }
.next-t { flex: 1; min-width: 0; }
.next-k { font-size: var(--fs-sm); font-weight: bold; color: var(--muted); }
.next-t h2 { font-size: var(--fs-xl); margin: 2px 0 4px; }
.next-t p { color: var(--text-2); max-width: 72ch; }
.next-a { flex: none; }
.connbar { display: flex; align-items: center; gap: var(--s3); margin: 0; padding: var(--s3) var(--s8); border-top: 1px solid var(--line); background: var(--info-bg); color: var(--info); }
.connbar form { margin-left: auto; }

/* Filter, Suche, Sammelfreigabe */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: var(--s3); }
.tab { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: bold; font-size: var(--fs-sm); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2); cursor: pointer; text-decoration: none !important; min-height: 32px; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab[aria-pressed=true], .tab[aria-current=page] { background: var(--strong); border-color: var(--strong); color: var(--bg); }
.tab .count { font-weight: normal; opacity: .8; }
.search-field { display: flex; align-items: center; gap: var(--s2); border: 1px solid var(--field); border-radius: var(--r-sm); background: var(--bg-2); padding: 0 var(--s3); width: 300px; max-width: 100%; }
.search-field .i { width: 16px; color: var(--muted); }
.search-field input { border: 0; background: transparent; padding: 9px 0; box-shadow: none !important; }
.search-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(108,180,224,.25); }
.search-field input:focus-visible { outline: none; }
.bulkbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s2) var(--s2) var(--s2) var(--s4); margin-bottom: var(--s3); border: 1px dashed var(--line-2); border-radius: var(--r); flex-wrap: wrap; }
.search { width: 260px; }

/* Seitenpanel (Drawer) und Dialoge */
.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100vh; max-height: 100vh; width: min(620px, 100vw); border: 0; border-left: 1px solid var(--line-2); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.drawer::backdrop, .dialog::backdrop { background: rgba(3,10,16,.6); }
.drawer[open] { display: flex; flex-direction: column; animation: slidein .2s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); padding: var(--s6) var(--s8) var(--s5); border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: var(--fs-2xl); margin: 2px 0 var(--s2); font-family: var(--mono); }
.drawer-body { overflow-y: auto; padding: var(--s2) var(--s8) var(--s10); }
.drawer-body > section { padding: var(--s5) 0; border-bottom: 1px solid var(--line); }
.drawer-body > section:last-child { border-bottom: 0; }
.drawer-body h3 { margin-bottom: var(--s3); }
.dialog { border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); color: var(--text); padding: var(--s8); width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dialog h2 { margin-bottom: var(--s2); }
.dialog p { color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s6); flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--s2) var(--s4); margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.flags { margin: 0 0 var(--s3); padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.flags li { display: flex; gap: var(--s2); align-items: flex-start; padding: 10px 14px; border-radius: var(--r-sm); background: var(--warn-bg); border-left: 3px solid var(--warn); color: var(--warn); font-weight: bold; }
.okline { display: flex; align-items: center; gap: var(--s2); color: var(--ok); font-weight: bold; margin-bottom: var(--s3); }
.checklist { list-style: none; padding: 0; margin: 0 0 var(--s3); display: flex; flex-wrap: wrap; gap: 6px; }
.decide { margin-top: var(--s4); gap: var(--s3); padding: var(--s4); border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg-2); }
.intune { margin: var(--s3) 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 var(--s4) var(--s8); display: flex; flex-direction: column; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--field); background: var(--surface); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 11px; top: 20px; bottom: 2px; width: 2px; background: var(--line-2); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.fail::before { background: var(--err); border-color: var(--err); border-radius: 2px; }
.timeline .tl-t { font-weight: bold; }
.timeline li.todo .tl-t { color: var(--muted); }
.csv-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s3); flex-wrap: wrap; }
.csv-head h3 { margin-bottom: 2px; }
.csv-table { border: 1px solid var(--line); border-radius: var(--r-sm); overflow-x: auto; }
.csv-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.csv-table th { background: var(--surface-2); text-align: left; padding: var(--s2) var(--s3); font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-2); font-weight: bold; border-bottom: 1px solid var(--line); white-space: nowrap; }
.csv-table td { padding: 10px var(--s3); }
.hashcell { max-width: 240px; } .hashcell .h { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Aufklappbare Bloecke */
.collapsible { padding: 0; }
.collapsible summary { list-style: none; display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s6); cursor: pointer; flex-wrap: wrap; }
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary > .i { margin-left: auto; width: 16px; color: var(--muted); transition: transform .15s; }
.collapsible[open] summary > .i { transform: rotate(180deg); }
.collapsible form { padding: 0 var(--s6) var(--s5); }
.addbox { margin-top: var(--s4); } .addbox summary { list-style: none; }
.addbox[open] summary { margin-bottom: var(--s4); }

/* ---------- Einstellungen */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s8); align-items: start; }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 96px; }
.subnav a { padding: 9px 14px; border-radius: var(--r-sm); color: var(--text-2); font-weight: bold; text-decoration: none; }
.subnav a:hover { background: var(--hover); color: var(--text); }
.subnav a.on { background: var(--surface-2); color: var(--strong); box-shadow: inset 3px 0 0 var(--accent); }
.settings .panel { max-width: 860px; min-width: 0; }
.profile { border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4) var(--s5); background: var(--bg-2); }
.profile-head { display: flex; gap: var(--s3); } .profile-head > .i { color: var(--ok); margin-top: 2px; }
.profile-custom { margin-top: var(--s3); } .profile-custom summary { cursor: pointer; color: var(--link); font-weight: bold; font-size: var(--fs-sm); }
.table.inset { border: 1px solid var(--line); border-radius: var(--r); border-collapse: separate; border-spacing: 0; margin-bottom: var(--s2); }
.table.inset td, .table.inset th { padding: var(--s3) 14px; }
.table.inset th:first-child { border-top-left-radius: var(--r); } .table.inset th:last-child { border-top-right-radius: var(--r); }
.branch-form { padding: var(--s5); border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg-2); }
.taglist { list-style: none; margin: 0 0 var(--s4); padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.taglist li { display: flex; align-items: center; gap: 14px; padding: var(--s2) var(--s2) var(--s2) var(--s4); border-bottom: 1px solid var(--line); }
.taglist li:last-child { border-bottom: 0; }
.taglist form { margin-left: auto; }
.addrow { display: flex; gap: var(--s2); } .addrow input { flex: 1; }
.checks { list-style: none; padding: 0; margin: var(--s5) 0 0; border-top: 1px solid var(--line); }
.checks li { display: grid; grid-template-columns: 96px 210px minmax(0, 1fr); gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.vergrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: var(--s6); }
.vergrid > div { border: 1px solid var(--line); border-radius: var(--r); padding: 14px var(--s4); }
.verv { font-size: var(--fs-2xl); font-weight: bold; margin-top: 6px; color: var(--strong); }
.methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.method { border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4) var(--s5); }
.method.on { border-color: var(--accent); background: var(--info-bg); }
.method p { margin-top: var(--s2); }

/* ---------- Benutzer */
.invite { margin-bottom: var(--s5); border-color: var(--accent); background: var(--info-bg); }
.invite-head { display: flex; gap: var(--s4); margin-bottom: var(--s4); } .invite-head .i { width: 22px; height: 22px; color: var(--link); margin-top: 2px; }
.invite-head .muted { margin-top: 6px; }
.copyline { display: flex; gap: var(--s2); align-items: flex-start; } .copyline input, .copyline textarea { flex: 1; font-size: var(--fs-xs); min-width: 0; }

/* ---------- Anmeldung */
body.auth { min-height: 100vh; background: var(--auth-bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--s10) var(--s4); }
.auth-brand { display: flex; align-items: center; justify-content: space-between; gap: var(--s5); width: min(440px, 100%); margin-bottom: var(--s6); }
.auth-brand .crest { width: 50px; height: 50px; }
.auth-brand .wordmark { height: 22px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; padding: var(--s8) var(--s8) var(--s6); box-shadow: var(--shadow); }
.auth-card h1 { font-size: var(--fs-2xl); margin: 6px 0 var(--s2); }
.auth-card .lead { color: var(--text-2); margin-bottom: var(--s6); }
.auth-card form + form, .auth-card form + .btn { margin-top: var(--s2); }
.fineprint { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s5); line-height: 1.6; }
.auth-foot { margin-top: var(--s8); font-size: var(--fs-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.qr-row { display: flex; gap: var(--s5); align-items: center; }
.qr { flex: none; width: 148px; height: 148px; border-radius: var(--r); background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.qr img { width: 136px; height: 136px; image-rendering: pixelated; }
.step-title { font-weight: bold; margin-bottom: 6px; }
.secret { margin-top: 10px; padding: var(--s2) 10px; background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: var(--r-sm); font-size: var(--fs-xs); word-spacing: 4px; }
.codes { list-style: none; margin: var(--s1) 0 var(--s5); padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); counter-reset: c; }
.codes li { counter-increment: c; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 9px var(--s3); background: var(--surface-2); }
.codes li::before { content: counter(c, decimal-leading-zero); color: var(--muted); font-size: var(--fs-xs); font-weight: bold; }
.codes .mono { font-size: var(--fs-lg); font-weight: bold; letter-spacing: .06em; color: var(--strong); }

/* ---------- Geraetecode-Anmeldung */
.connect { max-width: 760px; }
.connect-steps { list-style: none; margin: 0 0 var(--s6); padding: 0; display: flex; flex-direction: column; gap: var(--s5); }
.connect-steps li { display: flex; gap: var(--s4); align-items: flex-start; }
.connect-steps .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: var(--fs-sm); color: var(--link); }
.connect-steps .strong { margin: 3px 0 10px; }
.usercode { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.usercode .mono { font-size: 30px; font-weight: bold; letter-spacing: .18em; padding: 10px 18px; border-radius: var(--r-sm); background: var(--bg-2); border: 1px dashed var(--line-2); color: var(--strong); }
.waiting { display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s4); border-radius: var(--r-sm); background: var(--bg-2); border: 1px solid var(--line); font-weight: bold; }
.waiting .small { margin-left: auto; font-weight: normal; }
.waiting.failed { color: var(--err); } .waiting.failed .spinner { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bewegung reduzieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Kleinere Bildschirme (Reflow bis 320 px) */
@media (max-width: 1180px) {
  .main { padding: var(--s8) var(--s6) var(--s10); }
  .shell { grid-template-columns: 210px minmax(0, 1fr); }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage:nth-child(2)::after { display: none; }
  .stage:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s1); padding: var(--s2) var(--s3); border-right: 0; border-bottom: 1px solid var(--line-2); overflow: visible; }
  .nav-label, .side-foot { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav a.on::before { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid3, .checkgrid, .methods, .vergrid, .settings { grid-template-columns: minmax(0, 1fr); } .grid3 .span2 { grid-column: auto; }
  .subnav { position: static; flex-direction: row; flex-wrap: wrap; }
  .next { flex-wrap: wrap; padding: var(--s5); }
  .next-a { width: 100%; } .next-a .btn { width: 100%; }
  .checks li { grid-template-columns: 90px minmax(0, 1fr); } .checks li > :last-child { grid-column: 1 / -1; }
  .usermenu .uname, .usermenu .role { display: none; }
  .wordmark-box { padding: 0 var(--s4); }
}
@media (max-width: 560px) {
  .main { padding: var(--s6) var(--s4) var(--s10); }
  h1 { font-size: var(--fs-2xl); }
  .brand { padding: 0 var(--s3); } .brand .app { display: none; }
  .wordmark-box { border-left: 0; } .wordmark { height: 15px; }
  .usermenu { margin-right: 0; }
  .stage { padding: var(--s3) var(--s4); }
  .stage-n { width: 24px; height: 24px; font-size: var(--fs-xs); }
  .next-i { display: none; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: var(--s5) var(--s4); }
  .search-field { width: 100%; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: var(--s2); }
  .drawer-head, .drawer-body { padding-left: var(--s4); padding-right: var(--s4); }
  .codes { grid-template-columns: minmax(0, 1fr); }
  .qr-row { flex-direction: column; align-items: flex-start; }
  .auth-card { padding: var(--s6) var(--s5); }
  .copyline { flex-direction: column; } .copyline .btn { width: 100%; }
}
.dialog h2.mono { font-family: var(--mono); font-size: var(--fs-2xl); letter-spacing: .04em; margin: 2px 0 var(--s3); }
