/* ============================================
   NotenApp – Stylesheet
   Design: Minimalweiß
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-primary: #1d4ed8;
  --color-primary-light: #2563eb;
  --color-accent: #1d4ed8;
  --color-accent-dark: #1d4ed8;
  --color-bg: #f7f8fa;
  --color-warn: #dc2626;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-card-bg: #ffffff;
  --color-border: #e3e6eb;

  --font-display: 'DM Serif Display', serif;
  --font-body: 'Inter', sans-serif;

  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow-soft: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-hover: 0 4px 16px rgba(29,78,216,0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  color: var(--color-primary);
}

a { color: inherit; text-decoration: none; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
}

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

/* ---------- Login-Seite ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 24px;
}

.login-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  max-width: 380px;
  width: 100%;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.login-card .emoji-badge {
  display: none;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

.login-card p.subtitle {
  color: var(--color-text-muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 15px;
  font-family: var(--font-body);
  margin-bottom: 14px;
  transition: border-color 0.2s;
  background: var(--color-bg);
}

.login-card input[type="password"]:focus {
  border-color: var(--color-primary);
  outline: none;
}

.btn-primary {
  width: 100%;
  background: var(--color-primary);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--color-primary-light); }
.btn-primary:active { transform: scale(0.99); }

.error-message {
  background: #FBEAE3;
  color: var(--color-warn);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------- App-Shell (Dashboard, Settings) ---------- */

.app-shell { min-height: 100vh; }

.app-header {
  background: var(--color-card-bg);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 0 32px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--color-text);
}

.app-header .brand b {
  color: var(--color-primary);
  font-weight: 400;
}

.app-header .brand .dot { display: none; }

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.app-header nav { display: flex; gap: 4px; align-items: center; }

.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--color-bg); color: var(--color-text); }
.nav-link.active { color: var(--color-primary); background: #eff6ff; border-color: var(--color-primary); }

.btn-logout {
  background: transparent;
  color: var(--color-text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.btn-logout svg { display: block; }
.btn-logout:hover { color: var(--color-text); background: var(--color-bg); }

.app-main { padding: 36px 32px; max-width: 1100px; margin: 0 auto; }

.page-title { margin-bottom: 6px; color: var(--color-text); }
.page-subtitle { color: var(--color-text-muted); margin: 0 0 28px; font-size: 14px; }

/* ---------- Schuljahr-Auswahl ---------- */

.schuljahr-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 10px;
  background: var(--color-bg);
}

/* ---------- Klassen-Kacheln ---------- */

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.class-tile {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: box-shadow 0.15s, border-color 0.15s;
  border: 1px solid var(--color-border);
}

.class-tile:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--color-accent);
}

.class-tile .tile-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #eff6ff;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

.class-tile h3 {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-text);
  font-size: 18px;
  margin-bottom: 4px;
}
.class-tile .tile-meta { font-size: 13px; color: var(--color-text-muted); }

.class-tile .tile-status {
  width: 100%;
  margin-top: 2px;
}
.class-tile .tile-status p {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 3px 0;
  line-height: 1.4;
}

.tile-add {
  background: transparent;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px;
  color: var(--color-text-muted);
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
  min-height: 120px;
}
.tile-add:hover { border-color: var(--color-primary); color: var(--color-primary); }
.tile-add .plus { font-size: 22px; line-height: 1; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.empty-state .emoji { font-size: 48px; display: block; margin-bottom: 12px; }

/* ---------- Settings-Bereich ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 24px;
}

/* Aufklappbare Schüler-Gesamtübersicht (volle Breite, außerhalb des Grids) */
.schueler-uebersicht-card {
  padding: 0;
  margin-top: 0;
}

.schueler-uebersicht-kopf {
  width: 100%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-primary);
  border-radius: var(--radius-lg);
}

