/*
 * LOGIN Plattform: Verwaltungsdesign (ADR-006).
 * Sachlich und dicht wie ein Fachverfahren: Kopfleiste, Navigation, Pfad, Tabellen mit
 * Rasterlinien, zweispaltige Formulare. Keine Verläufe, keine Pillenformen, Systemschrift.
 */

:root {
  --page: #f2f4f7;
  --panel: #ffffff;
  --panel-head: #e9edf2;
  --line: #c5ccd6;
  --line-soft: #dde2e8;
  --text: #1c2430;
  --text-muted: #4d5866;
  --text-faint: #6b7684;
  --topbar: #23364d;
  --topbar-text: #ffffff;
  --topbar-muted: #b9c6d6;
  --nav-bg: #e8ecf1;
  --nav-active: #ffffff;
  --accent: #1f5a96;
  --accent-hover: #184a7c;
  --accent-soft: #e6eef8;
  --zebra: #f7f9fb;
  --hover: #eef4fb;
  --ok-fg: #1e6b3a;
  --ok-bg: #e5f2ea;
  --ok-line: #b9dcc6;
  --warn-fg: #7a4d00;
  --warn-bg: #fff4d9;
  --warn-line: #f0d595;
  --error-fg: #9f2420;
  --error-bg: #fbe9e8;
  --error-line: #efc1be;
  --info-fg: #1f5a96;
  --info-bg: #e6eef8;
  --info-line: #bcd0ea;
  --neutral-fg: #3f4a57;
  --neutral-bg: #eceff3;
  --neutral-line: #cfd6de;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "SF Mono", Menlo, monospace;
  --radius: 3px;
  --label-width: 220px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: .875rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--page);
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.3;
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
}

h3 {
  font-size: .875rem;
  font-weight: 600;
}

p {
  margin: 0 0 8px;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

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

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

.meta {
  font-size: .8125rem;
  color: var(--text-faint);
}

.mono {
  font-family: var(--mono);
  font-size: .8125rem;
}

.nowrap {
  white-space: nowrap;
}

/* Foto der Dozierenden: quadratischer Ausschnitt */
.portrait {
  display: block;
  width: 120px;
  height: 120px;
  margin-bottom: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-head);
}

/* Teilnahme anlegen: Bausteine als Liste zum Ankreuzen */
.module-choice ul {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.module-choice li + li {
  margin-top: 4px;
}

.module-choice label {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
}

.warn-text {
  color: var(--warn-fg);
}

/* Tagesdokumentation: Inhalte je UE */
.log-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 8px;
}

.log-tools[hidden] {
  display: none;
}

.log-tools input[type="search"] {
  flex: 1 1 16rem;
  min-width: 0;
}

.log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.log-table th.ue,
.log-table td.ue {
  width: 3.25rem;
  text-align: center;
}

.log-table tr.log-day th {
  background: var(--accent-soft);
  color: var(--accent);
}

.log-table tr.is-taught td {
  color: var(--text-faint);
}

/* Plan des Tages hervorheben, auch gegen die Zebrastreifen */
.log-table tbody tr.is-planned td {
  background: var(--info-bg);
}

.log-table tr.is-planned td.mono {
  font-weight: 700;
}

/* Fehler eines Imports je Zeile */
.error-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--error-fg);
}

.error-list li + li {
  margin-top: 4px;
}

/* Mehrzeilige Notizen mit ihren Zeilenumbrüchen anzeigen */
.pre-line {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Kopfleiste */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 0 16px;
  color: var(--topbar-text);
  background: var(--topbar);
}

.topbar-brand {
  color: var(--topbar-text);
  font-size: .9375rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-brand span {
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--topbar-muted);
  font-weight: 400;
  color: var(--topbar-muted);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .8125rem;
  color: var(--topbar-muted);
}

.topbar .link-button {
  color: var(--topbar-text);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* Rahmen und Navigation */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 44px);
}

.sidebar {
  padding: 8px 0;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
}

