:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #5f6b66;
  --line: #dde1dc;
  --accent: #2f5d50;
  --accent-hover: #244a3f;
  --approve: #1a7f37;
  --approve-bg: #e8f5ec;
  --reject: #c62828;
  --reject-bg: #fdecec;
  --pending: #8a6d00;
  --pending-bg: #fdf6dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1.5rem;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.brand-logo { height: 30px; width: auto; display: block; }
.login-logo { display: block; height: 84px; width: auto; margin: 0 auto 1rem; }
.auth-card h1 { text-align: center; }

/* Reiter für mehrere PDFs */
.filetabs-hint { margin: 0 0 .5rem; font-size: .95rem; }
.filetabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.filetab {
  display: inline-flex; align-items: center; gap: .45rem; max-width: 100%;
  padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: .92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filetab:hover { border-color: var(--accent); }
.filetab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filetab-num {
  display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; background: var(--bg); color: var(--text);
}
.filetab.active .filetab-num { background: rgba(255,255,255,.25); color: #fff; }

/* Impressum */
.auth-stack { width: 100%; max-width: 400px; display: grid; gap: 1rem; padding: 1.5rem 0; }
.impressum-card { padding: 1rem 1.25rem; font-size: .85rem; line-height: 1.45; color: var(--muted); box-shadow: none; }
.impressum h2 { font-size: .95rem; color: var(--text); margin: 0 0 .5rem; display: block; }
.impressum-label { font-weight: 600; color: var(--text); margin: 0 0 .25rem; }
.impressum address { font-style: normal; margin: 0 0 .6rem; }
.impressum p { margin: 0 0 .6rem; }
.impressum p:last-child { margin-bottom: 0; }
.footer { text-align: center; padding: 0 1rem 2rem; font-size: .85rem; }
.footer a { color: var(--muted); }
.topbar nav { display: flex; align-items: center; gap: 1.25rem; font-size: .95rem; }
.topbar nav a { text-decoration: none; }
.topbar form { margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }

/* Seitenrahmen */
.page { max-width: 760px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.page.wide { max-width: 1100px; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.auth-card { width: 100%; max-width: 400px; }
.narrow { max-width: 460px; }

/* Formulare */
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .35rem; }
input[type=email], input[type=password], input[type=text], textarea {
  width: 100%; padding: .65rem .75rem; font: inherit; color: inherit;
  border: 1px solid #c5cbc6; border-radius: 8px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { resize: vertical; min-height: 6rem; }
.error { color: var(--reject); font-size: .9rem; margin: .3rem 0 0; }
.help { color: var(--muted); font-size: .85rem; margin-top: .35rem; }
.help ul { margin: .25rem 0 0; padding-left: 1.1rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.1rem; font: inherit; font-weight: 600; text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer;
}
.btn:hover { border-color: #b8beb9; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }

/* Meldungen */
.notice { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.notice-success { background: var(--approve-bg); border-color: #b9e0c4; color: #134f24; }
.notice-error { background: var(--reject-bg); border-color: #f2c1c1; color: #8e1c1c; }
.notice-info, .notice-warning { background: var(--pending-bg); border-color: #efdf9f; color: #5f4b00; }

/* Dokumentliste */
.count { font-size: .8rem; font-weight: 600; background: var(--accent); color: #fff; border-radius: 999px; padding: .05rem .55rem; }
.doclist { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.doclist a {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title status" "meta status"; gap: .1rem 1rem;
  align-items: center; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: inherit; text-decoration: none;
}
.doclist a:hover { border-color: var(--accent); }
.doc-title { grid-area: title; font-weight: 600; }
.doc-meta { grid-area: meta; color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); padding: 1rem 0; }

.status { grid-area: status; font-size: .85rem; font-weight: 600; padding: .25rem .65rem; border-radius: 999px; white-space: nowrap; }
.status-pending { background: var(--pending-bg); color: var(--pending); }
.status-approved { background: var(--approve-bg); color: var(--approve); }
.status-rejected { background: var(--reject-bg); color: var(--reject); }

/* Detailseite */
.back { margin: 0 0 1rem; }
.back a { text-decoration: none; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.note { background: var(--surface); border-left: 4px solid var(--accent); padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }

.viewer { background: #525659; border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.viewer iframe { display: block; width: 100%; height: 78vh; border: 0; }

.decision textarea { margin-bottom: 1rem; }
.decision-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .5rem; }
.btn-approve, .btn-reject { padding: .9rem 1rem; font-size: 1.05rem; color: #fff; border: 0; }
.btn-approve { background: var(--approve); }
.btn-approve:hover { background: #156b2e; }
.btn-reject { background: var(--reject); }
.btn-reject:hover { background: #a82020; }
.icon { font-size: 1.3em; line-height: 1; }

.result { border-width: 2px; }
.result-approved { border-color: var(--approve); background: var(--approve-bg); }
.result-rejected { border-color: var(--reject); background: var(--reject-bg); }
.result-title { font-size: 1.2rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: .5rem; }
.result-approved .result-title { color: var(--approve); }
.result-rejected .result-title { color: var(--reject); }
.result .muted { margin: .25rem 0 0; }
.result-comment { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(0,0,0,.08); }

/* Seitenkopf mit Aktionen */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.actions form { margin: 0; }
.btn-small { padding: .4rem .8rem; font-size: .9rem; }
.count-muted { background: #c5cbc6; color: var(--text); }
.required { color: var(--reject); }

/* Admin-Zeilen: Titel + Stand + Archiv-Button */
.doclist li.docrow {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.doclist li.docrow:hover { border-color: var(--accent); }
.doclist .docrow-main { display: flex; flex-direction: column; flex: 1 1 14rem; padding: 0; border: 0; background: none; }
.docrow form { margin: 0; }
.tally { grid-area: status; display: flex; flex-wrap: wrap; gap: .35rem; }
.tally .status { grid-area: auto; }

/* Archiv */
.search { display: flex; gap: .5rem; flex-wrap: wrap; }
.search input { width: 18rem; max-width: 100%; padding: .55rem .75rem; font: inherit; border: 1px solid #c5cbc6; border-radius: 8px; }
.month { margin-top: 1rem; }
.month summary {
  display: flex; align-items: center; gap: .6rem; cursor: pointer; list-style: none;
  font-weight: 700; font-size: 1.05rem; padding: .5rem 0;
}
.month summary::-webkit-details-marker { display: none; }
.month summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.month[open] summary::before { transform: rotate(90deg); }
.month .doclist { margin-bottom: 1rem; }

/* Tabelle der Prüfungen */
.card-title { margin: 0 0 1rem; }
.card + .viewer, .note + .card { margin-top: 1rem; }
.card { margin-bottom: 1.5rem; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.result-label { font-weight: 600; margin: 0 0 .25rem; }

@media (max-width: 560px) {
  .viewer iframe { height: 65vh; }
  .decision-buttons { grid-template-columns: 1fr; }
  .doclist a { grid-template-columns: 1fr; grid-template-areas: "title" "meta" "status"; }
  .status { justify-self: start; margin-top: .35rem; }
}
