/* Feuerwehr-Plattform: Grundstil
   Farben angelehnt an Uniform (Nachtblau), Fahrzeug (Feuerrot)
   und Reflexstreifen (Leuchtgelb / Silber). */

:root {
  --paper:     #E8ECEF;
  --surface:   #FFFFFF;
  --ink:       #17232E;
  --ink-2:     #4A5763;
  --line:      #CBD2D8;
  --red:       #B0231B;
  --red-dark:  #8C1B15;
  --header:    #17232E;
  --header-fg: #FFFFFF;
  --reflex:    #D9E021;
  --silver:    #B9C0C6;

  --ok:        #2E7D4F;
  --warn:      #8A6A12;
  --bad:       #B0231B;
  --info:      #2F5E8C;

  --font:      'Barlow', 'Segoe UI', system-ui, sans-serif;
  --font-cond: 'Barlow Condensed', 'Arial Narrow', 'Segoe UI', sans-serif;

  --radius-s:  4px;
  --radius-m:  8px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: var(--font-cond);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}

.muted { color: var(--ink-2); }

:focus-visible {
  outline: 3px solid var(--reflex);
  outline-offset: 2px;
}

/* ---------- Reflexstreifen: das eine markante Element ---------- */

.reflex {
  height: 8px;
  background: linear-gradient(
    to bottom,
    var(--reflex) 0 3px,
    var(--silver) 3px 5px,
    var(--reflex) 5px 8px
  );
}

/* ---------- Buttons und Felder ---------- */

.btn {
  font: 600 15px/1 var(--font);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 10px 16px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .55; cursor: default; }

.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }

.btn.ghost-light {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
  padding: 8px 12px;
}
.btn.ghost-light:hover { border-color: #fff; }

.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.wide { width: 100%; }

.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field span { font-weight: 600; font-size: 14px; }

input, select, textarea {
  font: 16px var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 9px 10px;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
textarea { resize: vertical; line-height: 1.4; }

.error {
  color: var(--bad);
  font-weight: 600;
  margin: 0 0 14px;
}

/* ---------- Laden ---------- */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--ink-2);
}

/* ---------- Anmeldung ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.login-body { padding: 28px 28px 32px; }
.login-card h1 { font-size: 30px; }
.login-card p.muted { margin: 6px 0 24px; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-s);
  background: var(--red);
  color: #fff;
  font: 700 18px/1 var(--font-cond);
  letter-spacing: .02em;
  flex: none;
}
.brand-mark.small { width: 32px; height: 32px; font-size: 15px; }

/* ---------- Kopfzeile ---------- */

