:root {
  --ink: #0f2a2e;
  --ink-2: #3d5357;
  --muted: #6c7f82;
  --paper: #f5f3ee;
  --card: #ffffff;
  --line: #e3e0d8;
  --line-2: #efece6;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --gold: #f2c14e;
  --ok: #0f7a4f;
  --ok-bg: #e3f4ea;
  --warn: #9a6200;
  --warn-bg: #fdf1d8;
  --bad: #b3261e;
  --bad-bg: #fbe5e3;
  --idle: #5b6b6e;
  --idle-bg: #eceae4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 42, 46, .05), 0 6px 24px -12px rgba(15, 42, 46, .18);
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* top bar */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.08); display: grid; place-items: center; }
.mark svg { width: 22px; height: 22px; stroke: #fff; }
.mark svg path { stroke: var(--gold); }
.brand-name { font-weight: 800; letter-spacing: -.01em; }
.top-right { display: flex; align-items: center; gap: 10px; }
.credits { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.08); font-size: 13px; font-weight: 600; white-space: nowrap; }
.credits .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(242,193,78,.2); }
.credits.low .dot { background: #ff7a6b; box-shadow: 0 0 0 3px rgba(255,122,107,.25); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border-radius: 10px; }
.top .ghost { color: #fff; border-color: rgba(255,255,255,.18); background: transparent; }
.top .ghost:hover { background: rgba(255,255,255,.08); }

/* hero */
.hero { padding: 44px 0 22px; }
.hero h1 { font-size: clamp(28px, 4.4vw, 44px); line-height: 1.08; letter-spacing: -.03em; margin: 0 0 14px; font-weight: 800; }
.hero h1 span { color: var(--accent); }
.lead { max-width: 720px; color: var(--ink-2); margin: 0; font-size: 16px; }

/* buttons */
.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 11px; padding: 0 18px; height: 46px; font-weight: 700; border: 1px solid transparent;
  transition: background .15s, transform .05s, box-shadow .15s;
}
.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px -8px rgba(15,107,92,.7); }
.primary:hover { background: #0c5b4e; }
.primary:active, .ghost:active { transform: translateY(1px); }
.primary:disabled { opacity: .55; cursor: default; }
.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.ghost:hover { background: var(--line-2); }
.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

/* input panel */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.tabs { display: inline-flex; background: var(--line-2); border-radius: 11px; padding: 4px; margin-bottom: 14px; }
.tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.tab.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.row-input { display: flex; gap: 10px; }
.row-input input, textarea, dialog input {
  flex: 1; min-width: 0; height: 52px; border: 1.5px solid var(--line); border-radius: 11px; padding: 0 16px;
  background: #fcfbf8; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.row-input input:focus, textarea:focus, dialog input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(15,107,92,.12); background: #fff; }
.row-input .primary { height: 52px; padding: 0 24px; }
textarea { width: 100%; height: auto; padding: 12px 16px; font-family: var(--mono); font-size: 13.5px; resize: vertical; margin-top: 12px; }
.drop {
  display: flex; align-items: center; gap: 14px; padding: 18px; border: 1.5px dashed #cfcabe; border-radius: 12px;
  background: #fcfbf8; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: #f2f8f6; }
.drop input { display: none; }
.drop svg { width: 28px; height: 28px; color: var(--accent); }
.drop span { color: var(--muted); font-size: 13.5px; }
.file-note { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); background: var(--ok-bg); padding: 8px 12px; border-radius: 9px; }
.bulk-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 10px; }

/* settings */
.settings { display: flex; flex-wrap: wrap; gap: 18px 28px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-2); align-items: flex-end; }
.set { display: flex; flex-direction: column; gap: 6px; }
.set-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.stepper { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; height: 36px; }
.stepper button { width: 34px; border: 0; background: #fff; font-size: 18px; }
.stepper input { width: 44px; border: 0; text-align: center; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; height: 36px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* summary */
.summary { margin-top: 26px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--ink-2); }
.stat b { font-size: 15px; color: var(--ink); }
.stat i { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.sum-actions { display: flex; gap: 8px; }
.progress { flex-basis: 100%; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; order: 3; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #25a28c); transition: width .3s; }

/* result cards */
.results { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.card-main { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 18px; padding: 16px 18px; align-items: center; }
.home-name { font-weight: 800; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
.home-host { font-size: 13px; color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.home-host:hover { color: var(--accent); text-decoration: underline; }
.person-name { font-weight: 700; overflow-wrap: anywhere; }
.person-role { display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--line-2); padding: 2px 8px; border-radius: 6px; }
.person-none { color: var(--muted); font-size: 14px; }
.email-box { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.email-line { display: flex; align-items: center; gap: 8px; max-width: 100%; }
.email { font-family: var(--mono); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.copy { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: var(--ink-2); }
.copy:hover { border-color: var(--accent); color: var(--accent); }
.copy svg { width: 15px; height: 15px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; letter-spacing: .01em; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: var(--ok-bg); }
.b-warn { color: var(--warn); background: var(--warn-bg); }
.b-bad { color: var(--bad); background: var(--bad-bg); }
.b-idle { color: var(--idle); background: var(--idle-bg); }
.b-run { color: var(--accent); background: #e2f1ed; }
.b-run::before { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.pct { flex: none; font-family: var(--mono); font-size: 12.5px; font-weight: 600; padding: 2px 7px; border-radius: 7px; border: 1px solid currentColor; line-height: 1.4; }
.p-hi { color: var(--ok); background: var(--ok-bg); }
.p-mid { color: var(--warn); background: var(--warn-bg); }
.p-lo { color: var(--bad); background: var(--bad-bg); }
.cright { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.clist .pct { font-size: 11px; padding: 1px 6px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line-2); padding: 8px 12px 8px 18px; background: #fcfbf8; font-size: 13px; color: var(--muted); }
.card-foot .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.toggle { border: 0; background: transparent; color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 8px; white-space: nowrap; }
.toggle:hover { background: #e9f3f0; }
.toggle svg { width: 16px; height: 16px; transition: transform .2s; }
.card.open .toggle svg { transform: rotate(180deg); }

.details { display: none; border-top: 1px solid var(--line-2); padding: 16px 18px 18px; gap: 18px; grid-template-columns: 1fr 1fr; }
.card.open .details { display: grid; }
.details h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.plist, .clist, .elist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 10px; }
.plist li.cur { border-color: var(--accent); background: #f2f8f6; }
.plist .who { min-width: 0; }
.plist .who div:first-child { font-weight: 700; font-size: 14px; }
.plist .who div:last-child { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.clist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 12.5px; padding: 5px 8px; border-radius: 8px; background: #faf9f6; }
.clist li span:first-child { overflow-wrap: anywhere; min-width: 0; }
.clist .badge { font-family: Manrope, sans-serif; font-size: 11px; padding: 2px 7px; flex: none; }
.elist li { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.manual { display: flex; gap: 8px; margin-top: 10px; }
.manual input { flex: 1; min-width: 0; height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; font-size: 14px; }
.domains { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-family: var(--mono); }
.chip.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.salut { font-family: var(--mono); font-size: 12.5px; background: #faf9f6; border-radius: 8px; padding: 6px 8px; display: inline-block; }
.pages a { color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; }

/* tree: organisation → facilities → their facilities */
.card.d1, .card.d2 { position: relative; overflow: visible; }
.card.d1 { margin-left: 34px; }
.card.d2 { margin-left: 68px; }
.card.d1::before, .card.d2::before { content: ""; position: absolute; left: -20px; top: -13px; bottom: 50%; width: 14px; border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); border-bottom-left-radius: 10px; }
.card.d1:not(.open) .card-foot, .card.d2:not(.open) .card-foot { border-radius: 0 0 var(--radius) var(--radius); }
.card.has-kids { border-color: #cfdcd8; box-shadow: 0 1px 2px rgba(15,42,46,.05), 0 10px 30px -14px rgba(15,107,92,.35); }
.ftype { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; margin-bottom: 5px; }
.ft-heim { color: #7a3e9d; background: #f3e8fa; }
.ft-ambulant { color: #1f5fa8; background: #e5effb; }
.ft-tages { color: #9a6200; background: var(--warn-bg); }
.ft-org { color: var(--ink-2); background: var(--line-2); }
.kids-note { margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--accent); }

/* how */
.how { margin: 48px 0 60px; }
.how h2 { font-size: 20px; letter-spacing: -.01em; margin: 0 0 14px; }
.how ol { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.how li { counter-increment: s; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.how li::before { content: counter(s, decimal-leading-zero); font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.how li b { font-size: 15px; }
.how li span { color: var(--ink-2); font-size: 13.5px; }

/* dialog + toast */
dialog { border: 0; border-radius: 16px; padding: 24px; width: min(400px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(15, 42, 46, .55); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 6px; }
dialog input { width: 100%; margin: 12px 0; }
dialog .primary { width: 100%; }
.err { color: var(--bad); font-size: 13px; margin: -4px 0 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .card-main { grid-template-columns: 1fr; gap: 12px; }
  .details { grid-template-columns: 1fr; }
  .how ol { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .card.d1 { margin-left: 16px; }
  .card.d2 { margin-left: 32px; }
  .card.d1::before, .card.d2::before { left: -12px; width: 8px; }
  .wrap { padding: 0 16px; }
  .credits-label { display: none; }
  .brand-name { white-space: nowrap; font-size: 14px; }
  .hero { padding-top: 28px; }
  .row-input { flex-direction: column; }
  .how ol { grid-template-columns: 1fr; }
  .summary { flex-direction: column; align-items: stretch; }
  .sum-actions { justify-content: stretch; }
  .sum-actions > * { flex: 1; }
  .card-foot { flex-wrap: wrap; }
}
