:root {
  --ink: #2b3035;
  --ink-2: #3b4148;
  --bg: #f3f4f6;
  --card: #fff;
  --border: #e6e8ea;
  --text: #2b3035;
  --muted: #6b7280;
  --orange: #ef7d00;
  --orange-dark: #d06d00;
  --accent-soft: #fff7e6;
  --focus: #ef7d0026;
  --yellow: #f5b40a;
  --red: #e23b34;
  --green: #1f9d57;
  --shadow: 0 1px 2px #14181c0f, 0 6px 20px #14181c0f;
  --shadow-sm: 0 1px 2px #14181c0f;
  --gap: 16px;
  --pad: 18px;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column; min-height: 100%;
}
a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header (dunkel, orange Unterkante, Pill-Navigation) */
.topbar { background: var(--ink); color: #fff; border-bottom: 2px solid var(--orange);
  box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo-img { height: 30px; width: auto; display: block; }
.logo-img-f80 { height: 40px; }
.brand-sub { color: #ffffffb3; font-size: 14px; font-weight: 500; }
.mainnav { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.mainnav a { color: #ffffffd9; background: #ffffff14; border: 1px solid transparent; border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; }
.mainnav a:hover { color: #fff; background: #ffffff29; text-decoration: none; }
.mainnav a.logout { background: transparent; color: #ffffffb3; }
.mainnav a.logout:hover { background: #ffffff14; }

.container { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 20px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }

h1 { font-size: 24px; font-weight: 800; color: var(--ink); margin: 0 0 6px; }
h2 { font-size: 19px; font-weight: 700; color: var(--ink); margin: 26px 0 12px; }
h3 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0; }
.lead { color: var(--muted); margin: 0 0 22px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--orange); color: #fff; border: 1px solid transparent; padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--orange-dark); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f7f8f9; border-color: #d6d9dc; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-muted { background: #eef0f2; color: var(--text); }
/* Stift-Icon (Bearbeiten) */
.icon-pencil { flex: 0 0 auto; vertical-align: -2px; }
.btn .icon-pencil { margin-right: 2px; }
/* Kompakter, runder Stift-Button (nur Icon) */
.btn-edit { padding: 6px; width: 32px; height: 32px; border-radius: 999px; gap: 0; }
.btn-edit:hover { color: var(--orange-dark); border-color: var(--orange); }

/* Rich-Text-Editor (WYSIWYG – kein HTML) */
.rte { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px; background: #f7f8f9; border-bottom: 1px solid var(--border); }
.rte-btn { border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer; }
.rte-btn:hover { border-color: var(--orange); color: var(--orange-dark); }
.rte-btn:active { background: var(--accent-soft); }
.rte-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 3px; }
.rte-editor { min-height: 280px; max-height: 62vh; overflow-y: auto; padding: 14px 16px; font-size: 15px; line-height: 1.6; outline: none; }
.rte-editor:focus { box-shadow: inset 0 0 0 2px var(--focus); }
.rte-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rte-editor h2 { font-size: 19px; margin: 16px 0 8px; }
.rte-editor h3 { font-size: 16px; margin: 14px 0 6px; }
.rte-editor p { margin: 0 0 10px; }
.rte-editor ul, .rte-editor ol { margin: 0 0 10px 22px; }
.rte-editor a { color: var(--orange-dark); }
.rte-btn.is-active { border-color: var(--orange); background: var(--accent-soft); color: var(--orange-dark); }
.rte-btn-danger:hover { border-color: var(--red); color: var(--red); }

/* Fotos per Drag & Drop */
.rte-dropzone { display: none; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  align-items: center; justify-content: center; gap: 8px; text-align: center;
  background: #fff7e6f2; border: 2px dashed var(--orange); border-radius: var(--radius-sm);
  color: var(--orange-dark); font-size: 17px; font-weight: 700; }
.rte.is-dragover .rte-dropzone { display: flex; }
.rte-imgbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 8px; background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.rte-imgbar[hidden] { display: none; }
.rte-imgbar-label { font-size: 13px; font-weight: 700; color: var(--orange-dark); margin-right: 4px; }
.rte-status { margin: 8px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.rte-status.is-ok { color: var(--green); }
.rte-status.is-error { color: var(--red); }

/* Fotos im Unterweisungstext – im Editor und in der Leseansicht gleich */
.rte-editor .content-image, .content-box .content-image { margin: 14px 0; }
.rte-editor img, .content-box img { max-width: 100%; height: auto; display: block;
  margin: 4px 0; border-radius: var(--radius-sm); }
.rte-editor img.img-s, .content-box img.img-s { max-width: 260px; }
.rte-editor img.img-m, .content-box img.img-m { max-width: 520px; }
.rte-editor img.img-l, .content-box img.img-l { max-width: 100%; }
.rte-editor img { cursor: pointer; }
.rte-editor img.is-selected { outline: 3px solid var(--orange); outline-offset: 2px; }
.rte-editor .is-uploading { padding: 22px; text-align: center; color: var(--orange-dark);
  background: var(--accent-soft); border: 1px dashed var(--orange); border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; }

/* Foto-Bibliothek (/admin/fotos) */
.foto-uploader { text-align: center; padding: 26px 20px; border-style: dashed; border-width: 2px;
  border-color: var(--border); transition: border-color .12s ease, background .12s ease; }
.foto-uploader.is-dragover { border-color: var(--orange); background: var(--accent-soft); }
.foto-drop-title { font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.foto-uploader .btn { margin-top: 12px; }
.foto-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin: 22px 0 12px; font-size: 14px; color: var(--muted); }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--gap); }
.foto-card { margin: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; }
.foto-card > a { display: block; background: #f7f8f9; border-bottom: 1px solid var(--border); }
.foto-card img { display: block; width: 100%; height: 130px; object-fit: cover; }
.foto-card figcaption { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.foto-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foto-usage { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.foto-card form { margin-top: 2px; }

/* Auswahl „Foto aus der Bibliothek" im Unterweisungs-Editor */
.foto-picker { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: #14181c73; }
.foto-picker[hidden] { display: none; }
.foto-picker-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 760px; max-height: 82vh; display: flex; flex-direction: column; padding: 20px; }
.foto-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.foto-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; overflow-y: auto; }
.foto-tile { display: flex; flex-direction: column; gap: 6px; padding: 6px; cursor: pointer;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; text-align: left; }
.foto-tile:hover { border-color: var(--orange); box-shadow: var(--shadow-sm); }
.foto-tile img { width: 100%; height: 92px; object-fit: cover; border-radius: 6px; background: #f7f8f9; }
.foto-tile span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Standort-Umschalter im Menü */
.locnav { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; }
.locnav-pin { font-size: 14px; }
.locnav select { padding: 5px 8px; font-size: 13px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); max-width: 190px; width: auto; }
.locnav-fixed { font-size: 13px; color: var(--muted); font-weight: 600; }

/* Editierbare Mitarbeiterliste (Karten) */
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.emp-card { display: flex; flex-direction: column; gap: 10px; }
.emp-namerow { display: flex; gap: 8px; }
.emp-namerow input { font-weight: 600; }
.emp-email { font-size: 12.5px; color: var(--muted); }
.emp-selects { display: flex; gap: 10px; flex-wrap: wrap; }
.emp-selects label { flex: 1 1 130px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.emp-selects select { font-size: 14px; }
.emp-fixed { font-size: 14px; color: var(--text); font-weight: 400; padding: 8px 0; }
.emp-depts { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 0; }
.emp-depts legend { font-size: 12px; color: var(--muted); font-weight: 700; padding: 0 4px; }
.emp-depts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 2px 10px; margin-top: 4px; }
.emp-depts .check, .emp-flags .check { margin: 0; font-size: 13px; }
.emp-flags { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.emp-save { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(243,244,246,0) 0%, var(--bg) 45%); padding: 16px 0; margin-top: 16px; text-align: center; }

/* Inputs */
input[type=text], input[type=email], input[type=password], input[type=file], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); background: #fff; font-size: 15px; }
input:focus, select:focus { border-color: var(--orange); outline: none; box-shadow: 0 0 0 3px var(--focus); }

/* Cards / Modul-Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--gap); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: var(--pad); }
.module-card { display: flex; flex-direction: column; gap: 10px; }
.module-card:hover { border-color: var(--orange); box-shadow: var(--shadow); }
.module-card .icon { width: 48px; height: 48px; object-fit: contain; }
.module-card .intro { color: var(--muted); font-size: 13px; flex: 1; }

/* Status-Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.offen { background: #eef0f2; color: var(--muted); }
.badge.erledigt { background: #e9f7ee; color: var(--green); }
.badge.faellig_bald { background: var(--accent-soft); color: var(--orange-dark); }
.badge.ueberfaellig { background: #fdecec; color: var(--red); }

/* Stat-Kacheln */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); margin-bottom: 24px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow-sm); }
.tile .num { font-size: 28px; font-weight: 800; color: var(--ink); }
.tile .lbl { color: var(--muted); font-size: 13px; }
.tile.red { background: #fdecec; border-color: #f6cfcd; }
.tile.red .num { color: var(--red); }
.tile.amber .num { color: var(--orange-dark); }
.tile.green { background: #eef6f0; border-color: #cfe6d6; }
.tile.green .num { color: var(--green); }

/* Formulare */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 26px; max-width: 460px; }
.form-wide { max-width: 720px; }
label { display: block; font-weight: 600; margin: 14px 0 5px; font-size: 14px; color: var(--ink-2); }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 180px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; font-weight: 500; }
.check input { margin-top: 3px; width: auto; }
.hint { color: var(--muted); font-size: 13px; }

/* Tabellen */
.table-wrap, table { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
tbody tr:last-child td { border-bottom: none; }
th { background: #fafbfc; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
tbody tr:hover { background: #fafbfc; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #e9f7ee; color: var(--green); }
.alert-error { background: #fdecec; color: var(--red); }

/* Modul-Inhalt */
.content-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 26px; }
.content-box h2 { margin-top: 22px; }
.content-box ul { padding-left: 20px; }
.scroll-read { max-height: 60vh; overflow-y: auto; padding-right: 12px; font-size: 16px; line-height: 1.6; }
/* Bestätigungs-Häkchen unter jedem Absatz */
.para-check { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; padding: 8px 12px;
  background: rgba(0,0,0,0.03); border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
.para-check input { width: 20px; height: 20px; flex: 0 0 auto; margin: 0; cursor: pointer; }

/* Test */
.question { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--orange); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 16px; }
.question .q { font-weight: 700; margin-bottom: 8px; color: var(--ink); }
.question .q-hint { display: inline-block; font-size: 13px; font-weight: 600; color: var(--orange); background: rgba(0,0,0,0.03); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; margin-bottom: 12px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; }
.option input { width: auto; }

/* Abteilungs-Mehrfachauswahl im Mitarbeiter-Formular */
.hint-inline { color: var(--muted); font-size: 13px; font-weight: 400; }
.dept-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; margin-bottom: 18px; }
.dept-grid .check { display: flex; align-items: center; gap: 8px; padding: 6px 0; margin: 0; }
.dept-grid .check input { width: auto; }
@media (max-width: 640px) { .dept-grid { grid-template-columns: 1fr; } }

/* Startseite / Login-Auswahl */
.start-wrap { max-width: 760px; margin: 40px auto; text-align: center; }
.login-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; }
.login-choices a { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px 20px; font-size: 20px; font-weight: 700; color: var(--ink); box-shadow: var(--shadow-sm); }
.login-choices a:hover { border-color: var(--orange); color: var(--orange-dark); text-decoration: none; box-shadow: var(--shadow); }

/* Challenge-Block */
.challenge { display: flex; align-items: center; gap: 24px; background: linear-gradient(135deg, #fff 0%, var(--accent-soft) 100%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px 26px; margin-bottom: 24px; }
.challenge-ring svg { display: block; }
.ring-bg { fill: none; stroke: #efe7d8; stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--orange); stroke-width: 12; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 60px 60px; transition: stroke-dashoffset 1.1s ease-out; }
.ring-pct { fill: var(--ink); font-size: 26px; font-weight: 800; text-anchor: middle; }
.ring-sub { fill: var(--muted); font-size: 13px; font-weight: 600; text-anchor: middle; }
.challenge-title { font-size: 20px; font-weight: 800; color: var(--orange-dark); }
.challenge-msg { margin: 6px 0 14px; font-size: 15px; }

/* Login-Screen (dunkel) + PIN-Keypad */
.login-screen { background: var(--ink); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-stack { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-brand { text-align: center; }
.login-logo { height: 38px; width: auto; }
.login-logo-f80 { height: 64px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card h2 { margin: 0; text-align: center; }
.login-card label { text-align: left; }
.pinpad { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pinpad .full { width: 100%; }
.pin-dots { display: flex; gap: 12px; min-height: 18px; margin: 6px 0 4px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); background: transparent; }
.pin-dot.filled { background: var(--orange); border-color: var(--orange); }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-top: 8px; }
.pin-key { height: 58px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--ink); font-size: 22px; font-weight: 600; cursor: pointer; }
.pin-key:hover { background: #f7f8f9; }
.pin-key:active { background: #eef0f2; }
.pin-key.ghost { color: var(--muted); font-size: 16px; }
.pin-ok { width: 100%; margin-top: 14px; padding: 14px; font-size: 16px; }
.link { color: var(--orange-dark); background: none; border: none; padding: 2px 6px; font-size: 13px; cursor: pointer; text-align: center; }
.login-choice-card { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.login-choice-card a { display: block; text-align: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 26px 14px; font-weight: 700; color: var(--ink); }
.login-choice-card a:hover { border-color: var(--orange); color: var(--orange-dark); text-decoration: none; }

/* F80-Theme (Copper) – wird per Body-Klasse aktiviert */
.theme-f80 {
  --orange: #b3724e;
  --orange-dark: #8f5638;
  --accent-soft: #f3ebe4;
  --focus: #b3724e26;
}

/* Admin-Übersicht: aufklappbare Mitarbeiterliste */
.emp-list { display: flex; flex-direction: column; gap: 8px; }
.emp { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.emp > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; font-weight: 600; }
.emp > summary::-webkit-details-marker { display: none; }
.emp > summary::after { content: '▸'; color: var(--muted); margin-left: 8px; transition: transform .15s ease; }
.emp[open] > summary::after { transform: rotate(90deg); }
.emp-name { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.emp-loc { font-weight: 400; }
.emp-due { white-space: nowrap; font-size: 14px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.emp-due.is-over { color: #fff; background: var(--red, #d23); }
.emp-due.is-due { color: #7a4a00; background: rgba(240,170,0,0.22); }
.emp-due.is-done { color: var(--muted); background: rgba(0,0,0,0.05); }
.emp-body { padding: 4px 18px 16px; border-top: 1px solid var(--border); }
.emp-mod { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.emp-mod:last-of-type { border-bottom: none; }
.emp-mod-title { flex: 1; }
.emp-mod-due { color: var(--muted); font-size: 14px; white-space: nowrap; }
@media (max-width: 640px) {
  .emp > summary { padding: 16px; font-size: 17px; }
  .emp-mod { flex-wrap: wrap; gap: 6px 10px; }
  .emp-mod-due { width: 100%; }
}

@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .login-choices { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  /* Lese-Unterweisung auf dem Handy gut lesbar + große Tap-Häkchen */
  .content-box { padding: 18px; }
  .scroll-read { max-height: 70vh; font-size: 18px; line-height: 1.7; }
  .para-check { font-size: 16px; padding: 12px 14px; margin: 6px 0 22px; }
  .para-check input { width: 28px; height: 28px; }
  .check input { width: 26px; height: 26px; margin-top: 2px; }
  .check span { font-size: 16px; }
}
