/* aw-v3 — Vorschau-UI (DEMO). Eigenständiges Stylesheet, keine externen Assets. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --ink: #16202e;
  --muted: #55617a;
  --line: #dfe5f0;
  --line-strong: #c8d2e4;
  --accent: #1b57b8;
  --accent-ink: #0f3d86;
  --track: #e7ecf6;
  --mark: #b3261e;
  --ok-fg: #0b5d34;
  --ok-bg: #e3f4ea;
  --ok-line: #b9e2c9;
  --late-fg: #7a4400;
  --late-bg: #fdf0d2;
  --late-line: #efd49a;
  --exc-fg: #1b4a86;
  --exc-bg: #e6eefb;
  --exc-line: #c3d6f3;
  --unexc-fg: #a01a1a;
  --unexc-bg: #fbe7e7;
  --unexc-line: #f0c3c3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .06), 0 8px 24px rgba(22, 32, 46, .05);
  --focus: #0b4bb3;
}

* { box-sizing: border-box; min-width: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .35em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.55rem, 5.4vw, 2.15rem); }
h2 { font-size: clamp(1.15rem, 3.6vw, 1.35rem); }
h3 { font-size: 1.06rem; }

p { margin: 0 0 .8em; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

.muted { color: var(--muted); font-size: .95rem; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Demo-Kennzeichnung (immer sichtbar) ---------- */
.demo-ribbon {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline;
  background: #ffe08a;
  color: #3b2a00;
  border-bottom: 1px solid #e6c25c;
  padding: 8px 16px;
  font-size: .82rem;
  letter-spacing: .02em;
}
.ribbon-strong { font-weight: 800; letter-spacing: .06em; }
.ribbon-soft { opacity: .95; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), #4a86e8);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55);
}
.brand-text { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 8px; }
.brand-sub {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent-ink); background: #e8f0fe; padding: 2px 7px; border-radius: 999px;
}
.topnav { display: flex; gap: 4px; order: 3; width: 100%; }
.navlink {
  padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .95rem;
}
.navlink:hover { background: var(--surface-soft); color: var(--ink); }
.navlink.is-active { color: var(--accent-ink); background: #e8f0fe; }
.userbox {
  margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  font-size: .88rem; text-align: right;
}
.user-name { font-weight: 700; }
.user-meta { color: var(--muted); font-size: .8rem; }
.logout-form { margin: 0; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 20px 16px 56px; }

.page-head { margin-bottom: 18px; }
.page-head .eyebrow {
  display: inline-block; margin: 0 0 6px; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: var(--accent-ink);
}
.page-head .lede { margin: 0; color: var(--muted); }
.updated {
  margin: 10px 0 0; font-size: .84rem; color: var(--muted);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.updated strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.updated-note { color: var(--muted); font-size: .78rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #1a9c57; flex: 0 0 auto; }

/* ---------- Karten ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-title { margin-bottom: 10px; }

.section { margin-top: 26px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; }

/* ---------- Gesamtkarte ---------- */
.total-card { margin-top: 4px; }
.total-grid { display: grid; gap: 16px; }
.big-pct { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 6px; }
.big-num {
  font-size: clamp(3rem, 15vw, 4.2rem); font-weight: 800; line-height: .95;
  letter-spacing: -.04em; color: var(--accent-ink); font-variant-numeric: tabular-nums;
}
.big-unit { font-size: .42em; font-weight: 700; margin-left: 2px; }
.big-label { font-size: .95rem; font-weight: 600; color: var(--muted); }

/* Balken + 70-%-Marke */
.bar { margin: 10px 0 4px; }
.bar-track {
  position: relative; height: 10px; background: var(--track);
  border-radius: 999px; border: 1px solid #d5dded;
}
.bar-lg .bar-track { height: 16px; }
.bar-fill {
  width: 0; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #1b57b8, #4a86e8);
}
.bar-marker {
  position: absolute; left: 70%; top: -5px; bottom: -5px; width: 2px;
  background: var(--mark); border-radius: 2px;
}
.bar-lg .bar-marker { top: -6px; bottom: -6px; width: 3px; }
.marker-cap {
  position: absolute; left: 50%; top: -5px; width: 8px; height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--mark); border-radius: 1px;
}
.bar-legend {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px;
  font-size: .8rem; color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 3px; height: 14px; background: var(--mark); border-radius: 2px; display: inline-block; }

.stat-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.stat-list li {
  background: var(--surface-soft); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-k { font-size: .78rem; color: var(--muted); }
.stat-v { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

/* ---------- Fächer ---------- */
.grid { display: grid; gap: 14px; }
.subject-card { display: flex; flex-direction: column; }
.subj-head h3 { margin-bottom: 2px; }
.subj-course { margin: 0; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.subj-pct { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 12px 0 0; }
.subj-num {
  font-size: 2rem; font-weight: 800; letter-spacing: -.03em;
  color: var(--accent-ink); font-variant-numeric: tabular-nums; line-height: 1;
}
.subj-unit { font-size: .55em; font-weight: 700; }
.subj-ratio { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.mini-stats {
  list-style: none; margin: 12px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted);
}
.mini-stats li { display: inline-flex; align-items: baseline; gap: 5px; }
.mini-stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.card-link {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: .9rem; text-decoration: none;
}
.card-link-arrow { transition: transform .15s ease; }
.card-link:hover .card-link-arrow { transform: translateX(3px); }

/* ---------- Regel-Hinweis ---------- */
.rule-card { margin-top: 22px; }
.rule-card p:last-child { margin-bottom: 0; }

/* ---------- Filter ---------- */
.filter-card { margin-bottom: 16px; }
.filters { display: grid; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.field input, .field select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.field input::placeholder { color: #7b87a0; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: .95rem;
  border-radius: 10px; padding: 11px 18px; min-height: 44px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-ghost { background: transparent; color: var(--accent-ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-soft); color: var(--accent-ink); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Tabelle ---------- */
.table-card { padding: 16px 14px; }
.list-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 12px; margin-bottom: 10px;
}
.list-head h2 { margin: 0; font-size: 1.05rem; }
.list-head p { margin: 0; font-size: .84rem; }
.table-scroll { width: 100%; }

.units { width: 100%; border-collapse: collapse; font-size: .93rem; }
.units thead th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.units tbody th, .units tbody td {
  text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top; font-weight: 400;
}
.units tbody tr:last-child th, .units tbody tr:last-child td { border-bottom: 0; }
.units tbody tr:hover { background: var(--surface-soft); }
.cell-weekday { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-theme { overflow-wrap: anywhere; }
.subj-tag { font-weight: 600; }

/* ---------- Status-Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 3px 10px 3px 4px;
  font-size: .8rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}
.badge-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: .72rem; font-weight: 800; background: rgba(255, 255, 255, .75);
  border: 1px solid currentColor;
}
.badge-word { font-weight: 700; }
.st-a { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.st-v { color: var(--late-fg); background: var(--late-bg); border-color: var(--late-line); }
.st-e { color: var(--exc-fg); background: var(--exc-bg); border-color: var(--exc-line); }
.st-u { color: var(--unexc-fg); background: var(--unexc-bg); border-color: var(--unexc-line); }

/* ---------- Legende ---------- */
.legend-card { margin-top: 16px; }
.legend-grid {
  list-style: none; margin: 0 0 10px; padding: 0;
  display: grid; gap: 10px;
}
.legend-grid li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.legend-grid .muted { font-size: .82rem; }
.legend-note { margin: 0; font-size: .82rem; }

/* ---------- Pagination ---------- */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.pager-btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 40px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-strong);
  text-decoration: none; font-weight: 600; font-size: .9rem; color: var(--accent-ink);
  background: var(--surface);
}
.pager-btn:hover { background: var(--surface-soft); }
.pager-btn.is-disabled { color: #98a3b8; border-color: var(--line); background: var(--surface-soft); }
.pager-pages { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; }
.pager-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: 40px; padding: 0 8px; border-radius: 10px;
  text-decoration: none; font-weight: 600; font-size: .9rem; color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
.pager-num:hover { background: var(--surface-soft); }
.pager-num.is-current { background: var(--accent); color: #fff; }
.pager-gap { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; color: var(--muted); }

/* ---------- Leerzustand ---------- */
.empty { text-align: center; padding: 34px 8px; }
.empty-title { font-weight: 700; margin-bottom: 4px; }

/* ---------- Login ---------- */
.page-login .wrap { padding-top: 28px; }
.login-shell { display: grid; gap: 18px; max-width: 960px; margin: 0 auto; }
.login-card { padding: 24px 20px; }
.login-card h1 { margin-bottom: 8px; }
.login-note { margin: 16px 0 0; font-size: .82rem; color: var(--muted); }

.form { display: grid; gap: 14px; margin-top: 14px; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  background: #fdecec; color: #8a1616; border: 1px solid #f2c4c4;
  border-radius: 12px; padding: 10px 12px; font-size: .9rem; font-weight: 600;
}
.alert-icon {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  background: #8a1616; color: #fff; display: inline-flex; align-items: center;
  justify-content: center; font-size: .8rem; font-weight: 800;
}

.login-aside { padding: 4px 4px 0; }
.login-aside h2 { font-size: 1rem; }
.ticks { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.ticks li { position: relative; padding-left: 24px; font-size: .92rem; }
.ticks li::before {
  content: "✓"; position: absolute; left: 0; top: 0; color: var(--ok-fg); font-weight: 800;
}
.aside-warn {
  background: #fff8e6; border: 1px solid #eeda9e; border-radius: 12px;
  padding: 10px 12px; font-size: .84rem; color: #4a3600;
}

/* ---------- Footer ---------- */
.footer {
  max-width: 1120px; margin: 0 auto; padding: 8px 16px 40px;
  color: var(--muted); font-size: .8rem;
}
.footer p { margin: 0 0 6px; }
.footer-fine { font-size: .78rem; }

.print-only { display: none; }

/* ---------- Tablet / Desktop ---------- */
@media (min-width: 640px) {
  .wrap { padding: 26px 24px 64px; }
  .card { padding: 22px; }
  .topnav { order: 2; width: auto; margin-left: 8px; }
  .userbox { text-align: left; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-actions { grid-column: 1 / -1; }
  .legend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .total-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; }
  .stat-list { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .filters { grid-template-columns: 1.1fr .9fr 1.6fr 1fr auto; align-items: end; }
  .filter-actions { grid-column: auto; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .login-shell { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); align-items: start; gap: 24px; }
}

@media (min-width: 1180px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .subject-card { padding: 20px 18px; }
}

/* ---------- Mobile Tabelle als Karten ---------- */
@media (max-width: 719px) {
  .table-card { padding: 14px 12px; }
  .units, .units tbody, .units tr, .units th, .units td { display: block; width: 100%; }
  .units thead { display: none; }
  .units tbody tr {
    border: 1px solid var(--line); border-radius: 12px;
    padding: 10px 12px; margin-bottom: 10px; background: var(--surface);
  }
  .units tbody tr:hover { background: var(--surface); }
  .units tbody th, .units tbody td {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
    gap: 2px 14px; padding: 5px 0; border: 0; text-align: right;
  }
  .units tbody th::before, .units tbody td::before {
    content: attr(data-label); color: var(--muted); font-weight: 700;
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    text-align: left; flex: 0 0 auto;
  }
  .units tbody th.cell-date { font-weight: 400; }
  .units .cell-theme { text-align: left; }
  .units .cell-theme::before { margin-bottom: 2px; }
  .units tbody td[data-label="Status"] { justify-content: space-between; }
}

/* ---------- Druck ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .topbar, .no-print, .skip-link, .pager, .card-link, .filter-card, .logout-form { display: none !important; }
  .demo-ribbon {
    background: #fff; color: #000; border: 1.5pt solid #000; padding: 6pt 8pt;
    font-size: 9pt; margin-bottom: 8pt;
  }
  .wrap { padding: 0; max-width: none; }
  .card { box-shadow: none; border: .75pt solid #666; break-inside: avoid; padding: 10pt; }
  .print-only { display: block; }
  .print-note { font-size: 8.5pt; margin-top: 8pt; }
  .units { font-size: 8.5pt; }
  .units thead { display: table-header-group; }
  .units tbody tr { break-inside: avoid; }
  .badge { border: .75pt solid #000; color: #000 !important; background: #fff !important; }
  .bar-fill { background: #444 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bar-marker { background: #000 !important; }
  .bar, .bar-legend { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
