/* Kostenrechner – gemeinsames Stylesheet.
   Werte aus docs/SPEC.md Abschnitt 8 und den Mockups in docs/mockup/. */

/* --- Schriften (lokal, siehe public/fonts/) ----------------------------- */

@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/public/fonts/bricolage-grotesque-latin-opsz-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/public/fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/public/fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/public/fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
}

/* --- Farben und Maße ---------------------------------------------------- */

:root {
  --bg: #F3F4F0;
  --surface: #FFFFFF;
  --text: #1B211E;
  --text-muted: #5A635E;
  --text-label: #4F5852;
  --text-nav: #3E4742;
  --line: #DCE0DA;
  --line-soft: #ECEEEA;
  --line-strong: #C9CEC7;

  --accent: #1E6B57;
  --accent-dark: #134638;
  --accent-light: #E3EFEA;
  --planned-light: #A8D0C3;

  --warn-bg: #FBEFD9;
  --warn-text: #6B3D08;
  --planned-bg: #EEF0F7;
  --planned-text: #3B4A7A;
  --danger: #8A2E1F;
  --danger-bg: #F8E4DF;

  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --tap: 44px;

  --font-heading: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
}

/* --- Grundlagen --------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-heading);
  line-height: 1.15;
}
h1 { font-size: 36px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }

p { margin: 0; }

input, select, textarea, button { font: inherit; color: var(--text); }

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

.muted { color: var(--text-muted); }
.small { font-size: 13px; }

/* --- Seitenrahmen ------------------------------------------------------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { color: var(--text); }

.brand__mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.brand__name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 19px;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 500;
  color: var(--text-nav);
}
.main-nav a:hover { background: var(--bg); }
.main-nav a[aria-current="page"] {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
}

.user-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-left: auto;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--text);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.user-menu__who {
  font-size: 14px;
  line-height: 1.3;
}
.user-menu__who strong { display: block; }
.user-menu__who span { color: var(--text-muted); }

.user-menu__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  font-size: 14px;
}
.user-menu__actions a,
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-nav);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.user-menu__actions a:hover,
.link-button:hover { background: var(--bg); color: var(--text); }
.user-menu__actions form { margin: 0; }

.content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.page-head p { margin-top: 6px; }

/* --- Flächen ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}

.empty-state {
  padding: 40px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-state p { max-width: 56ch; }

.auth-card {
  width: 100%;
  max-width: 420px;
  margin: 24px auto 0;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-card h1 { font-size: 30px; }

/* --- Hinweise ----------------------------------------------------------- */

.notice {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
}
.notice--warn { background: var(--warn-bg); color: var(--warn-text); }
.notice--error { background: var(--danger-bg); color: var(--danger); }
.notice--success { background: var(--accent-light); color: var(--accent-dark); }
.notice--info { background: var(--planned-bg); color: var(--planned-text); }

/* --- Formulare ---------------------------------------------------------- */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}
.field small { font-weight: 400; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 15px;
  font-weight: 400;
}
textarea {
  padding: 10px 12px;
  resize: vertical;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--bg); color: var(--text); }

.button--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}
.button--primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #FFFFFF;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button--outline {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.button--outline:hover { background: var(--accent-light); color: var(--accent-dark); }