.schueler-kachel-anzahl {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.schueler-uebersicht-body {
  padding: 0 24px 24px;
}

/* Schüler-Tabelle */
.schueler-tabelle-wrap {
  overflow-x: auto;
}

.schueler-tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.sz-th {
  text-align: left;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
.sz-th-nr, .sz-td-nr {
  width: 32px;
  text-align: center;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
.sz-th:nth-child(2), .sz-th:nth-child(3) { width: 25%; }
.sz-th:nth-child(4) { width: 20%; }
.sz-th:nth-child(5) { width: 20%; }
.sz-th-actions { width: 10%; text-align: right; }

.sz-td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sz-td-actions {
  text-align: right;
  white-space: nowrap;
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.schueler-zeile:hover td { background: var(--color-bg); }
.schueler-zeile:last-child td { border-bottom: none; }

/* Sortier-Pfeile */
.sort-pfeil {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  cursor: pointer;
  vertical-align: middle;
  opacity: 0.7;
}
.sort-pfeil:hover { opacity: 1; }
.sort-pfeil.sort-aktiv { opacity: 1; }

/* Bearbeitungs-Zeile */
.sz-input {
  width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--color-accent-dark);
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--color-card-bg);
  color: var(--color-text);
  box-sizing: border-box;
}
.sz-input:focus { outline: none; border-color: var(--color-primary); }
.schueler-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.schueler-add-datum-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 800px) {
  .schueler-add-grid {
    grid-template-columns: 1fr 1fr;
  }
  .schueler-add-grid button[type="submit"] {
    grid-column: 1 / -1;
  }
}
.schueler-edit-label {
  flex: 0 0 100px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.schueler-edit-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
}
.schueler-edit-input:focus {
  border-color: var(--color-accent-dark);
  outline: none;
}

/* Veraltete Spalten-Grid-Styles (von vorheriger Version, können bleiben für Rückwärts-Kompatibilität) */
.schueler-spalten-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.schueler-spalte { display: flex; flex-direction: column; gap: 10px; }
.schueler-spalte-titel { font-family: var(--font-display); font-size: 16px; color: var(--color-primary); margin: 0; padding-bottom: 8px; border-bottom: 2px solid var(--color-accent); }
.schueler-add-form { margin: 0; }
.schueler-spalte-liste { display: flex; flex-direction: column; gap: 4px; }
.schueler-leer-hinweis { font-size: 12px; color: var(--color-text-muted); margin: 0; font-style: italic; }

.settings-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--color-border);
}

.settings-card h2 {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 4px;
  border-radius: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-size: 14px;
}
.list-item:last-child { border-bottom: none; }

.item-actions {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
  align-items: center;
}

.icon-btn {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--color-bg); color: var(--color-primary); }
.icon-btn.icon-delete:hover { background: #fef2f2; color: var(--color-warn); }

.list-item { gap: 8px; }

.list-item-klasse {
  position: relative;
}
.item-notensystem {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.list-item span.item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item.editing input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-primary);
  font-family: var(--font-body);
  font-size: 14px;
}

.list-item[data-type="klasse"].editing .item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible;
}
.list-item[data-type="klasse"].editing .custom-select { flex: 1 1 auto; min-width: 0; }
.list-item[data-type="klasse"].editing .custom-select-button {
  background: var(--color-bg);
  padding: 5px 8px;
  font-size: 13px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  width: 100%;
}

.inline-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--color-bg);
}
.inline-form input:focus {
  border-color: var(--color-primary);
  outline: none;
}

.inline-form .custom-select {
  flex: 1 1 auto;
  min-width: 0;
}
.inline-form .custom-select-button {
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 400;
  border-radius: var(--radius-md);
  border-width: 1px;
}

.inline-form .custom-select.select-grow {
  flex: 2 1 auto;
}

.btn-add {
  flex: 0 0 auto;
  background: var(--color-primary);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-add:hover { background: var(--color-primary-light); }

.badge {
  display: inline-block;
  background: #eff6ff;
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-accent);
}