.nav-title {
  width: 100%;
  margin: 12px 0 4px;
  padding: 0 16px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav a {
  display: block;
  padding: 5px 16px;
  border-left: 3px solid transparent;
  color: var(--text);
  text-decoration: none;
}

.nav a:hover {
  background: var(--hover);
}

.nav a[aria-current="page"] {
  border-left-color: var(--accent);
  background: var(--nav-active);
  font-weight: 600;
}

.main {
  min-width: 0;
  padding: 12px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Pfad */
.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: .8125rem;
  color: var(--text-faint);
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 4px;
}

/* Seitenkopf mit Werkzeugleiste */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

.record-key {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-family: var(--mono);
  font-size: .8125rem;
  color: var(--text-muted);
}

.toolbar,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Kleine Formulare in Werkzeugleisten und Kastenköpfen: Auswahl und Button nebeneinander */
.toolbar form,
.panel-head form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar select,
.panel-head select {
  width: auto;
}

/* Schaltflächen */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-family: inherit;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--hover);
  color: var(--text);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: #ffffff;
}

.btn-secondary {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-tertiary {
  border-color: var(--line);
}

.btn-danger {
  border-color: var(--error-line);
  color: var(--error-fg);
}

.btn-small {
  min-height: 24px;
  padding: 2px 8px;
  font-size: .75rem;
}

/* Kästen */
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
}

.panel-body,
.card {
  padding: 12px;
}

.panel-body > :last-child {
  margin-bottom: 0;
}

.panel > .table-wrap {
  border: 0;
  border-radius: 0;
}

/* Zwei Spalten auf breiten Bildschirmen, z. B. auf dem Arbeitsplatz */
.columns {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

/* Kopfdaten als Raster aus Beschriftung und Wert */
.facts {
  display: grid;
  grid-template-columns: minmax(140px, max-content) minmax(0, 1fr);
  gap: 4px 16px;
  margin: 0;
}

.facts dt {
  color: var(--text-muted);
}

/* Lange E-Mail-Adressen und Kennungen dürfen am Smartphone umbrechen */
.facts dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Tabellen */
/* position: relative hält unsichtbare Beschriftungen (.sr-only) in der scrollbaren Tabelle */
.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}

th,
td {
  padding: 5px 8px;
  border: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--panel-head);
  border-color: var(--line);
  font-weight: 600;
  white-space: nowrap;
}

tbody th {
  min-width: 12rem;
  white-space: normal;
}

tbody tr:nth-child(even) td {
  background: var(--zebra);
}

tbody tr:hover td {
  background: var(--hover);
}

td.num,
th.num {
  text-align: right;
}

/* Belegnummern und Kennungen nicht umbrechen */
td.mono {
  white-space: nowrap;
}

td.empty {
  padding: 16px 8px;
  color: var(--text-faint);
  text-align: center;
}

.list-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.list-count {
  font-size: .8125rem;
  color: var(--text-muted);
}

/* Kennzahlen im Cockpit */
.figures {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.figure-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.figure-label {
  font-size: .8125rem;
  color: var(--text-muted);
}

.figure-warn {
  border-color: var(--warn-line);
  background: var(--warn-bg);
}

/* Formulare: Beschriftung links, Feld rechts */
input,
select,
textarea {
  width: 100%;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-family: inherit;
  font-size: .875rem;
  color: var(--text);
}

textarea {
  min-height: 72px;
}

input[type="checkbox"],
input[type="radio"] {
  justify-self: start;
  width: auto;
  min-height: 0;
  margin: 8px 0 0;
}

.search input {
  width: min(100%, 360px);
}

.form,
form.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form > div:not(.actions) {
  display: grid;
  grid-template-columns: var(--label-width) minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 2px;
  align-items: start;
  max-width: 900px;
}

.form > div:not(.actions) > label {
  grid-column: 1;
  grid-row: 1 / span 3;
  padding-top: 5px;
  color: var(--text-muted);
}

.form > div:not(.actions) > :not(label) {
  grid-column: 2;
}

.form > div:not(.actions) > .errorlist {
  order: 2;
}

.form > div:not(.actions) > .helptext {
  order: 3;
}

.form > div.required > label::after {
  content: " *";
  color: var(--error-fg);
}

.form > div.has-error input,
.form > div.has-error select,
.form > div.has-error textarea {
  border-color: var(--error-fg);
}

.form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.helptext {
  font-size: .75rem;
  color: var(--text-faint);
}

.errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .8125rem;
  color: var(--error-fg);
}

/* Eingaben in Tabellenzellen, z. B. im Anwesenheitsbogen */
.cell-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.cell-form select {
  width: auto;
}

