/* VR-Cockpit. Gestaltung: ruhiges Kontor, Zahlen im Vordergrund.
   Farben, Schrift und Abstände als Tokens; Ampel immer mit Form und Text, nie nur mit Farbe.
   Schrift: Schibsted Grotesk (SIL OFL 1.1, static/fonts/LICENSE-SchibstedGrotesk-OFL.txt), Teilmenge Latin;
   tnum wirkt nur auf Ziffern (Punkt, Komma, Doppelpunkt und % bleiben proportional). */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/SchibstedGrotesk-Variable.4e48b9caadb2.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Grundfarben */
  --paper: #edefea;          /* Seitengrund, kühles Stein-Grüngrau */
  --surface: #ffffff;        /* Flächen für Tabellen und Formulare */
  --surface-soft: #f6f7f4;   /* Tabellenkopf, ruhige Unterflächen */
  --ink: #15201c;            /* Text */
  --muted: #5e6b66;          /* gedämpfter Text, 4.8:1 auf Papier */
  --line: #d5dad3;           /* Haarlinien */
  --line-strong: #7d8983;    /* Eingabefelder, 3.6:1 */
  --bottle: #0f3b33;         /* Struktur: Leiste, Primärbuttons, aktive Zustände */
  --bottle-hover: #0a2c26;
  --bottle-soft: #e4ece8;
  --brass: #a8803a;          /* Akzent, sparsam: Fokus, eine Linie im Firmenkopf */
  --brass-light: #c9a45c;    /* Fokus auf Flaschengrün */
  --on-bottle: #ffffff;
  --on-bottle-muted: #b9cbc4;

  /* Ampel: Grundton für Form, Tönung für Fläche, Textton für Schrift */
  --green: #2f7d4f;  --green-tint: #e5f0e8;  --green-text: #1f5e3a;
  --amber: #b9820f;  --amber-tint: #f7edd6;  --amber-text: #7a5600;
  --red: #b3261e;    --red-tint: #f6e2e0;    --red-text: #8e1d17;
  --grey: #8a958f;

  /* Schrift */
  --font: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 13px;   /* Beschriftungen, Tabellenkopf */
  --fs-s: 15px;    /* Tabellen, Nebeninformation */
  --fs-m: 16px;    /* Fliesstext */
  --fs-l: 21px;    /* Abschnittstitel */
  --fs-xl: 28px;   /* Seitentitel */
  --fs-xxl: 40px;  /* Firmenname */

  /* Form */
  --r-control: 6px;
  --r-surface: 10px;
  --sidebar: 248px;
  --shadow-float: 0 8px 24px rgba(15, 59, 51, .12), 0 1px 3px rgba(15, 59, 51, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--paper);
  font-family: var(--font); font-size: var(--fs-m); line-height: 1.55; font-weight: 400;
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: var(--fs-xl); margin: 0 0 24px; letter-spacing: -.02em; }
h2 { font-size: var(--fs-l); margin: 40px 0 14px; }
h3 { font-size: 17px; margin: 28px 0 10px; }
h4 { font-size: var(--fs-m); margin: 16px 0 6px; }
p { margin: 0 0 12px; max-width: 75ch; }
a { color: var(--bottle); text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: rgba(15, 59, 51, .35); }
a:hover { text-decoration-color: currentColor; }
strong { font-weight: 600; }
ul { padding-left: 1.2em; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Fokus: Messing, überall sichtbar */
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; border-radius: var(--r-control); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 16px;
  background: var(--surface); color: var(--ink); border-radius: var(--r-control); box-shadow: var(--shadow-float);
}
.skip:focus { top: 12px; }