.badge-muted {
  background: var(--color-bg);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* ---------- Notenverwaltung ---------- */

.app-main-wide { max-width: 1300px; }

.page-title .badge-muted {
  font-size: 13px;
  vertical-align: middle;
  margin-left: 8px;
}

.fach-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.fach-tab {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.fach-tab:hover { border-color: var(--color-primary); color: var(--color-text); }
.fach-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.kategorie-block {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
  background: var(--color-card-bg);
}

.kategorie-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 10px;
}

.kategorie-row .kategorie-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kategorie-row .kategorie-wichtung {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.kategorie-row input {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--color-accent-dark);
  font-family: var(--font-body);
  font-size: 14px;
}
.kategorie-row input.edit-name { flex: 1 1 auto; min-width: 0; }
.kategorie-row input.edit-wichtung { width: 70px; flex-shrink: 0; }

.lm-sublist {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.lm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
}
.lm-row:hover { background: var(--color-bg); }
.lm-row .lm-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lm-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--color-accent-dark);
  font-family: var(--font-body);
  font-size: 13px;
}

.add-lm-form {
  display: flex;
  gap: 8px;
  margin: 0 0 8px;
}
.add-lm-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 13px;
}
.add-lm-form input:focus { border-color: var(--color-accent-dark); outline: none; }
.add-lm-form button {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.add-lm-form button:hover { background: var(--color-primary-light); }

.notentabelle-card { overflow: visible; }

.notentabelle-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.notentabelle-head h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.notentabelle-head-actions {
  display: flex;
  gap: 8px;
}

.notentabelle-suche-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  margin-bottom: 14px;
  color: var(--color-text-muted);
}
.notentabelle-suche-wrap:focus-within {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.notentabelle-suche-wrap input {
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--color-text);
  flex: 1;
}
#notentabelle-suche-clear {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 4px;
  flex-shrink: 0;
}
#notentabelle-suche-clear:hover {
  color: var(--color-text);
  background: var(--color-border);
}
.notentabelle tbody tr.schueler-verborgen,
.noten-karten .schueler-karte.schueler-verborgen {
  display: none;
}

