:root {
  /* Markenfarben Volksschule Kundl */
  --vsk-yellow: #F5E400;
  --vsk-green: #A9CD39;
  --vsk-blue: #4FADDE;
  --vsk-navy: #16233F;
  --vsk-gray: #8C8C8C;

  --color-bg: #F4F6F9;
  --color-card: #ffffff;
  --color-border: #E3E7ED;
  --color-text: #1F2430;
  --color-muted: #6B7280;
  --color-primary: var(--vsk-blue);
  --color-primary-dark: #2E8FC0;
  --color-positive: #2F8A3E;
  --color-negative: #C6362E;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 35, 63, 0.04), 0 4px 16px rgba(22, 35, 63, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.55;
}

.brand-stripe {
  height: 5px;
  background: linear-gradient(90deg, var(--vsk-yellow) 0 33.3%, var(--vsk-green) 33.3% 66.6%, var(--vsk-blue) 66.6% 100%);
}

.topbar {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px 28px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; text-decoration: none; }
.vsk-logo { height: 40px; width: auto; display: block; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--color-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { color: var(--vsk-navy); background: #F0F3F8; }
.nav a.active { color: var(--vsk-navy); background: #E9F4FB; font-weight: 600; }

/* Modul-Dropdown im Nav (natives <details>/<summary>, kein JS nötig) -
   hält die Kopfzeile aufgeräumt, auch wenn ein Modul mehrere Unterseiten hat. */
.nav-dropdown { position: relative; }
.nav-dropdown summary {
  list-style: none;
  cursor: pointer;
  color: var(--color-muted);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary::after { content: '▾'; font-size: 0.7em; opacity: 0.7; }
.nav-dropdown summary:hover,
.nav-dropdown[open] summary { color: var(--vsk-navy); background: #F0F3F8; }
.nav-dropdown.active summary { color: var(--vsk-navy); background: #E9F4FB; font-weight: 600; }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.nav-dropdown-menu a { padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
/* Klick außerhalb schließt das <details> nicht automatisch im Browser -
   ein Overlay ist hier nicht nötig, da ein zweiter Klick auf die Summary
   oder ein Klick auf einen Menüpunkt (Seitenwechsel) es ohnehin schließt. */

@media (max-width: 700px) {
  .nav-dropdown-menu { position: static; box-shadow: none; border: none; padding: 2px 0 2px 14px; }
}

.user-info { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--color-text); line-height: 1.2; }
.user-chip small { color: var(--color-muted); font-weight: 400; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--vsk-navy); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}

.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

h1 {
  font-family: 'Poppins', 'Inter', sans-serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--vsk-navy);
  margin: 0 0 18px;
}
h2 {
  font-family: 'Poppins', 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--vsk-navy);
  margin: 0 0 14px;
}

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card.narrow { max-width: 480px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-header h1, .card-header h2 { margin: 0; }
.card-header .actions { display: flex; gap: 10px; flex-wrap: wrap; }

label { display: block; font-weight: 600; margin: 14px 0 5px; font-size: 0.88rem; color: var(--color-text); }
label:first-child { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--vsk-blue);
  box-shadow: 0 0 0 3px rgba(79, 173, 222, 0.18);
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  resize: vertical;
  min-height: 70px;
}
textarea:focus {
  outline: none;
  border-color: var(--vsk-blue);
  box-shadow: 0 0 0 3px rgba(79, 173, 222, 0.18);
}

.radio-row { display: flex; gap: 20px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 16px;
  background: #F8FAFC;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; font-size: 0.92rem; }

.btn-primary {
  margin-top: 20px;
  background: var(--vsk-blue);
  color: #fff;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.96rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #B9C2CE; cursor: not-allowed; }

.btn-secondary {
  margin-top: 20px;
  background: #fff;
  color: var(--vsk-navy);
  border: 1px solid var(--color-border);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.96rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #F0F3F8; }

.btn-small { margin-top: 0; padding: 8px 16px; font-size: 0.88rem; text-decoration: none; display: inline-block; }

.link-button {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  font-family: inherit;
  text-decoration: underline;
}
.link-button:hover { color: var(--vsk-navy); }

.inline-form { display: inline; }
.table td .inline-form:not(:last-child) { margin-right: 12px; }
.inline-form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form-row input { width: auto; flex: 1; min-width: 160px; }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.92rem; line-height: 1.5; }
.alert-error { background: #FDF0EF; color: var(--color-negative); border: 1px solid #F5CFC9; }
.alert-success { background: #F1F8E8; color: #4B7A1E; border: 1px solid #D6E9B7; }
.alert-info { background: #EAF5FB; color: #2A6788; border: 1px solid #CDE7F3; }

.hint { color: var(--color-muted); font-size: 0.86rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
.table th { color: var(--color-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table tbody tr:hover { background: #FAFBFD; }

.positive { color: var(--color-positive); }
.negative { color: var(--color-negative); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.badge.einnahme { background: #EEF6E1; color: #4B7A1E; }
.badge.ausgabe { background: #FDF0EF; color: var(--color-negative); }
.badge.scope { background: #EAF5FB; color: #2A6788; }
.badge.prio-hoch { background: #FDF0EF; color: var(--color-negative); }
.badge.prio-mittel { background: #EAF5FB; color: #2A6788; }
.badge.prio-niedrig { background: #F0F3F8; color: var(--color-muted); }

/* Diagramme in den Noten-Auswertungen */
.chart-row { display: flex; gap: 18px; flex-wrap: wrap; }
.chart-box { flex: 1; min-width: 260px; }
.chart-box h3 { font-family: 'Poppins', sans-serif; font-size: 0.95rem; font-weight: 600; color: var(--vsk-navy); margin: 0 0 10px; }

/* Notenvorschau bei Elterngesprächen, QR-Code-Anzeige */
.preview-box {
  border: 1.5px dashed var(--vsk-blue);
  background: #F5FAFD;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}
.qr-image { display: block; margin: 14px auto; border-radius: var(--radius-sm); border: 1px solid var(--color-border); }

.stat-row { display: flex; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  min-width: 190px;
  flex: 1;
}
.stat-label { display: block; color: var(--color-muted); font-size: 0.82rem; margin-bottom: 8px; font-weight: 500; }
.stat-value { font-family: 'Poppins', sans-serif; font-size: 1.8rem; font-weight: 600; }

code {
  background: #EEF1F5;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Start-Kacheln (Modul-Auswahl) */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.tile {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.tile:hover {
  transform: translateY(-2px);
  border-color: var(--vsk-blue);
  box-shadow: 0 4px 20px rgba(22, 35, 63, 0.1);
}
.tile-icon { font-size: 1.8rem; line-height: 1; }
.tile-label { font-family: 'Poppins', sans-serif; font-size: 1.1rem; font-weight: 600; color: var(--vsk-navy); }
.tile-description { color: var(--color-muted); font-size: 0.88rem; line-height: 1.4; }

/* Login-Seite */
.login-page {
  min-height: 66vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(169, 205, 57, 0.16), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(79, 173, 222, 0.16), transparent 40%),
    var(--color-bg);
  border-radius: var(--radius);
  padding: 24px;
  margin: -8px;
}
.login-card {
  background: var(--color-card);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(22, 35, 63, 0.12);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.login-card .vsk-logo { height: 56px; width: auto; display: block; margin: 0 auto 28px; }
.login-card h1 { text-align: center; }

/* KI-Scan-Box */
.scan-box {
  border: 1.5px dashed var(--vsk-blue);
  background: #F5FAFD;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
}
.scan-box .scan-status { font-size: 0.86rem; color: var(--color-muted); margin-top: 8px; }

/* Beleg-Vorschau */
.receipt-preview { max-width: 160px; border-radius: var(--radius-sm); border: 1px solid var(--color-border); margin-top: 10px; display: none; }

/* Umhüllt Tabellen: auf breiten Bildschirmen normales Scroll-Verhalten bei
   Bedarf, auf schmalen wird die Tabelle unten per Media Query zu Karten. */
.table-scroll { overflow-x: auto; }

/* Erst ab echter Telefon-Breite auf gestapelte Kopfzeile wechseln - ein
   normal breites Desktop-Fenster (auch mit Windows-Anzeigeskalierung) soll
   die Nav-Punkte immer in einer Zeile nebeneinander zeigen. */
@media (max-width: 560px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; }
  .user-info { width: 100%; justify-content: space-between; }
  .card-header .actions { width: 100%; }
  .card-header .actions .btn-secondary,
  .card-header .actions .btn-primary { flex: 1; text-align: center; }
}

/* Tabellen -> Kartenliste auf schmalen Bildschirmen (Handy). Jede Zeile wird
   zu einer eigenen Karte, jede Zelle zeigt ihre Spaltenüberschrift als Label
   (aus dem data-label-Attribut) statt einer klassischen Kopfzeile. */
@media (max-width: 640px) {
  .table-scroll { overflow-x: visible; }

  .table thead { display: none; }

  .table, .table tbody, .table tr, .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 14px;
    margin-bottom: 12px;
  }

  /* Label über dem Wert (statt nebeneinander) — dadurch kann nie etwas
     zwischen Label und Wert umbrechen, egal wie lang Label oder Wert sind. */
  .table td {
    padding: 9px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.92rem;
    text-align: left;
  }

  .table td:last-child { border-bottom: none; }

  .table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-muted);
    margin-bottom: 4px;
  }

  .table td .inline-form:not(:last-child) { margin-right: 16px; }
}
