@font-face {
  font-family: "Montserrat";
  src: url("/static/fonts/Montserrat-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --petrol-900: #002225;
  --petrol-700: #005255;
  --petrol-500: #00717E;
  --tuerkis: #00AFCB;
  --hellblau: #84C8DC;
  --grund: #F3F9FB;
  --karte: #FFFFFF;
  --linie: #DDEBF0;
  --linie-stark: #CFE3EA;
  --text: #002225;
  --text-2: #3F6E72;
  --hell-1: #E6F2F6;
  --hell-2: #DDF4F8;
  --magenta: #A11C67;
  --magenta-dunkel: #7D1450;
  --magenta-hell: #FBEAF2;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Montserrat", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--grund);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--petrol-700); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Grundgerüst ---------- */
.shell { display: flex; min-height: 100vh; }
.rail {
  width: 92px; flex-shrink: 0; background: var(--petrol-900);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: max(20px, env(safe-area-inset-top)) 0 20px;
  position: sticky; top: 0; height: 100vh;
}
.rail-logo { width: 52px; height: 52px; border-radius: 50%; margin-bottom: 18px; }
.rail-item {
  width: 72px; padding: 10px 0; border-radius: 14px; color: var(--hellblau); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 500;
}
.rail-item svg, .rail-sos svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-item.is-active { background: var(--petrol-700); color: #fff; font-weight: 600; }
.rail-item:hover { color: #fff; }
.rail-plus svg { stroke-width: 2.4; }
.rail-spacer { flex-grow: 1; }
.rail-sos {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid #E05A9B; background: var(--magenta); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; font-weight: 700; text-decoration: none; text-transform: uppercase;
}
.rail-sos svg { width: 20px; height: 20px; stroke-width: 2; }
.main { flex-grow: 1; min-width: 0; padding: 32px 40px 56px; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .rail {
    order: 2; position: fixed; bottom: 0; left: 0; right: 0; top: auto; width: auto; height: auto;
    flex-direction: row; justify-content: space-around; align-items: center;
    padding: 8px 8px max(8px, env(safe-area-inset-bottom)); z-index: 20;
  }
  .rail-logo, .rail-spacer { display: none; }
  .rail-item { width: 64px; padding: 6px 0; }
  .rail-sos { width: 52px; height: 52px; }
  .main { padding: max(20px, env(safe-area-inset-top)) 16px 120px; }
  h1 { font-size: 24px; }
}

/* ---------- Bausteine ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.overline { font-size: 14px; font-weight: 500; color: var(--text-2); }
.back { font-size: 14px; font-weight: 600; color: var(--petrol-500); text-decoration: none; display: inline-block; margin-bottom: 4px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.cols { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.cols > .col-wide { flex: 3 1 420px; min-width: 0; }
.cols > .col-narrow { flex: 2 1 300px; min-width: 0; }
@media (max-width: 1000px) { .grid { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }

.card { background: var(--karte); border-radius: 22px; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 2px rgba(0, 34, 37, .06); }
.card-dark { background: var(--petrol-900); color: #fff; }
.card-dark .muted { color: #A9D6E2; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.empty { color: var(--text-2); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
  border-radius: 24px; border: 0; background: var(--petrol-700); color: #fff; font: inherit; font-size: 15px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--petrol-900); }
.btn-accent { background: var(--petrol-500); }
.btn-light { background: var(--hell-1); color: var(--petrol-700); }
.btn-light:hover { background: var(--hell-2); }
.btn-outline { background: #fff; color: var(--petrol-700); border: 1px solid var(--linie-stark); }
.btn-outline:hover { background: var(--grund); }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 13px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--magenta); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row-end { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--hell-2); color: var(--petrol-700); }
.badge-warn { background: var(--magenta-hell); color: var(--magenta-dunkel); }
.badge-grey { background: #EEF3F4; color: var(--text-2); }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--grund); }
.item-main { flex-grow: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 600; }
.item-sub { font-size: 13px; color: var(--text-2); }
.item-link { color: inherit; text-decoration: none; }
.item-link:hover .item { background: var(--hell-1); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--petrol-500); }
.dot-light { background: var(--hellblau); }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--hellblau); color: var(--petrol-900); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }

.timeline-row { display: flex; gap: 18px; align-items: stretch; }
.timeline-time { width: 58px; flex-shrink: 0; font-weight: 600; padding-top: 14px; }
.event { flex-grow: 1; border: 1px solid var(--linie); border-radius: 16px; padding: 14px 18px; }
.event-kicker { font-size: 12px; font-weight: 600; color: var(--petrol-500); text-transform: uppercase; letter-spacing: .6px; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 16px; font-weight: 500; color: var(--text); background: #fff;
  border: 1px solid var(--linie-stark); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--tuerkis); outline-offset: 1px; border-color: var(--tuerkis); }
.fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.fieldset legend { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; padding: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--linie-stark); background: #fff; color: var(--petrol-700); font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip input:checked + span { background: var(--petrol-700); color: #fff; border-color: var(--petrol-700); }
.chip input:focus-visible + span { outline: 2px solid var(--tuerkis); outline-offset: 2px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; font-weight: 500; color: var(--text); }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--petrol-700); flex-shrink: 0; }
.hint { font-size: 13px; color: var(--text-2); }
.alert { padding: 14px 16px; border-radius: 14px; background: var(--magenta-hell); color: var(--magenta-dunkel); font-size: 14px; font-weight: 600; }
.notice { padding: 14px 16px; border-radius: 14px; background: var(--hell-2); color: var(--petrol-700); font-size: 14px; }

/* ---------- Akte ---------- */
.person-head { display: flex; gap: 18px; align-items: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--text-2); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.goal { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--grund); }
.goal-num { width: 28px; height: 28px; border-radius: 50%; background: var(--tuerkis); color: var(--petrol-900); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.goal.is-done .goal-num { background: var(--petrol-700); color: #fff; }
.goal.is-done .goal-text { text-decoration: line-through; color: var(--text-2); }
.goal-text { flex-grow: 1; font-weight: 500; }
.goal form { margin: 0; }
.verlauf-item { display: flex; gap: 16px; align-items: flex-start; }
.verlauf-dot { width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; background: var(--tuerkis); flex-shrink: 0; }
.verlauf-dot.is-light { background: transparent; border: 2px solid var(--hellblau); }

/* ---------- Sitzung ---------- */
.session-bar {
  background: var(--petrol-900); color: #fff; border-radius: 22px; padding: 16px 22px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.session-bar .muted { color: var(--hellblau); }
.chain { display: flex; flex-direction: column; gap: 12px; }
.chain-item { background: #fff; border-radius: 18px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.chain-item.is-intervention { background: var(--hell-1); }
.chain-kicker { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--petrol-500); text-transform: uppercase; letter-spacing: .6px; }
.chain-text { font-size: 15px; white-space: pre-wrap; }
.chain-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { padding: 4px 10px; border-radius: 12px; background: var(--hell-2); color: var(--petrol-700); font-size: 12px; font-weight: 600; }
.tag-strong { background: var(--petrol-900); color: #fff; }
.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 24px; background: var(--hell-1); width: fit-content; }
.tabs label span { display: inline-flex; min-height: 40px; padding: 0 16px; align-items: center; border-radius: 20px; font-size: 14px; font-weight: 600; color: var(--petrol-700); cursor: pointer; }
.tabs input { position: absolute; opacity: 0; }
.tabs input:checked + span { background: var(--petrol-700); color: #fff; }
.situation-only { display: flex; flex-direction: column; gap: 14px; }
.is-intervention-mode .situation-only { display: none; }

/* ---------- Notfall ---------- */
.sos-head { background: var(--magenta); color: #fff; border-radius: 22px 22px 0 0; padding: 22px 26px; }
.sos-head .muted { color: var(--magenta-hell); }
.sos-body { background: #fff; border-radius: 0 0 22px 22px; padding: 22px 26px; display: flex; flex-direction: column; gap: 12px; }
.sos-card {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 20px; min-height: 76px;
  border-radius: 18px; background: var(--grund); color: var(--text); text-decoration: none;
}
.sos-card:hover { background: var(--hell-1); }
.sos-card.is-personal { border: 2px solid var(--tuerkis); background: #F0FAFC; }
.sos-name { display: block; font-size: 15px; font-weight: 700; }
.sos-reason { display: block; font-size: 13px; color: var(--text-2); }
.sos-num { font-size: 22px; font-weight: 800; color: var(--petrol-700); white-space: nowrap; letter-spacing: .3px; }
.sos-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .sos-grid { grid-template-columns: minmax(0, 1fr); } .sos-num { font-size: 19px; } }
.sos-emergency { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sos-pill { display: inline-flex; gap: 8px; align-items: center; min-height: 48px; padding: 0 16px; border-radius: 24px; border: 1px solid var(--magenta); color: var(--magenta-dunkel); text-decoration: none; white-space: nowrap; }
.sos-pill strong { font-size: 20px; font-weight: 800; }
.sos-share { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 18px; border-radius: 18px; background: var(--hell-1); }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--petrol-900); }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 26px; padding: 34px 30px; display: flex; flex-direction: column; gap: 18px; text-align: center; }
.login-card img { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 17px; font-weight: 600; }
.codes li { list-style: none; padding: 12px; border-radius: 12px; background: var(--grund); text-align: center; }
.codes { padding: 0; margin: 0; }
details summary { cursor: pointer; font-weight: 600; color: var(--petrol-700); }

/* ---------- Ergänzungen ---------- */
.search, .select {
  font: inherit; font-size: 15px; min-height: 48px; padding: 0 16px; border-radius: 24px;
  border: 1px solid var(--linie-stark); background: #fff; color: var(--text); min-width: 0;
}
.search { width: 280px; }
.grow { flex: 1 1 220px; width: auto; }
.filter { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter .search { flex: 1 1 260px; }
.spacer { height: 20px; }
.spaced { margin-top: 20px; }
.back-light { color: var(--hellblau); }
.h-bar { font-size: 22px; color: #fff; }
.field-short { max-width: 200px; }
@media (max-width: 760px) { .search { width: 100%; } }
@media print { .rail, .btn-row { display: none; } .main { padding: 0; } }