.notentabelle-head-actions .icon-btn,
.icon-settings {
  width: 32px;
  height: 32px;
  font-size: 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notentabelle-head-actions .icon-btn:hover,
.icon-settings:hover { background: #eff6ff; }

.notentabelle-scroll { overflow-x: hidden; }

.noten-karten { display: none; }

.notentabelle {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  font-size: 13px;
}

.notentabelle th, .notentabelle td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notentabelle th.kategorie-header {
  background: var(--color-bg);
  color: var(--color-primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid var(--color-accent-dark);
}

.notentabelle thead tr:first-child th {
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-primary);
}

.notentabelle th.kategorie-header {
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.notentabelle th.lm-header,
.notentabelle th.schueler-header,
.notentabelle th.durchschnitt-header,
.notentabelle th.endnote-header {
  font-family: var(--font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-size: 11px;
}

.notentabelle th.lm-header {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  border-bottom: 1px solid var(--color-border);
}

/* Dünne vertikale Trennlinie zwischen unterschiedlichen Kategorien
   (z. B. zwischen Klassenarbeiten und sonstigen Noten) */
.notentabelle .kategorie-grenze {
  border-left: 1px solid var(--color-border);
}

.notentabelle th.haken-header,
.notentabelle td.haken-cell {
  width: 34px;
  padding: 8px 10px 8px 4px;
}

.notentabelle tfoot td {
  border-top: 2px solid var(--color-border);
  background: var(--color-bg) !important;
}

.notentabelle th.schueler-header {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  border-right: 1px solid var(--color-border);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}
.notentabelle td.schueler-cell {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--color-card-bg);
  z-index: 2;
  font-weight: 600;
  border-right: 1px solid var(--color-border);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

.notentabelle th.durchschnitt-header,
.notentabelle td.durchschnitt-cell {
  font-weight: 700;
  color: var(--color-text-muted);
  border-left: 2px solid var(--color-primary);
}

.notentabelle th.endnote-header,
.notentabelle td.endnote-cell {
  font-weight: 700;
  color: var(--color-primary);
  border-left: 2px solid var(--color-accent-dark);
}
.notentabelle td.endnote-cell .endnote-input {
  color: var(--color-primary);
}

.notentabelle td.haken-cell {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
}

.karte-endnote-row .endnote-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notentabelle td.endnote-cell,
.karte-endnote-row {
  transition: background 0.25s;
}

.endnote-input:disabled {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
  cursor: default;
}

.note-input:disabled {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  cursor: default;
}

.endnote-bestaetigt {
  background: transparent !important;
}

.endnote-haken {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.endnote-haken:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.endnote-haken.bestaetigt {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.endnote-haken:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

input.endnote-input {
  width: 100%;
  max-width: 48px;
  text-align: center;
  padding: 5px 4px;
  border-radius: 6px;
  border: 1.5px solid var(--color-accent-dark);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  background: #fff;
}
input.endnote-input:focus {
  border-color: var(--color-primary);
  outline: none;
}
input.endnote-input.note-error {
  border-color: var(--color-warn);
  background: #FBEAE3;
}

input.note-input {
  width: 100%;
  max-width: 48px;
  text-align: center;
  padding: 5px 4px;
  border-radius: 6px;
  border: 1.5px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 13px;
}
input.note-input:focus {
  border-color: var(--color-accent-dark);
  outline: none;
}
input.note-input.note-error {
  border-color: var(--color-warn);
  background: #FBEAE3;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-primary);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 600px) {
  .app-header { padding: 16px 20px; }
  .app-main { padding: 28px 18px; }
}

/* ---------- Modal-Dialoge (ersetzt Browser confirm/alert) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 58, 46, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--color-card-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.2s, max-width 0.2s;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-card.modal-card-wide {
  max-width: 560px;
}

.modal-custom-content {
  overflow-y: auto;
  margin-bottom: 18px;
  padding-right: 14px;
  margin-right: -14px;
}

.modal-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #FBEAE3;
  border: 1px solid rgba(217, 119, 87, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text);
}

.modal-checkbox-row input.modal-checkbox-input {
  margin-top: 2px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--color-warn);
  cursor: pointer;
}

.modal-btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.modal-btn-danger:disabled:hover { background: var(--color-warn); }

.modal-overlay.show .modal-card {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 19px;
  margin-bottom: 8px;
}

.modal-message {
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 22px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-btn {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
}

.modal-btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
}
.modal-btn-secondary:hover { background: var(--color-border); }

.modal-btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.modal-btn-primary:hover { background: var(--color-primary-light); }

.modal-btn-danger {
  background: var(--color-warn);
  color: #fff;
}
.modal-btn-danger:hover { background: #C4623F; }

/* ---------- Custom-Dropdown (ersetzt native <select>-Popups) ---------- */

.native-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.custom-select {
  position: relative;
  display: inline-block;
}

.custom-select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  transition: border-color 0.2s;
}
.custom-select-button:hover { border-color: var(--color-accent-dark); }
.custom-select.open .custom-select-button { border-color: var(--color-accent-dark); }

.custom-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  flex-shrink: 0;
  color: var(--color-text-muted);
  display: flex;
  transition: transform 0.2s;
}
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }

.custom-select-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 160px;
  background: var(--color-card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--color-border);
  padding: 6px;
  z-index: 50;
  max-height: 280px;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.custom-select.open .custom-select-list {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.custom-select-option {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
}
.custom-select-option:hover { background: var(--color-bg); }
.custom-select-option.selected {
  background: #eff6ff;
  color: var(--color-primary);
  font-weight: 600;
}

/* Schuljahr-Auswahl im hellen Header */
.schuljahr-pill .custom-select-pill .custom-select-button {
  background: transparent;
  border: none;
  color: var(--color-text);
  border-radius: 0;
  padding: 0;
  font-weight: 500;
  font-size: 12px;
  box-shadow: none;
}
.schuljahr-pill .custom-select-pill .custom-select-button:hover {
  background: transparent;
  color: var(--color-primary);
}
.schuljahr-pill .custom-select-pill.open .custom-select-button { color: var(--color-primary); }
.schuljahr-pill .custom-select-pill .custom-select-arrow { color: var(--color-text-muted); }
.schuljahr-pill .custom-select-pill .custom-select-list {
  min-width: 200px;
}

/* ---------- Mobile Karten-Ansicht der Notenübersicht ---------- */

@media (max-width: 640px) {
  .notentabelle-scroll { display: none; }
  .noten-karten { display: block; }
}

.schueler-karte {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--color-card-bg);
}

.schueler-karte-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--color-bg);
}

.schueler-karte-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schueler-karte-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.schueler-karte-durchschnitt {
  font-weight: 700;
  color: var(--color-primary);
  background: rgba(242, 197, 114, 0.25);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
}

.schueler-karte-chevron {
  color: var(--color-text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
  display: flex;
}

.schueler-karte.open .schueler-karte-chevron {
  transform: rotate(180deg);
}

.schueler-karte-body {
  display: none;
  padding: 6px 14px 14px;
}

.schueler-karte.open .schueler-karte-body {
  display: block;
}

.karte-kategorie-block {
  margin-bottom: 12px;
}

.karte-kategorie-titel {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--color-primary);
  margin: 10px 0 6px;
}

.karte-lm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}
.karte-lm-row:last-child { border-bottom: none; }

