:root {
  --red: #B3161C;
  --red-dark: #8C1116;
  --stone-900: #1c1917;
  --stone-700: #44403c;
  --stone-500: #78716c;
  --stone-400: #a8a29e;
  --stone-300: #d6d3d1;
  --stone-200: #e7e5e4;
  --stone-100: #f5f5f4;
  --stone-50: #fafaf9;
  --stone-800: #292524;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-card: 0 1px 2px rgba(28,25,23,0.06), 0 4px 16px rgba(28,25,23,0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--stone-100);
  color: var(--stone-900);
  padding-bottom: 4rem;
}

/* ---------- Toolbar ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--stone-900);
  color: var(--stone-100);
  padding: 0.6rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar-spacer { flex: 1 1 auto; }

.btn {
  font-size: 0.78rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn-dark { background: #38332f; color: #fff; }
.btn-dark:hover { background: #4a4440; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-clear { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-clear:hover { background: #fdf2f2; }

.btn-nav {
  background: transparent;
  color: var(--stone-300);
  font-weight: 600;
  border: 1px solid transparent;
}
.btn-nav:hover { color: #fff; background: rgba(255,255,255,0.08); }
.btn-nav-active { color: #fff; background: rgba(255,255,255,0.14); }

.save-hint {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  text-align: center;
}

/* ---------- Panels (Konfiguration) ---------- */

.panel {
  background: #fff;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--stone-200);
}

.panel-inner {
  max-width: 48rem;
  margin: 0 auto;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--stone-50);
  border: 1px solid var(--stone-200);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  margin-bottom: 1.5rem;
}

.panel-actions-hint {
  font-size: 0.72rem;
  color: var(--stone-500);
  line-height: 1.4;
}

.panel-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--stone-500);
  margin-bottom: 0.75rem;
}

.panel-section-title-spaced { margin-top: 2rem; }

.grid-config {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .grid-config { grid-template-columns: repeat(3, 1fr); }
}

.span-all { grid-column: 1 / -1; }

.field-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--stone-500);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--stone-900);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(179, 22, 28, 0.15);
}

.divider {
  height: 1px;
  background: var(--stone-200);
  margin: 0.4rem 0;
}

/* ---------- Standardübungen-Editor ---------- */

.weekday-block { margin-bottom: 1.1rem; }

.weekday-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--stone-700);
  margin-bottom: 0.5rem;
}

.exercise-row {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  margin-bottom: 0.35rem;
}

.exercise-row .input.thema { flex: 2 0 0; }
.exercise-row .input.ausbilder { flex: 1 0 0; }

.sort-btns {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--stone-400);
  line-height: 0.7;
  font-size: 0.6rem;
  padding: 0.1rem 0.2rem;
}
.sort-btn:hover:not(:disabled) { color: var(--stone-900); }
.sort-btn:disabled { color: var(--stone-200); cursor: default; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--stone-400);
  padding: 0.3rem;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--red); }

.add-row-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--stone-500);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0;
}
.add-row-btn:hover { color: var(--stone-900); }

/* ---------- Bildschirmansicht: Ausbildungsplan ---------- */

.screen-sheet {
  max-width: 48rem;
  margin: 1.5rem auto 0 auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.masthead {
  position: relative;
  color: #fff;
  padding: 1.3rem 1.5rem;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  text-align: center;
}

.masthead-text { margin: 0 3.6rem; }

.masthead-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  opacity: 0.85;
  font-weight: 600;
}

.masthead-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.masthead-logo {
  position: absolute;
  top: 50%;
  right: 1.3rem;
  transform: translateY(-50%);
  width: 2.9rem;
  height: 2.9rem;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 0.3rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.duty-list { }

.duty-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--stone-900);
}

.duty-row {
  display: flex;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--stone-200);
  break-inside: avoid;
}
.duty-row:last-child { border-bottom: none; }

.duty-stamp {
  flex-shrink: 0;
  width: 3.4rem;
  height: 3.4rem;
  border: 2px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.duty-stamp-num {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.duty-stamp-wd {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.15rem;
}

.duty-content { flex: 1; min-width: 0; }

.duty-date-line {
  font-size: 0.72rem;
  color: var(--stone-900);
  margin-bottom: 0.25rem;
}

.duty-empty-note {
  font-size: 0.85rem;
  color: var(--stone-900);
  font-style: italic;
}

.duty-exercise-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.duty-exercise-list li {
  font-size: 0.85rem;
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

.duty-exercise-list .ausbilder { color: var(--stone-900); }

.manual-entry-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.25rem;
}
.manual-entry-row .input { font-size: 0.78rem; padding: 0.3rem 0.4rem; }
.manual-entry-row .input.thema { flex: 2 0 0; }
.manual-entry-row .input.ausbilder { flex: 1 0 0; }

.add-manual-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--stone-400);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
  padding: 0;
}
.add-manual-btn:hover { color: var(--stone-900); }

