/* Colours and fonts of notenstatistik.htl.services (HTL green #9cce2b, grey #595b60, Outfit/Inter). */
:root {
  --font-display: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --primary-rgb: 130, 176, 28;
  --bg: #f4f5f7;
  --card: rgba(255, 255, 255, 0.85);
  --text: #1f2937;
  --muted: #6b7280;
  --line: rgba(0, 0, 0, 0.1);
  --primary: #82b01c;
  --secondary: #595b60;
  --accent: #5d7f14; /* links and outlines: darker green, readable on white */
  --accent-soft: rgba(130, 176, 28, 0.1);
  --on-primary: #ffffff;
  --error: #e11d48;
  --zero: rgba(0, 0, 0, 0.25);
  --ok: #10b981;
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --heading: linear-gradient(135deg, #1f2937 30%, #595b60 100%);
  color-scheme: light;
}
/* Theme: follows the system unless the switch in the header sets data-theme="light" or "dark" (static/theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary-rgb: 156, 206, 43;
    --bg: #0a0a0d;
    --card: rgba(29, 30, 34, 0.6);
    --text: #f3f4f6;
    --muted: #9ca3af;
    --line: rgba(255, 255, 255, 0.1);
    --primary: #9cce2b;
    --accent: #9cce2b;
    --accent-soft: rgba(156, 206, 43, 0.1);
    --on-primary: #0a0a0d;
    --error: #f43f5e;
    --zero: rgba(255, 255, 255, 0.22);
    --warn: #f59e0b;
    --warn-soft: rgba(245, 158, 11, 0.1);
    --shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    --heading: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary-rgb: 156, 206, 43;
  --bg: #0a0a0d;
  --card: rgba(29, 30, 34, 0.6);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.1);
  --primary: #9cce2b;
  --accent: #9cce2b;
  --accent-soft: rgba(156, 206, 43, 0.1);
  --on-primary: #0a0a0d;
  --error: #f43f5e;
  --zero: rgba(255, 255, 255, 0.22);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.1);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  --heading: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  /* the soft glows of notenstatistik, fixed behind the content */
  background:
    radial-gradient(45vw 45vw at 20% 15%, rgba(var(--primary-rgb), 0.08), transparent 70%) fixed,
    radial-gradient(40vw 40vw at 85% 85%, rgba(89, 91, 96, 0.12), transparent 75%) fixed,
    var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.top { padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
  display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  font-family: var(--font-display); font-size: 18px; font-weight: 600;
}
.logo { height: 26px; width: auto; display: block; }
.logo .green { fill: var(--primary); }
.logo .grey { fill: var(--secondary); }
.theme-switch {
  background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; box-shadow: none;
  padding: 4px 10px; font-weight: 400; font-size: 13px;
}
.theme-switch:hover { color: var(--primary); border-color: var(--primary); transform: none; }
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px; }
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px; }
h1, h2, h3 { font-family: var(--font-display); }
h1 {
  font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 12px;
  background: var(--heading); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
h2 { font-size: 19px; font-weight: 600; margin: 0 0 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow); backdrop-filter: blur(20px);
}
.upload { max-width: 640px; margin: 40px auto; }
.upload-form { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 20px 0; }
.dropzone {
  position: relative; display: block; width: 100%; padding: 36px 24px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 16px; background: transparent;
  transition: border-color .15s, background-color .15s, transform .15s;
}
.dropzone:hover, .dropzone.dragover, .dropzone:focus-within {
  border-color: var(--primary); background: var(--accent-soft); box-shadow: 0 0 25px rgba(var(--primary-rgb), 0.15);
}
.dropzone.dragover { transform: scale(1.01); }
.dropzone-small { padding: 18px 24px; }
.dropzone-small strong { font-size: 16px; }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
/* Visually hidden but focusable, so the browser can still point at it for "required" */
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.drop-empty, .drop-file { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.drop-empty[hidden], .drop-file[hidden] { display: none; }
.dropzone strong { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.dropzone span { color: var(--muted); }
.drop-limit { font-size: 12px; margin-top: 8px; }
.drop-icon {
  width: 52px; height: 52px; margin-bottom: 8px; fill: none; stroke: var(--primary);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s;
}
.dropzone:hover .drop-icon { transform: translateY(-4px); }
.drop-icon.ok { stroke: var(--ok); }
.link-button { background: none; color: var(--error); padding: 2px 6px; font-weight: 400; font-size: 13px; box-shadow: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.upload-form > button[type=submit] { min-width: 220px; padding: 10px 24px; }
button {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); color: var(--on-primary);
  border: 0; border-radius: 10px; padding: 8px 18px; font: inherit; font-family: var(--font-display); font-weight: 600;
  cursor: pointer; box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.25); transition: transform .2s, box-shadow .2s;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.4); }
button:disabled:hover { transform: none; }
.error { color: var(--error); font-weight: 600; }
.privacy, .hint, .meta { color: var(--muted); font-size: 13px; }