.karte-lm-name {
  font-size: 13px;
  color: var(--color-text-muted);
  flex: 1 1 auto;
  min-width: 0;
}

.karte-lm-row input.note-input {
  flex-shrink: 0;
  width: 56px;
  padding: 8px 4px;
  font-size: 15px;
}

.karte-endnote-row input.endnote-input {
  flex-shrink: 0;
  width: 56px;
  padding: 8px 4px;
  font-size: 15px;
}

.karte-endnote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--color-accent-dark);
}

.karte-endnote-label {
  font-weight: 700;
  color: var(--color-primary);
  font-size: 14px;
}

/* ---------- Datepicker ---------- */

.dp-card {
  max-width: 320px;
  padding: 20px;
  user-select: none;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.dp-monat-jahr {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  justify-content: center;
}

.dp-monat-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg);
  cursor: pointer;
}
.dp-monat-select:focus { border-color: var(--color-accent-dark); outline: none; }

.dp-jahr-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg);
  cursor: pointer;
  width: 72px;
  text-align: center;
}
.dp-jahr-select:focus { border-color: var(--color-accent-dark); outline: none; }

.dp-nav {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.dp-nav:hover { background: #eff6ff; }

.dp-wochentage {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.dp-wt {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 4px 0;
}

.dp-gitter {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dp-tag {
  aspect-ratio: 1;
  border-radius: 8px;
  font-size: 13px;
  background: transparent;
  color: var(--color-text);
  transition: background 0.1s;
  display: flex; align-items: center; justify-content: center;
}
.dp-tag.dp-leer { pointer-events: none; }
.dp-tag:not(.dp-leer):hover { background: var(--color-bg); }
.dp-tag.dp-heute {
  font-weight: 700;
  color: var(--color-primary);
}
.dp-tag.dp-gewaehlt {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}
.dp-tag.dp-gewaehlt:hover { background: var(--color-primary-light); }

.dp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.dp-btn-loeschen {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}
.dp-btn-loeschen:hover { background: #FBEAE3; color: var(--color-warn); }

.dp-btn-abbrechen {
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}
.dp-btn-abbrechen:hover { background: var(--color-bg); color: var(--color-text); }

.dp-trigger-btn {
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  transition: color 0.15s;
}
.dp-trigger-btn:hover { color: var(--color-primary); }

/* ---------- Druckansicht der Notenübersicht ---------- */

.druck-bereich {
  display: none;
}

@media print {
  /* Alles ausblenden außer dem eigens befüllten Druckbereich */
  body * {
    visibility: hidden;
  }

  .druck-bereich,
  .druck-bereich * {
    visibility: visible;
  }

  .druck-bereich {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  .druck-titel {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--color-primary);
    margin: 0 0 2px;
  }

  .druck-untertitel {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0 0 14px;
  }

  .druck-tabelle {
    border-collapse: collapse;
    width: 100%;
    table-layout: auto;
  }

  .druck-tabelle th,
  .druck-tabelle td {
    border: 1px solid #999;
    padding: 4px 6px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .druck-tabelle th.schueler-header,
  .druck-tabelle td.schueler-cell {
    text-align: left;
    width: auto;
    white-space: normal;
    word-break: break-word;
  }

  .druck-tabelle thead tr:first-child th {
    background: #f0f0f0 !important;
    border-left: 1px solid #999 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .druck-tabelle th.lm-header {
    font-weight: 400;
    border-bottom: 1px solid #999;
  }

  .druck-tabelle th.durchschnitt-header,
  .druck-tabelle td.durchschnitt-cell,
  .druck-tabelle th.endnote-header,
  .druck-tabelle td.endnote-cell {
    font-weight: 700;
    border-left: 1px solid #999 !important;
  }

  /* Eingabefelder im Druck durch reinen Text ersetzen (siehe noten.js) */
  .druck-tabelle input {
    border: none;
    background: transparent;
    text-align: center;
    width: 100%;
    font: inherit;
  }

  /* Häkchen-Spalte im Druck komplett ausblenden */
  .druck-tabelle th.haken-header,
  .druck-tabelle td.haken-cell {
    display: none !important;
  }
  .endnote-haken {
    display: none !important;
  }

  /* Schülerliste: alle Zellen linksbündig */
  .druck-tabelle .sz-th,
  .druck-tabelle .sz-td {
    text-align: left;
    border: 1px solid #999;
    padding: 4px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

/* ---------- Notenfarben (Toggle) ---------- */
.notentabelle.noten-eingefaerbt input.note-input.note-farbe-1,
.notentabelle.noten-eingefaerbt input.endnote-input.note-farbe-1 { background: #b7e4b7; }
.notentabelle.noten-eingefaerbt input.note-input.note-farbe-2,
.notentabelle.noten-eingefaerbt input.endnote-input.note-farbe-2 { background: #dcefc7; }
.notentabelle.noten-eingefaerbt input.note-input.note-farbe-3,
.notentabelle.noten-eingefaerbt input.endnote-input.note-farbe-3 { background: #fff2ad; }
.notentabelle.noten-eingefaerbt input.note-input.note-farbe-4,
.notentabelle.noten-eingefaerbt input.endnote-input.note-farbe-4 { background: #fde08a; }
.notentabelle.noten-eingefaerbt input.note-input.note-farbe-5,
.notentabelle.noten-eingefaerbt input.endnote-input.note-farbe-5 { background: #ffc98a; }
.notentabelle.noten-eingefaerbt input.note-input.note-farbe-6,
.notentabelle.noten-eingefaerbt input.endnote-input.note-farbe-6 { background: #ffa860; }

.noten-karten.noten-eingefaerbt input.note-input.note-farbe-1,
.noten-karten.noten-eingefaerbt input.endnote-input.note-farbe-1 { background: #b7e4b7; }
.noten-karten.noten-eingefaerbt input.note-input.note-farbe-2,
.noten-karten.noten-eingefaerbt input.endnote-input.note-farbe-2 { background: #dcefc7; }
.noten-karten.noten-eingefaerbt input.note-input.note-farbe-3,
.noten-karten.noten-eingefaerbt input.endnote-input.note-farbe-3 { background: #fff2ad; }
.noten-karten.noten-eingefaerbt input.note-input.note-farbe-4,
.noten-karten.noten-eingefaerbt input.endnote-input.note-farbe-4 { background: #fde08a; }
.noten-karten.noten-eingefaerbt input.note-input.note-farbe-5,
.noten-karten.noten-eingefaerbt input.endnote-input.note-farbe-5 { background: #ffc98a; }
.noten-karten.noten-eingefaerbt input.note-input.note-farbe-6,
.noten-karten.noten-eingefaerbt input.endnote-input.note-farbe-6 { background: #ffa860; }

#toggle-notenfarben.aktiv { color: var(--color-primary); background: #eff6ff; }

/* ---------- Massenimport-Modal ---------- */
.mi-format-btn {
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mi-format-btn.mi-format-aktiv {
  background: var(--color-primary) !important;
  color: #fff !important;
  border: 1.5px solid var(--color-primary) !important;
}
.mi-vorschau-zeile:last-child {
  border-bottom: none !important;
}

/* ---------- Willkommens-Seite ---------- */
.willkommen-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
}
.willkommen-box {
  text-align: center;
}
.willkommen-titel {
  font-family: var(--font-display);
  font-size: 34px;
  color: var(--color-text);
  margin-bottom: 8px;
}