.topbar { background: var(--ink); color: #fff; }

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.tenant { display: flex; align-items: center; gap: 10px; flex: none; max-width: 320px; }

.tenant-name {
  font: 700 22px/1.1 var(--font-cond);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenant-select {
  max-width: 270px;
  text-overflow: ellipsis;
  font: 700 20px var(--font-cond);
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
  padding: 4px 8px;
}
.tenant-select option { color: var(--ink); }

.tabs { display: flex; gap: 4px; }

.tab {
  font: 600 18px/1 var(--font-cond);
  letter-spacing: .02em;
  color: rgba(255, 255, 255, .75);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px 14px 9px;
  cursor: pointer;
}
.tab:hover { color: #fff; }
.tab[aria-current="page"] { color: #fff; border-bottom-color: var(--red); }

.user { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-text { display: grid; text-align: right; line-height: 1.25; }
.user-name { font-weight: 600; }
.user-roles { font-size: 13px; color: rgba(255, 255, 255, .7); }

/* ---------- Inhalt ---------- */

.view {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.view-head h2 { font-size: 34px; }
.view-head .count { color: var(--ink-2); margin-left: 10px; font: 500 18px var(--font-cond); }
.view-head input[type="search"] { width: min(340px, 100%); }

.section-title {
  font-size: 22px;
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--ink);
}
.section-title:first-of-type { margin-top: 8px; }

.state {
  padding: 28px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  color: var(--ink-2);
}

/* ---------- Tabellen ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font: 600 15px var(--font-cond);
  letter-spacing: .02em;
  color: var(--ink-2);
  background: #F5F7F8;
}
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.rank {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  font: 700 16px/1 var(--font-cond);
  padding: 5px 6px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-s);
}
.rank.none { border-style: dashed; border-color: var(--line); color: var(--ink-2); }

.person-name { font-weight: 600; }
.row-inactive td { color: var(--ink-2); }

.tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #EEF1F3;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.ok   { background: #E3F1E8; color: var(--ok); }
.tag.warn { background: #F6EFD9; color: var(--warn); }
.tag.bad  { background: #F6E2E0; color: var(--bad); }
.tag.info { background: #E2ECF5; color: var(--info); }

/* ---------- Übungen ---------- */

.exercise {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  margin-bottom: 10px;
}
.exercise[open] { border-color: var(--ink-2); }

.exercise > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
}
.exercise > summary::-webkit-details-marker { display: none; }

.ex-date {
  display: grid;
  justify-items: center;
  line-height: 1;
  padding: 8px 0;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: #fff;
}
.ex-day   { font: 600 13px var(--font-cond); color: rgba(255, 255, 255, .75); }
.ex-dnum  { font: 700 28px var(--font-cond); margin: 2px 0; }
.ex-month { font: 600 13px var(--font-cond); }

.ex-main h3 { font-size: 22px; }
.ex-main p { margin: 2px 0 0; color: var(--ink-2); }

.ex-meta { display: grid; justify-items: end; gap: 6px; text-align: right; }
.ex-counts { font-size: 14px; color: var(--ink-2); }

.ex-body {
  border-top: 1px solid var(--line);
  padding: 16px 18px 20px;
  display: grid;
  gap: 16px;
}
.ex-body .table-wrap { border-radius: var(--radius-s); }
.ex-desc { margin: 0; max-width: 70ch; }

.my-answer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #F5F7F8;
  border-left: 4px solid var(--red);
  border-radius: var(--radius-s);
}
.my-answer strong { margin-right: auto; }

.invite-box {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.invite-box p { margin: 0; color: var(--ink-2); max-width: 60ch; }

td select, td input { padding: 6px 8px; font-size: 15px; }
td input.hours { width: 80px; text-align: right; }

/* ---------- Personenliste: Werkzeuge ---------- */

.view-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--ink-2);
  cursor: pointer;
}
.dlg-body > .check { display: flex; margin: 6px 0; color: var(--ink); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--red); }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #F5F7F8; }
tr.clickable:focus-visible { outline-offset: -3px; }

.btn.danger { background: var(--surface); color: var(--red); border-color: var(--red); }
.btn.danger:hover:not(:disabled) { background: var(--red); color: #fff; }

.small { font-size: 14px; }

/* ---------- Dialog ---------- */

.dialog {
  width: min(680px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-m);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(23, 35, 46, .35);
}
.dialog::backdrop { background: rgba(23, 35, 46, .55); }

.dlg {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.dlg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  border-top: 6px solid var(--red);
}
.dlg-head h2 { font-size: 28px; }
.dlg-head p { margin: 2px 0 0; }

.icon-btn {
  font-size: 28px;
  line-height: 1;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: #EEF1F3; color: var(--ink); }

.dlg-body {
  overflow-y: auto;
  padding: 18px 22px 8px;
}

.dlg-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #F5F7F8;
}

.dlg-section {
  padding: 4px 0 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.dlg-section:last-child { border-bottom: 0; margin-bottom: 0; }
.dlg-section h3 { font-size: 20px; margin-bottom: 10px; }
.dlg-section p { margin: 0 0 10px; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.grid2 .field input, .grid2 .field select { width: 100%; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.inline-form .field { margin-bottom: 0; }
.inline-form .btn { padding: 10px 14px; }

.assignments {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.assignments li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.assignments li:last-child { border-bottom: 0; }

.history {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 14px;
}

/* ---------- Übungen: Bearbeiten ---------- */

.grid2 .span2 { grid-column: 1 / -1; }
.grid2 .field textarea { width: 100%; }

.groups-field {
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 14px 12px;
  margin: 14px 0 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.groups-field legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
.groups-field p { flex-basis: 100%; margin: 4px 0 0; }
.groups-field:disabled .check { opacity: .6; cursor: default; }

.ex-kind { font-weight: 600; color: var(--red) !important; }

.ex-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- Personalien: Führerausweis, Grössen, Vertraulich ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  min-width: 48px;
  text-align: center;
  padding: 7px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  font: 700 16px/1 var(--font-cond);
  color: var(--ink-2);
  background: var(--surface);
}
.chip:hover span { border-color: var(--ink-2); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--reflex); outline-offset: 2px; }
.chip input:disabled + span { cursor: default; opacity: .7; }

.licences {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
  margin-bottom: 8px;
}
.licence-row { display: flex; align-items: center; gap: 8px; }
.licence-row .chip span { min-width: 92px; white-space: nowrap; }
.licence-date { display: flex; align-items: center; gap: 6px; flex: 1; }
.licence-date span { font-size: 13px; color: var(--ink-2); }
.licence-date input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 15px; }
.licence-date input:disabled { background: #F5F7F8; color: var(--line); }

.grid-sizes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0 12px;
}
.grid-sizes .field input { width: 100%; }

.confidential .dlg-section {
  background: #FBF7EC;
  margin: 0 -22px 14px;
  padding: 16px 22px 18px;
  border-top: 1px solid #E8DDBF;
  border-bottom: 1px solid #E8DDBF;
}

.dlg-section .form-actions { margin-top: 6px; }

/* ---------- Dokumente ---------- */

.documents {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.documents li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.documents li:last-child { border-bottom: 0; }
.doc-main { display: grid; gap: 2px; min-width: 0; }
.doc-main strong { overflow-wrap: anywhere; }
.doc-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.doc-tags:empty { display: none; }
.doc-actions { display: flex; gap: 8px; flex: none; }

.upload {
  padding: 14px;
  border: 1px dashed var(--ink-2);
  border-radius: var(--radius-s);
  background: #F5F7F8;
}
.file-field input[type="file"] { width: 100%; background: var(--surface); }
.upload .grid2 .field input, .upload .grid2 .field select { width: 100%; }

/* ---------- Verwaltung ---------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--ink);
  border-radius: var(--radius-s);
  overflow: hidden;
}
.segmented button {
  font: 600 16px/1 var(--font-cond);
  letter-spacing: .02em;
  padding: 10px 16px;
  border: 0;
  border-left: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.segmented button:first-child { border-left: 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.order-cell { width: 84px; white-space: nowrap; }
.icon-btn.small { width: 32px; height: 32px; font-size: 18px; }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.row-actions { text-align: right; }
.row-actions .btn { margin: 2px 0 2px 6px; white-space: nowrap; }

.add-row {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.add-row h3 { font-size: 20px; margin-bottom: 10px; }
.add-row input.short { width: 110px; }

.defaults-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.defaults-box p { margin: 0; max-width: 70ch; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Login und Einladung ---------- */

.role-choice { display: flex; align-items: center; gap: 10px; flex-basis: 100%; min-height: 38px; }
.role-choice select { padding: 6px 8px; font-size: 15px; }

.invite-link {
  padding: 14px;
  margin-bottom: 14px;
  border: 2px solid var(--ok);
  border-radius: var(--radius-s);
  background: #EEF7F1;
}
.invite-link p { margin: 0 0 10px; }
.invite-link input { width: 100%; font-size: 14px; margin-bottom: 10px; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; }
a.btn { display: inline-block; text-decoration: none; }

.btn.spaced { margin-top: 10px; }
.linkish {
  display: block;
  margin: 16px auto 0;
  background: none;
  border: 0;
  color: var(--info);
  font: 600 15px var(--font);
  text-decoration: underline;
  cursor: pointer;
}
.login-body p { margin: 0 0 14px; }

/* ---------- Übersicht ---------- */

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px 20px;
}
.card h3 { font-size: 22px; margin-bottom: 12px; }
.card p { margin: 0 0 10px; }
.card .field input { width: 100%; }
.span-wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.next-list { list-style: none; margin: 0; padding: 0; }
.next-list li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.next-list li:first-child { border-top: 0; padding-top: 0; }
.next-main { display: grid; gap: 2px; min-width: 0; }
.next-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.small-date { padding: 6px 0; }
.small-date .ex-dnum { font-size: 22px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 0 0 12px;
}
.stats div { padding: 10px 12px; background: #F5F7F8; border-radius: var(--radius-s); }
.stats dt { font-size: 13px; color: var(--ink-2); }
.stats dd { margin: 2px 0 0; font: 700 30px/1.1 var(--font-cond); }
.stats dd span { font-size: 18px; color: var(--ink-2); font-weight: 600; }
.stats dd.bad { color: var(--bad); }

.facts { margin: 0 0 10px; }
.facts div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--ink-2); font-size: 14px; }
.facts dd { margin: 0; }

.documents.compact li { padding: 8px 10px; }

/* ---------- Support ---------- */

.support-banner { background: var(--reflex); color: var(--ink); }
.support-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 15px;
}

.radio {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
}
.radio input { margin-top: 4px; accent-color: var(--red); width: 18px; height: 18px; flex: none; }
.radio:has(input:checked) { border-color: var(--ink); background: #F5F7F8; }

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  margin-top: 14px;
  border: 1px solid #E6C3C0;
  border-radius: var(--radius-s);
  background: #FBF3F2;
}
.danger-zone p { margin: 2px 0 0; }

.tenant-name { max-width: 300px; }

/* ---------- Material ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.filters select, .filters input { padding: 8px 10px; font-size: 15px; }
.filters input[type="search"] { flex: 1; min-width: 220px; }
.filters .btn { margin-left: auto; }
td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }

.history.plain { list-style: none; padding: 0; }
.history.plain li { padding: 4px 0; border-top: 1px solid var(--line); }
.history.plain li:first-child { border-top: 0; }

.warn-box {
  padding: 10px 12px;
  border-left: 4px solid var(--warn);
  background: #F6EFD9;
  border-radius: var(--radius-s);
}

/* ---------- Rechte ---------- */

.matrix-wrap {
  overflow: auto;
  max-height: 72vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.matrix { border-collapse: separate; border-spacing: 0; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 8px 10px; }
.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #F5F7F8;
  vertical-align: bottom;
  text-align: center;
  min-width: 96px;
}
.matrix thead th.sticky { z-index: 3; text-align: left; }
.matrix .sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  min-width: 260px;
  max-width: 320px;
}
.matrix .role-name { display: block; font: 700 16px/1.15 var(--font-cond); color: var(--ink); }
.matrix .scope { display: block; font: 500 12px var(--font); color: var(--ink-2); margin-top: 3px; }
.matrix td { text-align: center; }
.matrix .perm-label { font: 500 15px var(--font); color: var(--ink); }
.matrix .module-row th {
  background: var(--ink);
  color: #fff;
  font: 700 16px var(--font-cond);
  letter-spacing: .03em;
  text-transform: uppercase;
}
.matrix tbody tr:not(.module-row):hover td,
.matrix tbody tr:not(.module-row):hover th { background: #F5F7F8; }
.perm-box { width: 20px; height: 20px; accent-color: var(--red); cursor: pointer; }
.perm-box:disabled { cursor: not-allowed; opacity: .6; }

/* ---------- Material: Menü, Bilder, Prüfplan ---------- */


.tab-menu {
  position: absolute;
  z-index: 20;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: var(--radius-s);
  box-shadow: 0 10px 30px rgba(23, 35, 46, .25);
}
.tab-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-s);
  font: 600 16px var(--font);
  color: var(--ink);
  cursor: pointer;
}
.tab-menu button:hover, .tab-menu button:focus-visible { background: #F5F7F8; }
.tab-menu button[aria-current="page"] { background: var(--ink); color: #fff; }

.crumb { font-size: .6em; color: var(--ink-2); display: block; letter-spacing: .02em; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); }
.thumbs.large figure { position: relative; margin: 0; }
.thumbs.large img { width: 140px; height: 105px; }
.thumbs.large .icon-btn {
  position: absolute; top: 4px; right: 4px;
  background: rgba(255, 255, 255, .9); color: var(--bad);
}
.file-chip {
  display: inline-block; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: #F5F7F8; font-size: 14px;
}

h3.sub { font-size: 18px; margin: 16px 0 8px; }
.plan-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.plan-table th, .plan-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.plan-table input.short { width: 110px; }

.linkish.inline { display: inline; margin: 0; padding: 0; font-size: 14px; }
.assignments .inline-actions { flex: none; }

/* ---------- Materialmenü: Gruppen ---------- */

.tab-menu { border-top-width: 3px; margin-top: 0; }
.menu-group {
  padding: 8px 12px 2px;
  font: 700 12px var(--font);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.menu-group:not(:first-child) { border-top: 1px solid var(--line); margin-top: 4px; }

/* ---------- Stammblatt ---------- */

.dialog:has(.sheet) { width: min(1040px, calc(100% - 24px)); }
.sheet { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  border-top: 5px solid var(--red);
}
.sheet-head h2 { font-size: 24px; }
.sheet-head h2 .sub { font: 500 16px var(--font); color: rgba(255, 255, 255, .75); margin-left: 8px; }
.sheet-head .icon-btn { color: #fff; }
.sheet-head .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.sheet-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 18px 0;
  background: #EEF1F3;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.sheet-tabs button {
  font: 600 15px var(--font);
  padding: 8px 14px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.sheet-tabs button:hover { color: var(--ink); }
.sheet-tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.sheet-body { overflow-y: auto; padding: 16px 18px; }
.sheet-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr);
  gap: 20px;
  align-items: start;
}
.sheet-fields { display: grid; gap: 8px; }
.sheet-fields .row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.sheet-fields .row > span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.sheet-fields .row input, .sheet-fields .row select, .sheet-fields .row textarea { width: 100%; padding: 7px 9px; font-size: 15px; }
.sheet-fields .row:has(textarea) { align-items: start; }
.sheet-fields .row:has(textarea) > span { padding-top: 8px; }
.sheet-fields input:disabled, .sheet-fields select:disabled, .sheet-fields textarea:disabled { background: #F5F7F8; color: var(--ink-2); }
.row-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  margin: 4px -10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
}

.sheet-side { display: grid; gap: 14px; }
.box {
  margin: 0 0 14px;
  padding: 10px 14px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
}
.sheet-side .box { margin: 0; }
.box legend { font: 700 15px var(--font); padding: 0 6px; color: var(--ink); }
.box p { margin: 4px 0; }

.photo-main {
  display: grid;
  place-items: center;
  height: 180px;
  border-radius: var(--radius-s);
  background: #F5F7F8;
  overflow: hidden;
  margin-bottom: 8px;
}
.photo-main img { width: 100%; height: 180px; object-fit: contain; border: 0; }
.photo-main a { display: block; width: 100%; }
.photo-empty { color: var(--ink-2); font-size: 14px; }
.sheet-side .thumbs figure { position: relative; margin: 0; }
.sheet-side .thumbs img { width: 56px; height: 56px; }
.icon-btn.tiny {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; font-size: 16px;
  background: var(--surface); color: var(--bad); border: 1px solid var(--line); border-radius: 50%;
}
.photo-upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.photo-upload input[type="file"] { flex: 1; min-width: 0; font-size: 13px; }
#create-preview img { width: 100%; height: 180px; object-fit: contain; border: 0; }

.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #F5F7F8;
}
.inline-form .field.grow { flex: 1; min-width: 220px; }
.inline-form .field.grow input { width: 100%; }
.check-list { display: grid; gap: 4px; margin-bottom: 10px; }

