:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --subtle: #fafaf8;
  --line: #e6e6e1;
  --line-strong: #d3d3cc;
  --text: #18191c;
  --muted: #6a6d74;
  --accent: #2f5bea;
  --accent-dark: #1f43c0;
  --accent-bg: #edf1fe;
  --ok: #0f7b4a;
  --ok-bg: #e5f4ec;
  --warn: #8a5a00;
  --warn-bg: #fcf1dc;
  --error: #a3261f;
  --error-bg: #fbeceb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(24, 25, 28, .04);
  --shadow-pop: 0 10px 30px rgba(24, 25, 28, .12);
  --sidebar: 236px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Grundgerüst: Seitenleiste + Inhalt ---------- */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sb-brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--text); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .4px;
}
.sb-brand-text strong { display: block; font-size: 14px; line-height: 1.2; }
.sb-brand-text small { display: block; color: var(--muted); font-size: 12px; }

/* Bereichsumschalter als kleines Aufklappmenü */
.ws-switch { position: relative; }
.ws-switch > summary {
  list-style: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--subtle);
}
.ws-switch > summary::-webkit-details-marker { display: none; }
.ws-switch > summary::after { content: '⌄'; position: absolute; right: 12px; top: 13px; color: var(--muted); }
.ws-switch[open] > summary { border-color: var(--line-strong); }
.ws-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ws-name { font-size: 14px; font-weight: 600; padding-right: 16px; }
.ws-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); padding: 4px;
}
.ws-menu a { display: block; padding: 7px 9px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; }
.ws-menu a small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.ws-menu a:hover, .ws-menu a.current { background: var(--accent-bg); }

.sb-nav { display: flex; flex-direction: column; gap: 1px; }
.sb-section {
  margin: 14px 10px 4px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.sb-nav a, .sb-foot a, .sb-foot button {
  display: block; padding: 7px 10px; border-radius: var(--radius-sm);
  color: #3d4048; text-decoration: none; font-size: 14px; font-weight: 500;
}
.sb-nav a:hover, .sb-foot a:hover, .sb-foot button:hover { background: var(--bg); color: var(--text); }
.sb-nav a.active, .sb-foot a.active { background: var(--accent-bg); color: var(--accent-dark); }

.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: 1px; border-top: 1px solid var(--line); padding-top: 10px; }
.sb-foot form { margin: 0; }
.sb-foot button { width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; }

main { width: 100%; max-width: 1180px; padding: 32px 40px 72px; }

/* ---------- Typografie ---------- */

h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
small.muted { font-size: 12.5px; }