/* ---------- Rahmen: Leiste links, Inhalt rechts ---------- */
.shell {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--bottle) var(--sidebar), var(--paper) var(--sidebar));
}
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; z-index: 20;
  display: flex; flex-direction: column; background: var(--bottle); color: var(--on-bottle);
}
.sidebar a { color: var(--on-bottle); text-decoration: none; }
.sidebar :focus-visible { outline-color: var(--brass-light); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 26px 24px 30px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; font-size: 18px; letter-spacing: -.01em; }
.nav-toggle { display: none; }
.sidebar-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.mainnav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.mainnav a {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: var(--r-control); color: var(--on-bottle-muted); font-size: var(--fs-s); font-weight: 500;
}
.mainnav a:hover { color: var(--on-bottle); background: rgba(255, 255, 255, .06); }
.mainnav a.aktiv { color: var(--on-bottle); background: rgba(255, 255, 255, .1); }
.mainnav a.aktiv::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--brass-light);
}
.mainnav .badge { background: var(--brass-light); border-color: var(--brass-light); color: var(--bottle); font-weight: 600; }
.user {
  margin-top: auto; padding: 18px 24px 24px; border-top: 1px solid rgba(255, 255, 255, .12);
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: var(--fs-s);
}
.user form { margin: 0; }
.user a { color: var(--on-bottle); font-weight: 500; }
.user a:hover { text-decoration: underline; }
.user .btn-link { color: var(--on-bottle-muted); padding: 0; font-size: var(--fs-s); text-decoration: none; }
.user .btn-link:hover { color: var(--on-bottle); text-decoration: underline; }

.content { padding: 40px 40px 72px; max-width: 1400px; min-width: 0; }
.content > .stack:first-child { margin-bottom: 20px; }

/* ---------- Bausteine ---------- */
.stack > * + * { margin-top: 12px; }
.narrow { max-width: 420px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0 0 16px; }
.toolbar h1 { margin: 0 auto 0 0; }
.toolbar label { font-weight: 500; font-size: var(--fs-s); }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 24px; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 0; color: var(--muted); }

.empty {
  color: var(--muted); padding: 22px 20px; margin: 0; max-width: none;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-surface);
}
td.empty { border: 0; border-radius: 0; text-align: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  font: inherit; font-size: var(--fs-s); font-weight: 500; line-height: 1.2; padding: 8px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-soft); border-color: var(--ink); }
.btn-primary { background: var(--bottle); border-color: var(--bottle); color: var(--on-bottle); }
.btn-primary:hover { background: var(--bottle-hover); border-color: var(--bottle-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-text); border-color: var(--red-text); }
.btn-link, button.btn-link {
  font: inherit; font-size: inherit; border: 0; background: none; color: var(--bottle); padding: 2px 0; min-height: 0;
  cursor: pointer; text-decoration: underline; text-decoration-color: rgba(15, 59, 51, .35); text-underline-offset: 3px;
}
.btn-link:hover { background: none; text-decoration-color: currentColor; }