/* ---------- Ausgabe und Rücknahme ---------- */

.issue-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
.issue-grid .field select { width: 100%; }
.issue-grid h4 { margin: 14px 0 6px; font: 700 16px var(--font-cond); }
.pick { max-height: 360px; overflow-y: auto; margin: 8px 0 10px; }
.pick tr.match td { background: #EEF7F1; }
.pick td:first-child { width: 36px; }
.pick input[type="radio"] { width: 18px; height: 18px; accent-color: var(--red); }

/* ---------- Atemschutz ---------- */

.as-summary { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.as-summary .stat {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 16px; background: var(--surface); border: 1px solid var(--line);
  border-left: 5px solid var(--ink-2); border-radius: var(--radius-s); font-weight: 600; color: var(--ink-2);
}
.as-summary .stat span { font: 700 28px/1 var(--font-cond); color: var(--ink); }
.as-summary .stat.ok { border-left-color: var(--ok); }
.as-summary .stat.warn { border-left-color: var(--warn); }
.as-summary .stat.bad { border-left-color: var(--bad); }
.as-summary .check { margin-left: auto; }

.notice {
  padding: 10px 14px; margin-bottom: 14px; border-left: 4px solid var(--info);
  background: #E2ECF5; border-radius: var(--radius-s);
}
.grid-as { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.grid-as .field input, .grid-as .field select { width: 100%; }
.grid-as .span2 { grid-column: span 2; }
.sub-head { margin: 24px 0 10px; }
.sub-head h3 { font-size: 22px; }
.field.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
.compare td.num, .compare th.num { min-width: 90px; }
.ok-text { color: var(--ok); font-weight: 600; }
.bad-text { color: var(--bad); font-weight: 600; }
.icon-btn.tiny-inline { width: 20px; height: 20px; font-size: 15px; vertical-align: middle; color: var(--bad); }

/* ---------- Übungen: Appel und Auswertung ---------- */

.appel { display: grid; gap: 4px; justify-items: start; }
.appel .check.small { font-size: 13px; }
.quote { display: flex; align-items: center; gap: 10px; }
.quote meter { width: 140px; height: 14px; }
.quote span { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; }
.filters .segmented { margin-left: 4px; }

/* ---------- Posten, Programm, Jahresplanung ---------- */

.post-card {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: center;
  width: 100%; text-align: left; padding: 12px 16px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  font: inherit; color: inherit; cursor: pointer;
}
.post-card:hover { border-color: var(--ink-2); }
.post-main { display: grid; gap: 2px; }
.lesson-table { width: 100%; border-collapse: collapse; }
.lesson-table th { text-align: left; font-size: 13px; color: var(--ink-2); padding: 4px 6px; }
.lesson-table td { padding: 4px 6px; vertical-align: top; border-top: 1px solid var(--line); }
.lesson-table input, .lesson-table textarea, .lesson-table select { width: 100%; padding: 6px 8px; font-size: 14px; }
.lesson-table td:first-child input.short { width: 70px; }
.lesson-table .s-time { white-space: nowrap; padding-top: 12px; color: var(--ink-2); }
.lesson-foot { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 14px; }
ul.tight, ol.tight { margin: 2px 0 8px; padding-left: 18px; font-size: 14px; }
.box .label { font-weight: 700; margin: 8px 0 2px; }
.box select { width: 100%; }
.post-edit { margin-bottom: 14px; }
.post-edit .grid2 textarea { width: 100%; }
.post-edit .grid2 select, .post-edit .grid2 input { width: 100%; }
.ex-actions.left { justify-content: flex-start; border-top: 0; padding-top: 0; }
.month-row th { background: #EEF1F3; font: 700 15px var(--font-cond); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Erscheinungsbild ---------- */

.topbar { background: var(--header); color: var(--header-fg); }
.topbar .tab { color: var(--header-fg); opacity: .72; }
.topbar .tab:hover, .topbar .tab[aria-current="page"] { color: var(--header-fg); opacity: 1; }
.topbar .user-roles { color: var(--header-fg); opacity: .72; }
.topbar .btn.ghost-light { color: var(--header-fg); border-color: currentColor; }
.topbar .tenant-select { color: var(--header-fg); border-color: currentColor; }
.brand-logo { height: 40px; width: auto; max-width: 140px; object-fit: contain; flex: none; }
.brand-logo.small { height: 34px; max-width: 110px; }

.brand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.color-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.color-row input[type="color"] { width: 64px; height: 40px; padding: 2px; }
.brand-preview { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 14px; }
.bp-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-family: var(--font-cond); font-size: 18px; }
.bp-logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-s); color: #fff; font: 700 14px var(--font-cond); overflow: hidden; }
.bp-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.bp-body { padding: 12px; background: var(--paper); }
.bp-btn { border: 0; border-radius: var(--radius-s); color: #fff; padding: 8px 14px; font: 600 14px var(--font); }
.bp-link { font: 700 18px var(--font-cond); margin-left: 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 14px; }

/* ---------- Startseite gestalten ---------- */

.hb { display: flex; flex-direction: column; min-width: 0; }
.hb > .card { flex: 1; }
.hb.editing { outline: 2px dashed var(--line); outline-offset: 4px; border-radius: var(--radius-m); }
.hb-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px; margin-bottom: 6px; background: #EEF1F3; border-radius: var(--radius-s);
}
.home-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.rich p { margin: 0 0 10px; }
.rich h4 { font: 700 18px var(--font-cond); margin: 12px 0 6px; }
.rich ul { margin: 0 0 10px; padding-left: 20px; }
.rich a, .link-list a { color: var(--red); font-weight: 600; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { padding: 8px 0; border-top: 1px solid var(--line); }
.link-list li:first-child { border-top: 0; }
.image-card figure { margin: 0; }
.image-card img { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius-s); display: block; }
.image-card figcaption { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.card.placeholder { border-style: dashed; background: #F5F7F8; }

/* ---------- Testumgebung ---------- */

.env-banner {
  position: sticky; top: 0; z-index: 30;
  padding: 6px 12px; text-align: center;
  background: #FFD60A; color: #17232E; font: 700 14px var(--font);
  border-bottom: 2px solid #17232E;
}
@media print { .env-banner { display: none; } }

/* ---------- Finanzen und Sold ---------- */

.pay-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.pay-table input.short { width: 68px; padding: 5px 6px; }
.pay-table input:not(.short) { width: 100%; min-width: 90px; padding: 5px 6px; }
.pay-table th, .pay-table td { padding-left: 8px; padding-right: 8px; }
.pay-table .row-actions { white-space: nowrap; }
.pay-table td { vertical-align: middle; }
.rate-table th.c, .rate-table td.c { text-align: center; }
.rate-table input.short { width: 90px; }
.fin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 8px; }
.fin-card { display: grid; gap: 4px; padding: 14px 16px; }
.fin-card strong { font: 700 28px/1.1 var(--font-cond); }
.inc-people { display: grid; gap: 4px; max-height: 420px; overflow-y: auto; }
.inc-person { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 14px; }
.inc-person input.short { width: 76px; padding: 4px 6px; }

/* ---------- Personen-Stammblatt ---------- */

.sheet-fields .row.readonly { align-items: start; min-height: 30px; }
.sheet-fields .row.readonly .value { padding-top: 2px; line-height: 1.5; }
.sheet-fields .row.readonly .value a { color: var(--red); }
.service-box .big { font: 700 40px/1 var(--font-cond); margin: 4px 0; }
.service-box .big span { font-size: 18px; color: var(--ink-2); }
.mail-list { list-style: none; margin: 8px 0; padding: 0; }
.mail-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; word-break: break-all; }
.mail-list li > span { flex: 1; }
.mail-add { display: grid; grid-template-columns: 1fr 90px auto; gap: 6px; margin-top: 8px; }
.mail-add input { min-width: 0; padding: 6px 8px; font-size: 14px; }
.box select, .box input[name="diet_note"] { width: 100%; margin-bottom: 6px; }
.licences.compact { grid-template-columns: 1fr; gap: 4px; }
.box .grid-sizes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.box .field input { width: 100%; }
[data-person] .sheet-panel > .box { margin-bottom: 14px; }

/* ---------- Rückmeldung ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(23, 35, 46, .25);
  z-index: 10;
}
.toast[data-kind="error"] { background: var(--red); }

/* ---------- Mittlere Breite: Bereiche in eigene Zeile ---------- */

@media (max-width: 1440px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 0; padding-bottom: 0; }
  .user { margin-left: auto; }
  .tabs { order: 3; width: 100%; }
}

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px 0; }
  .user { margin-left: auto; }
  .user-roles { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tab { flex: none; }

  .view { padding: 20px 14px 48px; }
  .view-head h2 { font-size: 28px; }

  .col-function, .col-nr { display: none; }

  .view-tools { width: 100%; }
  .view-tools input[type="search"] { flex: 1; }
  .grid2 { grid-template-columns: 1fr; }
  .grid-sizes { grid-template-columns: repeat(3, 1fr); }
  .licences { grid-template-columns: 1fr; }
  .sheet-grid, .issue-grid { grid-template-columns: 1fr; }
  .grid-as { grid-template-columns: 1fr 1fr; }
  .brand-grid { grid-template-columns: 1fr; }
  .as-summary .check { margin-left: 0; }
  .sheet-fields .row { grid-template-columns: 1fr; gap: 2px; }
  .sheet-foot { flex-wrap: wrap; }
  .sheet-foot .btn { flex: 1; }
  .home-grid { grid-template-columns: 1fr; }
  .next-list li { grid-template-columns: 52px 1fr; }
  .next-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .facts div { grid-template-columns: 110px 1fr; }
  .tab { font-size: 16px; padding-left: 8px; padding-right: 8px; }
  .matrix .sticky { min-width: 170px; }
  .row-actions .btn { margin: 2px 0 2px 4px; }
  .filters .btn { margin-left: 0; width: 100%; }
  .filters select { flex: 1 1 45%; }
  .documents li { flex-direction: column; align-items: stretch; }
  .doc-actions { justify-content: flex-end; }
  .confidential .dlg-section { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .dlg-head, .dlg-body, .dlg-foot { padding-left: 16px; padding-right: 16px; }

  .exercise > summary { grid-template-columns: 56px 1fr; gap: 14px; }
  .ex-meta { grid-column: 1 / -1; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; align-items: center; }
}