.cell-form .minutes {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.cell-form:has(option[value="partial"]:checked) .minutes {
  display: flex;
}

.cell-form .minutes input {
  width: 5rem;
}

/* Positionstabellen mit Eingaben, z. B. im Rechnungsentwurf */
.line-table td:first-child {
  width: 55%;
}

.line-table td.num input {
  text-align: right;
}

.form .actions {
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

/* Meldungen und Kennzeichen */
.messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg {
  padding: 8px 12px;
  border: 1px solid var(--neutral-line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--neutral-bg);
}

.msg-success {
  border-color: var(--ok-line);
  border-left-color: var(--ok-fg);
  background: var(--ok-bg);
}

.msg-info {
  border-color: var(--info-line);
  border-left-color: var(--info-fg);
  background: var(--info-bg);
}

.msg-warning {
  border-color: var(--warn-line);
  border-left-color: var(--warn-fg);
  background: var(--warn-bg);
}

.msg-error {
  border-color: var(--error-line);
  border-left-color: var(--error-fg);
  background: var(--error-bg);
}

.chip,
.status {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--neutral-line);
  border-radius: var(--radius);
  background: var(--neutral-bg);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--neutral-fg);
  white-space: nowrap;
}

.chip-ok,
.status-ok {
  border-color: var(--ok-line);
  background: var(--ok-bg);
  color: var(--ok-fg);
}

.chip-warn,
.status-warn {
  border-color: var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-fg);
}

.status-error {
  border-color: var(--error-line);
  background: var(--error-bg);
  color: var(--error-fg);
}

.status-info {
  border-color: var(--info-line);
  background: var(--info-bg);
  color: var(--info-fg);
}

.overdue td:first-child {
  border-left: 3px solid var(--error-fg);
}

/* Reiter auf Detailseiten */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  display: block;
  margin-bottom: -1px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--panel-head);
  color: var(--text);
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--panel);
  background: var(--panel);
  font-weight: 600;
}

/* Listen innerhalb von Kästen */
.checklist,
.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .8125rem;
}

/* Anmeldeseiten */
.auth {
  min-height: 100vh;
  background: var(--page);
}

.auth-card {
  width: min(100% - 32px, 420px);
  margin: 48px auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 0 16px;
}

.auth-card > :not(.auth-head) {
  margin-left: 16px;
  margin-right: 16px;
}

.auth-head {
  padding: 10px 16px;
  color: var(--topbar-text);
  background: var(--topbar);
  font-weight: 700;
}

.auth-head span {
  font-weight: 400;
  color: var(--topbar-muted);
}

.auth-card form p {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
}

.auth-card form p:has(> input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
}

.auth-card .btn {
  align-self: flex-start;
}

.auth-card hr {
  width: auto;
  margin: 4px 16px;
  border: 0;
  border-top: 1px solid var(--line-soft);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: .8125rem;
}

/* Teilnehmerbereich: gleiche Sprache, größere Bedienelemente */
.portal {
  font-size: 1rem;
}

.portal .main {
  max-width: 640px;
  margin: 0 auto;
}

.portal .btn {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 1rem;
}

.portal input,
.portal select,
.portal textarea {
  min-height: 44px;
  font-size: 1rem;
}

.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 16px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
}

.portal-nav a {
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.portal-nav a[aria-current="page"] {
  border-color: var(--line);
  background: var(--panel);
  font-weight: 600;
}

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .sidebar {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .main {
    padding: 16px 24px 48px;
  }
}

@media (min-width: 1100px) {
  .columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  /* Kopfleiste am Smartphone: Zusatz ausblenden, langer Name wird gekürzt */
  .topbar-brand span {
    display: none;
  }

  .topbar-user {
    min-width: 0;
  }

  .topbar-user > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form > div:not(.actions) {
    grid-template-columns: minmax(0, 1fr);
  }

  .form > div:not(.actions) > label,
  .form > div:not(.actions) > :not(label) {
    grid-column: 1;
    grid-row: auto;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toolbar,
  .actions,
  .search,
  .pager,
  .breadcrumbs {
    display: none;
  }

  .shell {
    display: block;
  }

  body {
    background: #ffffff;
  }

  .panel,
  .table-wrap {
    border-color: #000000;
  }
}

.checkin-code {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: .1em;
}

.qr svg {
  width: 12rem;
  height: auto;
}