/* Tabellen: weisse Fläche, ruhiger Kopf, Zahlen rechtsbündig */
.table-wrap {
  position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface);
  margin-bottom: 16px; -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th {
  background: var(--surface-soft); color: var(--muted); font-weight: 500; font-size: var(--fs-xs); line-height: 1.35;
  padding-top: 10px; padding-bottom: 10px; white-space: nowrap; border-bottom-color: var(--line);
}
.table tbody th { font-weight: 500; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover > * { background-color: #fafbf9; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.table td a, .table th a { font-weight: 500; text-decoration: none; }
.table td a:hover, .table th a:hover { text-decoration: underline; }
.table input:not([type=checkbox]) { width: 100%; min-width: 7em; }
.table tr.overdue > td { background: var(--red-tint); }
.table tr.overdue:hover > td { background: var(--red-tint); }
.table-wrap + p { margin-top: -4px; }

/* Matrizen: erste Spalte bleibt stehen, rechter Rand blendet aus, solange seitlich noch etwas folgt */
.table .sticky-col { position: sticky; left: 0; z-index: 1; background-color: var(--surface); }
.table thead .sticky-col { z-index: 2; background-color: var(--surface-soft); }
.table tbody tr:hover > .sticky-col { background-color: #fafbf9; }
.scroll-frame { margin-bottom: 16px; }
.scroll-frame .table-wrap { margin-bottom: 0; }
.scroll-frame.is-scrolled .sticky-col { box-shadow: inset -1px 0 0 var(--line), 6px 0 8px -6px rgba(15, 59, 51, .22); }
.scroll-frame.is-scrollable:not(.at-end) .table-wrap {
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 44px); mask-image: linear-gradient(to left, transparent 0, #000 44px);
}
.scroll-hint { display: none; margin: 0 0 6px; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); text-align: right; }
.scroll-hint::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px; vertical-align: 1px;
  border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(45deg);
}
@media (max-width: 720px), (pointer: coarse) {
  .scroll-frame.is-scrollable:not(.at-end) .scroll-hint { display: block; }
}
.table-wrap[role="region"]:focus-visible { outline-offset: 2px; border-radius: var(--r-surface); }

/* Ampel: Form trägt die Bedeutung mit (Kreis, Raute, Quadrat, Ring) */
.dot {
  display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: 1px; flex: none;
  border-radius: 50%; background: var(--grey);
}
.dot-green { background: var(--green); border-radius: 50%; }
.dot-yellow { background: var(--amber); border-radius: 1px; transform: rotate(45deg) scale(.9); }
.dot-red { background: var(--red); border-radius: 1px; }
.dot-grey { background: transparent; border: 2px solid var(--grey); }

/* Badges */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-control); font-size: var(--fs-xs); font-weight: 500; line-height: 1.45;
  background: var(--surface-soft); border: 1px solid var(--line); color: var(--ink); vertical-align: 1px; white-space: nowrap;
}
.badge-red, .badge-missed { background: var(--red-tint); border-color: #e7b9b5; color: var(--red-text); }
.badge-at_risk { background: var(--amber-tint); border-color: #e6cf9c; color: var(--amber-text); }
.badge-on_track, .badge-achieved { background: var(--green-tint); border-color: #b9d5c1; color: var(--green-text); }
.badge-planned { color: var(--muted); }

/* Reiter: klare Unterstreichung */
.tabs {
  position: relative; display: flex; gap: 0 28px; border-bottom: 1px solid var(--line); margin: 28px 0 28px;
  overflow-x: auto; scrollbar-width: none;
}
/* Weiche Kante, solange links oder rechts weitere Reiter liegen (Klassen setzt app.js) */
.tabs.fade-r { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 40px); mask-image: linear-gradient(to left, transparent 0, #000 40px); }
.tabs.fade-l { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 40px); mask-image: linear-gradient(to right, transparent 0, #000 40px); }
.tabs.fade-l.fade-r {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 40px, #000 calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 40px, #000 calc(100% - 40px), transparent 100%);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 0 12px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: var(--fs-s);
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a.aktiv { color: var(--ink); border-bottom-color: var(--bottle); }

/* Hinweise */
.alert {
  padding: 12px 16px; border-radius: var(--r-control); border: 1px solid var(--line); border-left-width: 4px;
  background: var(--surface); font-size: var(--fs-s); max-width: 90ch;
}
.alert-info { border-color: #c4d4cd; border-left-color: var(--bottle); background: #f3f7f5; }
.alert-warn { border-color: #e6cf9c; border-left-color: var(--amber); background: #fcf7ea; }
.alert-error { border-color: #e7b9b5; border-left-color: var(--red); background: #fcf1f0; color: var(--red-text); }
.alert { margin-bottom: 12px; }
.form-row .alert { padding: 6px 10px; border-left-width: 3px; margin-bottom: 0; }

/* Formulare: Beschriftung oben */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row label { font-weight: 500; font-size: var(--fs-s); }
.form-row .muted { font-size: var(--fs-xs); }
.form-row ul { margin: 0; padding: 0; list-style: none; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=search], input[type=url], input[type=tel], input:not([type]), select, textarea {
  font: inherit; font-size: var(--fs-m); min-height: 40px; padding: 8px 12px; max-width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); color: var(--ink);
}
textarea { line-height: 1.5; min-height: 0; }
select { padding-right: 32px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--bottle); vertical-align: -3px; }
input[type=file] { font: inherit; font-size: var(--fs-s); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 500; margin-right: 12px; padding: 7px 14px; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--bottle); }
.narrow-form {
  max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); padding: 24px 24px 8px;
  margin-bottom: 16px;
}
.narrow-form input[type=text], .narrow-form input[type=email], .narrow-form input[type=number], .narrow-form input[type=date],
.narrow-form input[type=url], .narrow-form input[type=tel], .narrow-form input[type=password], .narrow-form input:not([type]),
.narrow-form select, .narrow-form textarea { width: 100%; }
.narrow-form > .toolbar:last-child { margin: 8px 0 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check-list { display: flex; flex-direction: column; gap: 6px; padding: 0; list-style: none; }
.check-list label { font-weight: 400; }
details { margin: 8px 0; }
summary { cursor: pointer; color: var(--bottle); font-weight: 500; font-size: var(--fs-s); padding: 4px 0; }
summary:hover { text-decoration: underline; text-underline-offset: 3px; }
details[open] > summary { margin-bottom: 10px; }
form.inline { display: inline; margin-left: 8px; }
.toolbar form.inline { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 0; }
.actions { white-space: nowrap; }
.actions form { display: inline; margin-left: 8px; }
.actions > :first-child { margin-left: 0; }

/* Faktenlisten */
.facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 10px 32px; max-width: 760px; margin: 0 0 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); padding: 20px 24px;
}
.facts dt { color: var(--muted); font-size: var(--fs-s); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.hash { font-family: ui-monospace, Menlo, monospace; font-size: var(--fs-xs); word-break: break-all; }
main code { overflow-wrap: anywhere; }
.signature { max-height: 80px; border: 1px solid var(--line); background: #fff; border-radius: var(--r-control); }
.mailbody {
  overflow-wrap: anywhere; padding: 16px 20px; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-surface); margin-bottom: 16px; max-width: 90ch;
}
pre.mailbody { white-space: pre-wrap; font-family: var(--font); font-size: var(--fs-s); }
.pdf-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--r-surface); background: var(--surface); }

/* Verweisliste (Verwaltung) */
.link-list { list-style: none; padding: 0; margin: 0; max-width: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); }
.link-list li + li { border-top: 1px solid var(--line); }
.link-list a { display: block; padding: 16px 20px; text-decoration: none; color: var(--ink); font-weight: 500; }
.link-list a:hover { background: var(--surface-soft); }
.link-list a span { display: block; color: var(--muted); font-weight: 400; font-size: var(--fs-s); }
.link-list li:first-child a { border-radius: var(--r-surface) var(--r-surface) 0 0; }
.link-list li:last-child a { border-radius: 0 0 var(--r-surface) var(--r-surface); }

/* Traktanden und Sitzungsmodus */
.agenda-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface);
  padding: 4px 24px 16px; margin: 12px 0; max-width: 980px;
}
.agenda-item h3, .agenda-item h4 { margin: 16px 0 6px; }
.agenda-item textarea.notes { width: 100%; }
.agenda-item details { margin: 6px 0; }
.agenda-item .toolbar { margin: 12px 0 8px; }
.save-status { display: inline-block; font-size: var(--fs-xs); margin-top: 6px; min-height: 1.4em; }
.mode-live .agenda-item { padding: 8px 28px 20px; scroll-margin-top: 16px; }
.mode-live .agenda-item h3 { font-size: var(--fs-l); margin-top: 18px; }
.mode-live .agenda-item label[for^="notes-"] { display: block; font-weight: 500; font-size: var(--fs-s); margin: 14px 0 6px; }
.mode-live .agenda-item textarea.notes { font-size: 17px; min-height: 9em; padding: 12px 14px; }
.mode-live .check-list { font-size: 17px; gap: 10px; }
.mode-live summary { padding: 8px 0; font-size: var(--fs-m); }