.button--warn {
  min-height: 40px;
  padding: 0 14px;
  border-color: #C9A46B;
  color: var(--warn-text);
  font-weight: 600;
}
.button--warn:hover { background: #FFF8EC; color: var(--warn-text); }

.button--danger-text {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
  font-weight: 600;
  padding: 0 16px;
}
.button--danger-text:hover { background: var(--danger-bg); color: var(--danger); }

.button--wide { padding: 0 22px; }
.button--block { width: 100%; }
.button-row--center { align-items: center; }
.push-right { margin-left: auto; }
/* Textknopf bündig mit dem Text darüber (gleicht sein Innenabstand aus). */
.pull-left { margin-left: -16px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.soft { color: var(--text-nav); }
.strong { font-weight: 600; }

/* --- Hinweis mit Symbol und Knopf --------------------------------------- */

.notice--row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.notice--row svg { flex: none; }
.notice--row form { margin: 0; }
.notice__text { flex: 1 1 300px; }

/* --- Kennzeichen -------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.pill--warn { background: var(--warn-bg); color: var(--warn-text); }
.pill--planned { background: var(--planned-bg); color: var(--planned-text); }
.pill--muted { background: var(--line-soft); color: var(--text-muted); }

/* --- Werkzeugleiste über Tabellen --------------------------------------- */

.card--flush { padding: 16px 0 8px; }

.toolbar {
  padding: 0 16px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.search {
  flex: 1 1 280px;
  display: flex;
  gap: 8px;
  margin: 0;
}

.search__box {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
}
.search__box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search__box input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-nav);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.chip:hover { background: var(--bg); color: var(--text); }
.chip[aria-current="true"] {
  border-color: var(--text);
  background: var(--text);
  color: #FFFFFF;
}

.table-link { font-weight: 600; text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.table-link + .pill { margin-left: 8px; }

th.num, td.num { text-align: right; }
/* Lange Texte (Gruppe, Projekt) dürfen umbrechen, statt die Tabelle zu dehnen. */
td.wrap { white-space: normal; min-width: 160px; overflow-wrap: anywhere; }
tr.is-archived td { color: var(--text-muted); }

.table-empty { padding: 20px 16px; color: var(--text-muted); }
.table-foot { padding: 12px 16px 4px; font-size: 13px; color: var(--text-muted); }

/* --- Zweispaltige Seiten (Formular + Randspalte) ------------------------ */

.back-link {
  align-self: flex-start;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}
.split__main {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.split__side {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.section--tight { gap: 12px; }
.section h2 { font-size: 18px; }
.section form { margin: 0; }
.small-gap { margin-top: 4px; font-size: 14px; }

.plain-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.field-row--end { align-items: flex-start; }
.field--grow { flex: 1 1 150px; min-width: 0; }
.field--grow-small { flex: 1 1 140px; min-width: 0; }
.field--narrow { max-width: 260px; }
.optional { font-weight: 400; color: var(--text-muted); }

.field-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}
input[aria-invalid="true"],
.input-group[aria-invalid="true"] { border-color: var(--danger); }

/* Eingabefeld mit Einheit dahinter (mm, €, %). */
.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.input-group:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.input-group input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-variant-numeric: tabular-nums;
}
.input-group__unit { color: var(--text-muted); font-weight: 500; }

fieldset:disabled input,
fieldset:disabled select,
fieldset:disabled textarea,
fieldset:disabled .input-group { background: var(--bg); color: var(--text-nav); opacity: 1; }

/* --- Gebindeart wählen -------------------------------------------------- */

.pack-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pack-type {
  position: relative;
  min-height: 56px;
  min-width: 112px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pack-type input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.pack-type__label { font-weight: 600; }
.pack-type__hint { font-size: 12px; opacity: 0.85; }
.pack-type:hover { background: var(--bg); }
.pack-type:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent);
  color: #FFFFFF;
}
.pack-type:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset:disabled .pack-type { cursor: default; }
fieldset:disabled .pack-type:not(:has(input:checked)) { opacity: 0.55; }

/* Nur die Felder zeigen, die zur gewählten Gebindeart gehören. Jedes Feld
   nennt in data-pack die Arten, für die es gilt. */
.material-form:has(input[name="pack_type"][value="stueck"]:checked) [data-pack]:not([data-pack~="stueck"]),
.material-form:has(input[name="pack_type"][value="packung"]:checked) [data-pack]:not([data-pack~="packung"]),
.material-form:has(input[name="pack_type"][value="flaeche"]:checked) [data-pack]:not([data-pack~="flaeche"]),
.material-form:has(input[name="pack_type"][value="laenge"]:checked) [data-pack]:not([data-pack~="laenge"]),
.material-form:has(input[name="pack_type"][value="gewicht"]:checked) [data-pack]:not([data-pack~="gewicht"]),
.material-form:has(input[name="pack_type"][value="volumen"]:checked) [data-pack]:not([data-pack~="volumen"]) {
  display: none;
}

/* --- Ergebnis der Live-Berechnung --------------------------------------- */

.result-box {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 32px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
}
.result-box__label { font-size: 13px; font-weight: 600; color: #1E5B4A; }
.result-box__value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}
.result-box__detail {
  font-size: 14px;
  color: #1E4A3D;
  font-variant-numeric: tabular-nums;
}
.result-box__detail span { display: block; }

/* --- Änderungsprotokoll ------------------------------------------------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 14px;
}
.timeline li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 14px;
  border-left: 2px solid var(--line-strong);
  font-variant-numeric: tabular-nums;
}

/* --- Seiten mit Auswahlliste links (Projekte) --------------------------- */

.with-sidebar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
}
.with-sidebar__main {
  flex: 999 1 640px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-list {
  flex: 1 1 240px;
  min-width: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-list__search { margin: 0 0 6px; }
.field--small { font-size: 13px; }
.side-list__search .field { color: var(--text-label); }
.side-list__search input[type="search"] { min-height: 40px; }

.side-list__item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.side-list__item:hover { background: var(--bg); color: var(--text); }
.side-list__item[aria-current="page"] { background: var(--accent-light); }
.side-list__item[aria-current="page"] .side-list__name { font-weight: 600; }
.side-list__name { min-width: 0; overflow-wrap: anywhere; }
.side-list__cost { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.side-list__item[aria-current="page"] .side-list__cost { color: #1E5B4A; }
.side-list__empty { padding: 6px 12px; }

.side-list__add {
  margin-top: 8px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #9AA39D;
  border-radius: var(--radius);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.side-list__add:hover { background: var(--accent-light); color: var(--accent-dark); }
.side-list__toggle { padding: 8px 12px 0; color: var(--text-muted); }

/* --- Projektkopf mit Kostenbox ------------------------------------------ */

.project-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.project-head__text { flex: 1 1 360px; min-width: 0; }
.project-head__text h1 { overflow-wrap: anywhere; }
.project-head__description {
  margin-top: 8px;
  max-width: 60ch;
  color: var(--text-nav);
  white-space: pre-line;
}
.project-head__actions { margin-top: 14px; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.tag {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--line-soft);
  font-size: 13px;
  font-weight: 500;
}

.cost-box {
  min-width: 200px;
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #FFFFFF;
}
.cost-box__label { font-size: 13px; font-weight: 600; color: #D4E8E1; }
.cost-box__value {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.notice__link { font-weight: 600; color: inherit; }
.notice__link:hover { color: inherit; }

/* --- Karte mit Tabelle und Hinzufügen-Zeile ----------------------------- */

.card--table { padding: 20px 0 0; overflow: hidden; }
.card__head {
  padding: 0 20px 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.card__head h2 { font-size: 18px; }
.card--table .table-empty { padding: 12px 20px 20px; }
.card--table th:first-child, .card--table td:first-child { padding-left: 20px; }

.sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}
.sub--warn { font-weight: 600; color: #8A4F0C; }

tfoot td { border-bottom: 0; }
td.total { font-weight: 700; }

td.actions {
  width: 1%;
  padding-top: 6px;
  padding-bottom: 6px;
}
td.actions form { display: inline-block; margin: 0; }
td.actions .button { min-height: 40px; padding: 0 14px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  vertical-align: middle;
}
.icon-button:hover { background: var(--bg); color: var(--text); }

/* Zeile im Bearbeitungsmodus: Eingabefelder statt Text. */
tr.is-editing td { background: #F7F8F5; }
td.cell-edit {
  min-width: 112px;
  padding-left: 6px;
  padding-right: 6px;
  white-space: normal;
  text-align: right;
}
td.cell-edit .input-group { min-height: 40px; padding: 0 10px; }
td.cell-edit .input-group input[type="text"] { text-align: right; width: 3.5em; }
td.actions { white-space: nowrap; }
td.cell-edit .field-error { display: block; margin-top: 4px; text-align: left; }

.add-row {
  margin: 0;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: #F7F8F5;
}
.add-row--note { color: var(--text-muted); }
.add-row__material { flex: 3 1 240px; min-width: 0; }
.add-row__qty { flex: 1 1 110px; min-width: 0; }
.add-row__hint {
  flex: 0 0 auto;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 14px;
}
/* Meldungen unter den Feldern sollen die Knöpfe nicht verschieben. */
.add-row:has(.field-error) { align-items: flex-start; }
.add-row:has(.field-error) .add-row__hint,
.add-row:has(.field-error) .button { margin-top: 26px; }

.narrow-form {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Kurs-Kalkulation --------------------------------------------------- */

.pill--done { background: var(--accent-light); color: #1E5B4A; }

.notice--top { align-items: flex-start; flex-wrap: nowrap; gap: 12px; }
.notice--top svg { margin-top: 1px; }
.notice--top .notice__text { flex: 1 1 auto; }

.course-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}
.course-layout__form {
  flex: 1 1 380px;
  min-width: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.course-layout__form h2 { font-size: 18px; }
.course-layout__result {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.plain-fieldset--tight { gap: 16px; }
.field--grow-tiny { flex: 1 1 120px; min-width: 0; }

/* Teilnehmende mit Minus- und Plus-Knopf. */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stepper__button {
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 20px;
  cursor: pointer;
}
.stepper__button:hover { background: var(--bg); }
.stepper .stepper__input {
  width: 90px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.course-projects {
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.course-projects h3 { font-size: 15px; font-family: var(--font-body); font-weight: 600; }

.project-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.project-card__cost {
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.project-card__pieces { color: var(--text); }

.text-button {
  align-self: flex-start;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.text-button:hover { text-decoration: underline; }
.text-button--danger { color: var(--danger); }

.add-project summary {
  list-style: none;
  margin-top: 0;
  cursor: pointer;
}
.add-project summary::-webkit-details-marker { display: none; }
.add-project__body {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.cost-summary {
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px 40px;
}
.cost-summary__main { flex: 1 1 220px; }
.cost-summary__label { font-size: 14px; font-weight: 600; color: #D4E8E1; }
.cost-summary__total {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.cost-summary__small { font-size: 13px; color: #D4E8E1; }
.cost-summary__value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.card__head--stack { display: block; }

.course-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
}
.course-foot form { margin: 0; }

/* Titelzeile einer Karte mit Knopf rechts. */
.card-title-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.usage-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.usage-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.usage-list li:last-child { border-bottom: 0; }

.page-head .button-row form { margin: 0; }

/* --- Startseite: Zeitraum, Kennzahlen, Diagramm, Aufteilungen ----------- */

.period {
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}
.period__label { font-size: 13px; font-weight: 600; color: var(--text-label); }
.period__steps { display: flex; gap: 6px; }
.period__range {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-nav);
  font-variant-numeric: tabular-nums;
}
.period__custom {
  flex: 1 1 100%;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.period__custom .field { flex: 0 1 180px; }
.icon-button--outline { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-nav); }

.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.kpi {
  flex: 1 1 220px;
  min-width: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.kpi__label { font-size: 13px; font-weight: 600; color: var(--text-label); }
.kpi__value {
  margin-top: 4px;
  font-family: var(--font-heading);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.kpi__detail { font-size: 13px; color: var(--text-muted); }
.kpi--accent { border-color: var(--accent); background: var(--accent); color: #FFFFFF; }
.kpi--accent .kpi__label,
.kpi--accent .kpi__detail { color: #D4E8E1; }

.card-title-row--baseline { align-items: baseline; gap: 8px 20px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 13px;
  color: var(--text-nav);
}
.legend > span { display: flex; align-items: center; gap: 6px; }
.legend__swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend__swatch--closed { background: var(--accent); }
.legend__swatch--planned { background: var(--planned-light); }

/* Balkendiagramm in reinem HTML/CSS. Die Höhen kommen als Pixel vom Server. */
.chart-scroll { position: relative; overflow-x: auto; margin-top: 2px; }
.chart {
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-bottom: 1px solid var(--line-strong);
}
.chart__column {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.chart__value {
  margin-bottom: 4px;
  font-size: 12px;
  text-align: center;
  color: var(--text-nav);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart__bar { width: 100%; max-width: 72px; }
.chart__bar--planned { background: var(--planned-light); border-radius: 4px 4px 0 0; }
.chart__bar--closed { background: var(--accent); }
.chart__bar--top { border-radius: 4px 4px 0 0; }
.chart__names {
  margin-top: 6px;
  display: flex;
  gap: 8px;
}
.chart__names span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-label);
  white-space: nowrap;
}

.breakdowns {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.breakdowns__card { flex: 1 1 420px; min-width: 0; }
.breakdown__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.breakdown__head strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown__link { color: inherit; text-decoration: none; }
.breakdown__link:hover { text-decoration: underline; }
.meter {
  height: 10px;
  margin-top: 6px;
  border-radius: 5px;
  background: var(--line-soft);
  overflow: hidden;
}
.meter__fill { height: 100%; border-radius: 5px; background: var(--accent); }

.card__head--center { align-items: center; padding-bottom: 12px; }
.table-search { margin: 0; }
.table-search label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-nav);
}
.table-search input[type="search"] { width: 220px; min-height: 40px; }

/* --- Benutzer & Rollen -------------------------------------------------- */

.lead { margin-top: 6px; }

.pill--dark { background: var(--text); color: #FFFFFF; }
.pill--danger { background: var(--danger-bg); color: var(--danger); }

.user-name { display: block; }

.inline-form {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
select.select--small {
  width: auto;
  min-height: 40px;
  padding: 0 10px;
}
.button--small { min-height: 40px; padding: 0 12px; }
/* Ersatz-Knöpfe für den Betrieb ohne Skript (siehe public/js/app.js). */
.js .js-hidden { display: none; }

td.actions--text { text-align: right; }
td.actions--text form { margin-left: 12px; }
td.actions--text .text-button { min-height: 40px; }

/* Frisch erzeugter Link zum Weitergeben. */
.link-box { border-color: var(--accent); }
.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.copy-row input[type="text"] {
  flex: 1 1 320px;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--bg);
}

.role-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.role-card { flex: 1 1 300px; min-width: 0; padding: 20px; }
.role-card h3 { font-size: 17px; }
.role-card p { margin: 4px 0 12px; font-size: 14px; }
.role-card ul {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[readonly] { background: var(--bg); color: var(--text-nav); }

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

/* position: relative hält auch unsichtbare Beschriftungen (.visually-hidden)
   im Scrollbereich – sonst ragen sie aus der Seite und diese scrollt quer. */
.table-scroll { position: relative; overflow-x: auto; }

table {
  border-collapse: collapse;
  width: 100%;
}
th {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-label);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

@media (max-width: 640px) {
  h1 { font-size: 28px; }
  .site-header__inner { padding: 12px 16px; gap: 10px 16px; }
  .content { padding: 24px 16px 40px; }
  .main-nav { order: 3; flex: 1 1 100%; }
  .user-menu { margin-left: 0; flex: 1 1 100%; }
  .user-menu__actions { margin-left: auto; }
  .auth-card { padding: 22px 18px; }
}