.summary { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; color: var(--muted); box-shadow: var(--shadow); }
.stat .num { display: block; font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--primary); }
.meta { flex: 1 1 260px; align-self: center; }
.summary[hidden], .variant[hidden], .class-detail[hidden], tr[hidden] { display: none; }
.file { font-weight: 600; }

.tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.tabs a {
  padding: 8px 16px; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0;
  text-decoration: none; background: var(--bg); color: var(--muted); font-family: var(--font-display); font-weight: 500;
}
.tabs a:hover { color: var(--primary); }
.tabs a.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: inset 0 2px 0 var(--primary); }
.js .tab { border-top-left-radius: 0; }
.js .tab:not(.active) { display: none; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.sortable th { cursor: pointer; user-select: none; }
.sortable th[aria-sort="ascending"]::after { content: " ▲"; }
.sortable th[aria-sort="descending"]::after { content: " ▼"; }
.n { text-align: right; font-variant-numeric: tabular-nums; }
.matrix { width: auto; }
.pivot td:first-child { min-width: 220px; }
.matrix tfoot th { font-size: inherit; }
/* Matrix tables: vertical lines; subject headers at 45°. Each header is a band rotated around the bottom-right
   corner of its column, so its two borders continue the column's vertical lines diagonally.
   --col is the width of a subject column, the band height is --col × sin 45°. */
.matrix { --col: 40px; margin-right: 200px; }
.matrix td, .matrix tfoot th { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.matrix th:not(.diag) { vertical-align: bottom; }
.matrix th.diag {
  position: relative; height: 225px; padding: 0; vertical-align: bottom;
  width: var(--col); min-width: var(--col); max-width: var(--col);
}
.matrix th.diag > span {
  position: absolute; left: 100%; bottom: 0; width: 300px; height: calc(var(--col) * 0.7071);
  transform-origin: bottom left; transform: rotate(-45deg);
  border-bottom: 1px solid var(--line); /* continues the column's right line */
  padding-left: 10px; line-height: calc(var(--col) * 0.7071 - 2px); white-space: nowrap; text-align: left;
  font-size: 12.5px; color: var(--text); font-weight: 500;
}
.matrix td.n { padding-left: 4px; padding-right: 4px; text-align: center; }
.matrix td:not(.n) { text-align: left; }
.matrix td.sum { min-width: 48px; }
.sortable th.diag[aria-sort]::after { content: none; }
.sortable th.diag[aria-sort="ascending"] > span::after { content: " ▲"; }
.sortable th.diag[aria-sort="descending"] > span::after { content: " ▼"; }
.matrix td.zero { color: var(--zero); }
.matrix tbody tr:hover, #students tbody tr:hover { background: var(--accent-soft); }
.export-form { display: flex; gap: 8px; margin: 0; }
.export-form button { padding: 6px 14px; font-size: 13px; }
#print-button { background: none; color: var(--text); border: 1px solid var(--line); box-shadow: none; }
#print-button:hover { border-color: var(--primary); color: var(--primary); }
.warning {
  background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn); border-left-width: 5px;
  border-radius: 12px; padding: 10px 14px; margin: 0 0 14px;
}
.warning strong, .warn-text { color: var(--warn); }
.tabs a.tab-warning { color: var(--warn); }
.tabs a.tab-warning.active { color: var(--warn); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; color: var(--muted); }
.stage-filter { color: var(--text); font-weight: 600; margin-right: auto; }
.stage-filter select { font-weight: 400; }
h3 { font-size: 16px; margin: 4px 0; }
.matrix td.sum, .matrix tfoot td, .matrix tfoot th { font-weight: 700; }
.matrix tfoot th, .matrix tfoot td { border-top: 2px solid var(--line); color: var(--text); }
.pivot td[title] { cursor: help; }
.class-link { font-weight: 600; text-decoration: none; }
.class-link:hover { text-decoration: underline; }
.class-detail + .class-detail { margin-top: 28px; }
.filters { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; }
select {
  font: inherit; padding: 4px 6px; margin-left: 6px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
}
#filter-count { color: var(--muted); }
.hide-none tr.none { display: none; }
.pivot tr.none td:first-child, .pivot tr.none td.sum { color: var(--muted); font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.warning details { margin-top: 6px; }
details summary { cursor: pointer; }
.entries { margin: 6px 0; padding-left: 18px; }
.note { color: var(--muted); white-space: pre-line; }
pre { white-space: pre-wrap; font-size: 12px; }

@media print {
  body { background: #fff; color: #000; font-size: 11px; }
  /* :root:root outweighs the dark theme of the system */
  :root:root, :root[data-theme] { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #bbb; --zero: #999; --primary: #000; }
  h1 { -webkit-text-fill-color: currentColor; background: none; }
  .card, .stat { box-shadow: none; backdrop-filter: none; }
  .top, footer, .tabs, .filters, .toolbar a { display: none; }
  .card, .stat { border: 0; padding: 0; }
  .js .tab:not(.active) { display: block; }
  .tab, .class-detail + .class-detail { break-before: page; }
  .toolbar .export-form, .detail-filters, .stage-filter, .new-file { display: none; }
  .variant > .tab:first-child { break-before: auto; }
  .scroll { overflow: visible; }
}