/* ---------- Unterschriftenblock: Platz zum Unterschreiben + immer zentriert ---------- */

.signature-block {
  padding: 2rem 1.5rem 1.75rem 1.5rem;
  break-inside: avoid;
}

.signature-row {
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
}

.signature-item {
  text-align: center;
  min-width: 9rem;
}

.signature-space {
  height: 2.6rem;
  border-bottom: 1px solid var(--stone-400);
}

.signature-name {
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 0.4rem;
}

.signature-role {
  font-size: 0.72rem;
  color: var(--stone-900);
  margin-top: 0.15rem;
}

/* ======================================================================
   Druckansicht – echter Tabellen-Look (wie in der Excel-Vorlage),
   immer auf eine A4-Seite skaliert.

   #print-scale-wrap liegt bewusst außerhalb des sichtbaren Bereichs
   (position:absolute + weit nach links verschoben) statt display:none,
   damit JavaScript seine Höhe vor dem Drucken messen und die Schrift-
   größe passend herunterskalieren kann. Alle Maße darin sind in "em"
   angegeben, damit eine Änderung der font-size auf dem Wrapper alles
   proportional mitskaliert.
   ==================================================================== */

@page {
  size: A4;
  margin: 12mm;
}

#print-scale-wrap {
  position: absolute;
  left: -99999px;
  top: 0;
  font-size: 13px;
  color: var(--stone-900);
}

.pt-masthead {
  position: relative;
  color: #fff;
  padding: 1em 1.1em;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  text-align: center;
}

.pt-masthead-text { margin: 0 3.8em; }

.pt-eyebrow {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.85;
  font-weight: 600;
}

.pt-title {
  font-size: 1.15em;
  font-weight: 700;
  margin-top: 0.2em;
}

.pt-logo {
  position: absolute;
  top: 50%;
  right: 1em;
  transform: translateY(-50%);
  width: 3em;
  height: 3em;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 0.25em;
  box-shadow: 0 0.07em 0.3em rgba(0,0,0,0.3);
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1em;
}

.print-table th {
  background: var(--red);
  color: #fff;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 0.5em 0.7em;
  border: 1px solid var(--red-dark);
}

.print-table th:nth-child(1),
.print-table th:nth-child(2) {
  text-align: center;
}

.print-table td {
  padding: 0.4em 0.7em;
  border: 1px solid var(--stone-300);
  font-size: 0.85em;
  vertical-align: top;
}

.print-table td.pt-date, .print-table td.pt-wd {
  white-space: nowrap;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
}
.print-table td.pt-wd { color: var(--stone-900); font-weight: 400; }
.pt-ausbilder { color: var(--stone-900); white-space: nowrap; }
.pt-empty { color: var(--stone-900); font-style: italic; }

.pt-divider td {
  padding: 0;
  height: 0.22em;
  background: #1c1917;
  border: none;
}

.pt-signature-block { padding: 1.9em 1.1em 1.1em 1.1em; }

.pt-signature-row {
  display: flex;
  justify-content: center;
  gap: 2.4em;
  flex-wrap: wrap;
}

.pt-signature-item { text-align: center; min-width: 8em; }

.pt-signature-space {
  height: 2.4em;
  border-bottom: 1px solid var(--stone-400);
}

.pt-signature-name {
  font-size: 0.95em;
  font-weight: 700;
  margin-top: 0.35em;
}

.pt-signature-role {
  font-size: 0.72em;
  color: var(--stone-900);
  margin-top: 0.15em;
}

.site-footer {
  max-width: 48rem;
  margin: 1.5rem auto 0 auto;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--stone-400);
}
.site-footer a { color: var(--stone-500); text-decoration: none; }
.site-footer a:hover { color: var(--stone-900); text-decoration: underline; }

@media print {
  .no-print { display: none !important; }
  .screen-sheet { display: none !important; }
  .panel { display: none !important; }
  body { background: #fff; padding-bottom: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  #print-scale-wrap {
    position: static;
    left: auto;
  }
}