/* ---------- Flächen ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.cols-2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  display: block;
}
a.stat:hover { border-color: var(--line-strong); }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.accent .value { color: var(--accent-dark); }
.stat.alert { border-color: #f0d9a8; background: #fffaf0; }
.stat.alert .value { color: var(--warn); }

/* Trichter auf der Übersicht: Bewerbung → Entscheidung → Zusage → Teilnehmer */
.funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.funnel a { padding: 16px 18px; text-decoration: none; color: inherit; border-right: 1px solid var(--line); position: relative; }
.funnel a:last-child { border-right: 0; }
.funnel a:hover { background: var(--subtle); }
.funnel a:not(:last-child)::after {
  content: ''; position: absolute; right: -7px; top: 50%; width: 12px; height: 12px; z-index: 1;
  background: inherit; border-top: 1px solid var(--line); border-right: 1px solid var(--line);
  transform: translateY(-50%) rotate(45deg); background: var(--surface);
}
.funnel .step { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.funnel .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.funnel .sub { font-size: 13px; color: var(--muted); }
.funnel .final .value { color: var(--ok); }

/* Aufgabenliste „Als Nächstes" */
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.todo li:last-child { border-bottom: 0; padding-bottom: 0; }
.todo li:first-child { padding-top: 0; }
.todo .count {
  min-width: 40px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-weight: 650; font-size: 15px;
  background: var(--bg); color: var(--text);
}
.todo .count.warn { background: var(--warn-bg); color: var(--warn); }
.todo .text { flex: 1; min-width: 0; }
.todo .text small { display: block; color: var(--muted); font-size: 12.5px; }
.todo-done { color: var(--muted); margin: 0; }

/* ---------- Hinweise ---------- */

.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #c9e8d6; }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d9a8; }
.flash-error { background: var(--error-bg); color: var(--error); border-color: #f1c9c6; }
.flash a { color: inherit; font-weight: 600; }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* ---------- Bedienelemente ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1.4;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--error); border-color: #ebc8c5; }
.btn-danger:hover { background: var(--error-bg); }
.btn-small { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid #d6defc; outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 200px; resize: vertical; line-height: 1.55; }
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* Umschalter zwischen Ansichten einer Seite */
.tabs { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 18px; background: #ecece7; border-radius: 10px; flex-wrap: wrap; }
.tabs a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-size: 14px; font-weight: 500;
}
.tabs a span { margin-left: 6px; font-weight: 600; color: var(--text); }
.tabs a:hover { color: var(--text); }
.tabs a.current { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(24, 25, 28, .08); }
.tabs a.current .warn-dot { color: var(--warn); }

/* ---------- Tabellen ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--subtle); }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ---------- Listenansicht ---------- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head .lead { margin-bottom: 20px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--text); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=text] { flex: 1 1 260px; }
.toolbar select { flex: 0 1 200px; width: auto; }

.filterbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filterbar a {
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
}
.filterbar a span { color: var(--text); font-weight: 600; margin-left: 4px; }
.filterbar a:hover { border-color: var(--line-strong); }
.filterbar a.current { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-bg); }

.filterbar-sub { align-items: center; margin-top: -6px; }
.filterbar-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }

/* Aufklappbare Gruppen je Entscheidung */
.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.group > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; cursor: pointer; list-style: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before {
  content: '▸'; color: var(--muted); font-size: 12px; transition: transform .15s ease;
}
.group[open] > summary::before { transform: rotate(90deg); }
.group > summary:hover { background: var(--subtle); }
.group-title { font-weight: 650; font-size: 15px; }
.group-count {
  background: var(--bg); border-radius: 999px; padding: 1px 9px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.group-meta { margin-left: auto; font-size: 13px; color: var(--muted); text-align: right; }
.group-meta a { color: var(--muted); text-decoration: none; }
.group-meta a:hover { color: var(--accent-dark); text-decoration: underline; }
.group .table-wrap { border-top: 1px solid var(--line); }
details.group > summary .pill { margin-left: 4px; }

/* „Mehr"-Menü in der Aktionsleiste – hält das Löschen auf Abstand */
.bulkmore { position: relative; margin-left: auto; }
.bulkmore > summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.bulkmore > summary::-webkit-details-marker { display: none; }
.bulkmore > summary:hover { background: rgba(255, 255, 255, .12); }
.bulkmore[open] > summary { background: rgba(255, 255, 255, .16); }
.bulkmore > .btn {
  position: absolute; right: 0; top: calc(100% + 6px); white-space: nowrap;
  background: var(--surface); box-shadow: var(--shadow-pop);
}

.quickadd summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.quickadd summary + form { margin-top: 16px; }
.quickadd textarea { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.bulkbar {
  position: sticky; top: 10px; z-index: 5;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--text); color: #fff;
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px;
  box-shadow: var(--shadow-pop);
}
.bulkbar[hidden] { display: none; }
.bulkbar select, .bulkbar input[type=text] { width: auto; flex: 0 1 200px; }

.table-card { padding: 0; overflow: hidden; }
.col-check { width: 36px; }
.note-dot { color: var(--accent); font-weight: 700; }
td a { color: var(--accent-dark); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ---------- Anmeldung ---------- */

.auth-body { display: grid; place-items: center; min-height: 100vh; }
.auth-main { width: 100%; max-width: 420px; padding: 24px; }
.auth-card { padding: 28px; }

/* ---------- Versand ---------- */

.checkrow { display: flex; gap: 16px; flex-wrap: wrap; }
.checkitem {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 400; font-size: 14px; margin-bottom: 0; cursor: pointer;
}

.progress {
  height: 10px; border-radius: 999px; background: var(--line);
  overflow: hidden; margin-bottom: 14px;
}
.progress-bar { height: 100%; background: var(--accent); transition: width .3s ease; }
.run-line { margin: 0 0 4px; font-size: 15px; }

/* ---------- Mailvorschau ---------- */

.mail-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 20px 22px;
  max-height: 460px;
  overflow-y: auto;
}
.mail-preview p:last-child { margin-bottom: 0; }

code {
  background: #efefea; border-radius: 5px; padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
}

.tone-neutral { background: #efefea; color: #4b4f57; }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-strong { background: var(--ok); color: #fff; }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-error { background: var(--error-bg); color: var(--error); }
.tone-info { background: var(--accent-bg); color: var(--accent-dark); }
.tone-hint { background: #f1e9fb; color: #6b3fa0; }

/* ---------- Teilnehmer ---------- */

.ptable td { padding: 6px 10px; }
.ptable select, .ptable input[type=text] { padding: 5px 7px; font-size: 13px; }
.ptable select { width: auto; min-width: 54px; }
.ptable input[name=accommodation] { min-width: 150px; }
.ptable input[name=participant_note] { min-width: 170px; }

/* Teilnehmer-Akte */
.facts { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 22px; }
.fact { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.fact b { font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 12px; align-items: center; }
.kv label { margin: 0; color: var(--muted); font-weight: 500; overflow-wrap: anywhere; }

/* Unterkünfte */
.group.acc { margin-bottom: 8px; }
.acc-body { padding: 12px 18px 16px; border-top: 1px solid var(--line); }

/* ---------- Kleine Bildschirme ---------- */

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sb-brand-text { display: none; }
  .ws-switch { flex: 1 1 200px; }
  .sb-nav { flex-direction: row; flex: 1 1 100%; min-width: 0; overflow-x: auto; gap: 2px; }
  .todo li { flex-wrap: wrap; }
  .todo .btn { margin-left: 54px; }
  .sb-section { display: none; }
  .sb-nav a { white-space: nowrap; }
  .sb-foot { flex-direction: row; margin: 0; border: 0; padding: 0; }
  main { padding: 20px 16px 56px; }
  .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel a::after { display: none; }
  .cols-2 { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

/* ---------- Öffentliche Seiten: Zusage-Formular und Eltern-Bestätigung ---------- */

.public-body { display: block; }
.public-main { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; }
.public-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.public-brand small { display: block; color: var(--muted); font-size: 12.5px; }
.public-main h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -.02em; }
.public-main h2 { font-size: 17px; margin: 0 0 14px; }
.public-main h3 { font-size: 15px; margin: 18px 0 6px; }
.public-form .card { margin-bottom: 16px; }
.req { color: var(--error); font-weight: 600; }
.choice { border: 0; padding: 0; margin: 0 0 14px; }
.choice legend { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; padding: 0; }
.choice-item { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14.5px; margin: 0 0 6px; cursor: pointer; }
.choice-item input { margin: 0; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; line-height: 1.5; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 10px; cursor: pointer; }
.consent input { margin: 4px 0 0; flex: 0 0 auto; }
.consent.has-error, .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--error); }
.field-error { color: var(--error); font-size: 12.5px; margin: 4px 0 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.live-hint { font-size: 12.5px; margin: 4px 0 0; }
.live-hint.is-ok { color: var(--ok); }
.live-hint.is-error { color: var(--error); }
.public-actions { text-align: center; padding: 8px 0 0; }
.btn-big { font-size: 16px; padding: 12px 26px; }
[hidden] { display: none !important; }