/* ---------- Firmenkopf mit Registerleiste ---------- */
.company-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; margin-bottom: 20px; }
.company-title { min-width: 0; }
.company-head h1 { font-size: var(--fs-xxl); line-height: 1.08; letter-spacing: -.025em; margin: 0; overflow-wrap: anywhere; }
.company-head h1 .badge { font-size: var(--fs-xs); letter-spacing: 0; vertical-align: 8px; }
.company-links { margin: 8px 0 0; font-size: var(--fs-s); }
.company-head-extra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.company-head-extra form { margin: 0; }

.company-summary {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface);
  box-shadow: inset 0 2px 0 var(--brass); overflow: hidden;
}
.register {
  display: grid; grid-template-rows: auto auto; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 0;
}
.register dt, .register dd { padding: 0 20px; border-left: 1px solid var(--line); }
.register dt { padding-top: 16px; color: var(--muted); font-size: var(--fs-xs); }
.register dd { margin: 0; padding-bottom: 16px; padding-top: 2px; font-size: 17px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.register dt:first-of-type, .register dd:first-of-type { border-left: 0; }
.register .nowrap { white-space: nowrap; }
.register .reg-sub { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.register .stale { color: var(--amber-text); }
.register-line {
  display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0; max-width: none; padding: 11px 20px;
  border-top: 1px solid var(--line); background: var(--surface-soft); font-size: var(--fs-s);
}
.register-line .label { color: var(--muted); margin-right: 6px; }
.overdue-text { color: var(--red-text); font-weight: 500; }

/* ---------- Startseite: Ampel-Matrix ---------- */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; margin: 36px 0 14px; }
.section-head h2 { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; padding: 0; margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.legend li { display: inline-flex; align-items: center; }
.legend .dot { margin-right: 6px; }

.kpi-matrix { font-size: var(--fs-s); }
.kpi-matrix thead th, .kpi-matrix thead th.num {
  white-space: normal; vertical-align: bottom; min-width: 88px; hyphens: auto; -webkit-hyphens: auto; hyphenate-limit-chars: 12 6 6;
}
.kpi-matrix th, .kpi-matrix td { padding-left: 10px; padding-right: 10px; }
.kpi-matrix th:first-child { padding-left: 16px; }
.kpi-matrix thead th.firm-col { min-width: 0; }
.kpi-matrix .firm-col { text-align: left; }
.kpi-matrix tbody th.firm-col { font-weight: 500; white-space: nowrap; }
.kpi-matrix tbody th.firm-col a { font-weight: 600; color: var(--ink); text-decoration: none; }
.kpi-matrix tbody th.firm-col a:hover { text-decoration: underline; }
.kpi-matrix .asof { display: block; white-space: nowrap; padding-left: 18px; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.kpi-matrix .asof.stale { color: var(--amber-text); }
.kpi-matrix tbody td { padding-top: 15px; padding-bottom: 15px; border-left: 1px solid var(--surface); font-size: var(--fs-s); font-weight: 500; }
.kpi-matrix tbody td .dot { margin-right: 6px; }
.kpi-matrix td.cell-green { background-color: var(--green-tint); }
.kpi-matrix td.cell-yellow { background-color: var(--amber-tint); }
.kpi-matrix td.cell-red { background-color: var(--red-tint); }
.kpi-matrix tbody tr:hover > td.cell-green { background-color: #d9e9de; }
.kpi-matrix tbody tr:hover > td.cell-yellow { background-color: #f2e3c2; }
.kpi-matrix tbody tr:hover > td.cell-red { background-color: #f0d2cf; }
.kpi-matrix tbody tr > * { border-bottom-color: var(--surface); border-bottom-width: 2px; }
.kpi-matrix .trend { display: inline-block; width: .9em; margin-left: 3px; color: var(--muted); font-weight: 400; text-align: center; }
.kpi-matrix .none { color: var(--muted); font-weight: 400; }

/* Die einzige Ladeanimation: Ampeltöne laufen einmal von links nach rechts ein */
@media (prefers-reduced-motion: no-preference) {
  .kpi-matrix td[class*="cell-"] { animation: tint-in .7s cubic-bezier(.2, .7, .2, 1) both; }
  .kpi-matrix td:nth-child(3) { animation-delay: .05s; }
  .kpi-matrix td:nth-child(4) { animation-delay: .1s; }
  .kpi-matrix td:nth-child(5) { animation-delay: .15s; }
  .kpi-matrix td:nth-child(6) { animation-delay: .2s; }
  .kpi-matrix td:nth-child(7) { animation-delay: .25s; }
  .kpi-matrix td:nth-child(8) { animation-delay: .3s; }
  .kpi-matrix td:nth-child(n+9) { animation-delay: .35s; }
}
@keyframes tint-in { from { background-color: var(--surface); } }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }
.home-grid > div > h2:first-child { margin-top: 40px; }
.firm-list td:first-child { white-space: nowrap; }
.firm-list td:first-child a { font-weight: 600; color: var(--ink); text-decoration: none; }
.firm-list td:first-child a:hover { text-decoration: underline; }
.inbox-note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; margin: 0 0 16px; max-width: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface);
}

/* ---------- Anmeldung und öffentliche Seiten ---------- */
body.auth { min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: minmax(320px, 5fr) 7fr; min-height: 100vh; }
.auth-aside {
  background: var(--bottle); color: var(--on-bottle); padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
}
.auth-aside .brand { color: var(--on-bottle); text-decoration: none; font-size: 20px; }
.auth-claim { max-width: 26ch; }
.auth-claim p { font-size: var(--fs-xl); line-height: 1.25; font-weight: 500; letter-spacing: -.015em; margin: 0 0 20px; }
.auth-claim .rule { display: block; width: 56px; height: 2px; background: var(--brass-light); margin-bottom: 20px; }
.auth-foot { color: var(--on-bottle-muted); font-size: var(--fs-xs); margin: 0; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-surface); padding: 32px;
}
.auth-card h1 { font-size: var(--fs-l); margin-bottom: 4px; }
.auth-card:not(.wide) .btn-primary { width: 100%; min-height: 44px; font-size: var(--fs-m); }
.auth-card input:not([type=checkbox]):not([type=radio]):not([type=file]) { width: 100%; }
.auth-card.wide .btn-primary { min-height: 44px; padding: 10px 28px; font-size: var(--fs-m); }

.public-bar { background: var(--bottle); padding: 18px 24px; }
.public-bar .brand { color: var(--on-bottle); text-decoration: none; }
.public-main { padding: 32px 24px 64px; }
.auth-card.wide { max-width: 960px; margin: 0 auto; }
.auth-card.wide h1 { font-size: var(--fs-xl); }

/* ---------- Mobil ---------- */
@media (max-width: 1100px) {
  .content { padding: 32px 28px 56px; }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 721px) and (max-width: 1240px) {
  .register { grid-template-rows: none; grid-auto-flow: row; grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); }
  .register dt, .register dd { border-left: 0; border-top: 1px solid var(--line); padding: 12px 16px; }
  .register dt { padding-right: 4px; }
  .register dt:nth-of-type(-n+2), .register dd:nth-of-type(-n+2) { border-top: 0; }
  .register dt:nth-of-type(even) { border-left: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; background: var(--paper); }
  .sidebar { height: auto; overflow: visible; }
  .sidebar-head { padding: 12px 16px; }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; font: inherit; font-size: var(--fs-s); font-weight: 500;
    color: var(--on-bottle); background: transparent; border: 1px solid rgba(255, 255, 255, .35); border-radius: var(--r-control); cursor: pointer;
  }
  .nav-toggle-icon, .nav-toggle-icon::before, .nav-toggle-icon::after {
    display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; position: relative;
  }
  .nav-toggle-icon::before, .nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
  .nav-toggle-icon::before { top: -5px; }
  .nav-toggle-icon::after { top: 5px; }
  .nav-toggle[aria-expanded="true"] .nav-toggle-icon { background: transparent; }
  .nav-toggle[aria-expanded="true"] .nav-toggle-icon::before { top: 0; transform: rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle-icon::after { top: 0; transform: rotate(-45deg); }
  .js .sidebar-panel { display: none; }
  .js .sidebar.open .sidebar-panel { display: flex; }
  .sidebar-panel { padding-bottom: 8px; border-top: 1px solid rgba(255, 255, 255, .12); max-height: calc(100vh - 64px); overflow-y: auto; }
  .mainnav { padding: 8px 12px; }
  .mainnav a { padding: 12px; font-size: var(--fs-m); }
  .user { margin-top: 0; padding: 14px 24px 12px; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; }
  .content { padding: 24px 16px 48px; }

  .auth-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-aside { padding: 20px 20px 24px; gap: 16px; }
  .auth-claim p { font-size: var(--fs-l); margin-bottom: 0; }
  .auth-claim .rule { margin-bottom: 12px; }
  .auth-foot { display: none; }
  .auth-main { align-items: flex-start; padding: 24px 16px 40px; }
  .auth-card { padding: 24px 20px; }
}
@media (max-width: 720px) {
  h1 { font-size: 24px; }
  h2 { font-size: 19px; margin-top: 32px; }
  .grid-2 { grid-template-columns: 1fr; }
  .company-head h1 { font-size: var(--fs-xl); }
  .register { grid-template-rows: none; grid-auto-flow: row; grid-template-columns: max-content minmax(0, 1fr); }
  .register dt, .register dd { border-left: 0; border-top: 1px solid var(--line); padding: 10px 16px; }
  .register dt:first-of-type, .register dd:first-of-type { border-top: 0; }
  .register dt { padding-right: 4px; align-self: stretch; }
  .register dd { font-size: var(--fs-m); }
  .register-line { padding: 10px 16px; flex-direction: column; }
  .table th, .table td { padding: 10px 12px; }
  .table:not(.table-stack) td:not(.num):not(.empty) { min-width: 8.5em; }
  .kpi-matrix thead th.firm-col { min-width: 150px; }
  .kpi-matrix tbody th.firm-col { white-space: normal; min-width: 168px; }
  .kpi-history .sticky-col { min-width: 136px; max-width: 168px; white-space: normal; }

  /* Listen: jede Zeile ein Block; Hauptzeile oben, Nebenangaben mit kleiner Beschriftung (data-label) */
  .table-stack, .table-stack tbody, .table-stack tfoot { display: block; width: 100%; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .table-stack tr { display: flex; flex-direction: column; gap: 5px; padding: 14px 16px 15px; border-bottom: 1px solid var(--line); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack tfoot tr { border-top: 1px solid var(--ink); }
  .table.table-stack tr > td, .table.table-stack tr > th {
    display: block; padding: 0; border: 0; min-width: 0; text-align: left; white-space: normal; background-color: transparent;
  }
  .table.table-stack tr > :empty { display: none; }
  .table-stack tr.overdue { background: var(--red-tint); }
  .table-stack .cell-kicker { order: -2; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); }
  .table-stack .cell-main { order: -1; font-size: var(--fs-m); font-weight: 600; line-height: 1.35; margin-bottom: 3px; overflow-wrap: anywhere; }
  .table-stack .cell-main a, .table-stack .cell-main strong { font-weight: 600; }
  .table.table-stack tr > [data-label] { padding-left: 128px; text-indent: -128px; overflow-wrap: anywhere; }
  .table-stack [data-label]::before {
    content: attr(data-label); display: inline-block; box-sizing: border-box; width: 128px; padding-right: 10px; text-indent: 0; vertical-align: top;
    font-size: var(--fs-xs); font-weight: 500; line-height: 1.75; color: var(--muted); overflow-wrap: normal;
  }
  .table-stack [data-label] > * { text-indent: 0; }
  .table.table-stack tr > [data-label].cell-field {
    display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; padding-left: 0; text-indent: 0;
  }
  .table-stack .cell-field > input, .table-stack .cell-field > select { width: 100%; min-width: 0; }
  .table.table-stack tr > .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 6px; }
  .table-stack .actions form { margin-left: 0; }
  .table-stack .actions .sep { display: none; }
  .table.table-stack td.empty { padding: 4px 0; text-align: left; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 16px 18px; }
  .facts dd { margin-bottom: 10px; }
  .agenda-item, .mode-live .agenda-item { padding: 4px 16px 14px; }
  .narrow-form { padding: 18px 16px 4px; }
  .pdf-frame { height: 60vh; }
}

/* ---------- Druck ---------- */
@media print {
  .sidebar, .skip, .toolbar, .tabs, .btn, .company-head-extra, .nav-toggle, details { display: none !important; }
  body { color: #000; background: #fff; font-size: 11pt; }
  .shell { display: block; background: none; }
  .content { margin: 0; padding: 0; max-width: none; }
  .table-wrap, .company-summary, .facts, .agenda-item, .narrow-form, .empty { border-color: #bbb; overflow: visible; box-shadow: none; }
  .company-summary { box-shadow: inset 0 2px 0 var(--brass); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi-matrix td { -webkit-print-color-adjust: exact; print-color-adjust: exact; animation: none !important; }
  .table tbody tr:hover > * { background-color: inherit; }
  a { color: #000; text-decoration: none; }
  h1, h2, h3 { break-after: avoid; }
  tr { break-inside: avoid; }
}
