/* aidev – ruhig, sachlich, gut lesbar. Systemschriften (keine externen Fonts), Hell/Dunkel. */
:root {
  --bg: #f5f7f7;
  --surface: #ffffff;
  --surface-2: #eef3f3;
  --text: #1b2a2c;
  --muted: #566a6d;
  --line: #d9e2e2;
  --primary: #155e63;
  --primary-hover: #0f4b4f;
  --on-primary: #ffffff;
  --primary-soft: #e3f0f0;
  --ok: #1d6b3a;
  --ok-soft: #e4f3e9;
  --warn: #8a5300;
  --warn-soft: #fdf1dc;
  --danger: #a3262a;
  --danger-soft: #fbe7e7;
  --focus: #2b8a91;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(16 40 42 / 6%), 0 4px 16px rgb(16 40 42 / 6%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Source Sans 3", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1718;
    --surface: #162123;
    --surface-2: #1c2a2c;
    --text: #e4eded;
    --muted: #9db1b3;
    --line: #2a3b3d;
    --primary: #5fb3b9;
    --primary-hover: #7cc6cb;
    --on-primary: #0b1d1f;
    --primary-soft: #1d3436;
    --ok: #7cd19a;
    --ok-soft: #173023;
    --warn: #f0b860;
    --warn-soft: #332714;
    --danger: #f08a8d;
    --danger-soft: #3a1c1d;
    --focus: #7cc6cb;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 400 1rem/1.55 var(--font);
}
main { flex: 1; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2, .h3 { font-size: 1.15rem; }
.h4, h4 { font-size: 1rem; margin-top: 1.25rem; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .95em; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.right { text-align: right; margin-left: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: .5rem; background: var(--surface); padding: .5rem 1rem; z-index: 100; border-radius: var(--radius-sm); }
.skip:focus { left: .5rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* Layout */
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 2rem; }
.wrap.narrow { max-width: 440px; padding-top: 12vh; }
.narrow-block { max-width: 640px; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin-bottom: .25rem; }
.page-head p { margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 650; color: var(--primary); margin: 0 0 .25rem; }
.crumb { margin: 0 0 .75rem; font-size: .9rem; }
.crumb a { text-decoration: none; display: inline-flex; gap: .25rem; align-items: center; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; margin-bottom: 1rem; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.stack { display: grid; gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid-2 > .card + .card { margin-top: 0; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-inner { max-width: 1180px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.brand-mark { width: 1.6rem; height: 1.6rem; border-radius: 7px; background: var(--primary); display: inline-block; position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 28% 24% 30%; border: 3px solid var(--on-primary); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -2px); border-radius: 1px; }
.brand-mark.big { width: 3rem; height: 3rem; border-radius: 12px; }
.realm select, .realm-label { font-size: .9rem; }
.realm select { min-height: 36px; padding: .25rem 2rem .25rem .6rem; width: auto; }
.realm-label { color: var(--muted); padding: .25rem .6rem; background: var(--surface-2); border-radius: 999px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.nav a { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .75rem; min-height: 44px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.account { position: relative; }
.account summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .6rem; border-radius: var(--radius-sm); color: var(--muted); }
.account summary::-webkit-details-marker { display: none; }
.account summary:hover { background: var(--surface-2); }
.account-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .75rem; min-width: 200px; display: grid; gap: .5rem; z-index: 30; }
.account-menu p { margin: 0; }
@media (max-width: 720px) {
  .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; }
  .nav a span { white-space: nowrap; }
  .account { margin-left: auto; }
  .account-name { display: none; }
}

/* Formulare */
label { display: grid; gap: .35rem; font-weight: 550; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .75rem; min-height: 44px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 650; margin-bottom: .5rem; padding: 0; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 400; min-height: 40px; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; accent-color: var(--primary); }
.checks { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); max-height: 340px; overflow: auto; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.checks .count { margin-left: auto; }
.field-error { color: var(--danger); background: var(--danger-soft); padding: .5rem .75rem; border-radius: var(--radius-sm); margin: 0; }
.range-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.range-form > label { min-width: 220px; }
.free-range { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.segmented { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.segmented label { display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: flex; align-items: center; min-height: 44px; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 550; transition: background .15s, border-color .15s; }
.segmented input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; min-height: 44px; padding: .55rem 1rem; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.subtle { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Hinweise */
.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.callout { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius); background: var(--primary-soft); margin-bottom: 1rem; }
.callout .icon { margin-top: .2rem; color: var(--primary); }
.callout p { margin: 0; }
.callout.warn { background: var(--warn-soft); }
.callout.warn .icon { color: var(--warn); }
.callout.ok { background: var(--ok-soft); }
.note { background: var(--warn-soft); padding: .6rem .9rem; border-radius: var(--radius-sm); }
.warn-text { color: var(--warn); font-weight: 600; }
.empty { color: var(--muted); padding: 1rem 0; }
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.busy { background: var(--primary-soft); color: var(--primary); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.failed .icon { width: .75em; }
.badge.busy .icon { width: .7em; animation: pulse 1.4s ease-in-out infinite; }
.status-pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; }
.status-pill .icon { width: .7em; }
.status-pill.ok { background: var(--ok-soft); color: var(--ok); }
.status-pill.off { background: var(--danger-soft); color: var(--danger); }
.count { display: inline-block; min-width: 1.6em; text-align: center; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 0 .45rem; }
@keyframes pulse { 50% { opacity: .35; } }

/* Kinderliste */
.search { min-width: min(100%, 320px); }
.groups { display: grid; gap: 1.25rem; }
.group-title { font-size: .95rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.child-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.child a { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; min-height: 60px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.child a:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.child-name { font-weight: 600; }
.child-meta { margin-left: auto; text-align: right; }

/* Job */
.job { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1rem; }
.job:last-child { border: 0; margin: 0; padding: 0; }
.job-phase { font-weight: 600; margin-bottom: .5rem; }
.job .progress { margin-bottom: .75rem; }
.job .field-error { margin-bottom: .75rem; }
.progress { width: 100%; height: .6rem; border-radius: 999px; overflow: hidden; appearance: none; border: 0; background: var(--surface-2); }
.progress::-webkit-progress-bar { background: var(--surface-2); }
.progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; transition: width .3s ease-out; }
.progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }

/* Schritte der laufenden Analyse */
.job-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.job-head [data-elapsed] { font-variant-numeric: tabular-nums; }
.steps { list-style: none; margin: .75rem 0 1rem; padding: 0; display: grid; gap: .1rem; }
.steps li { display: flex; gap: .75rem; align-items: flex-start; padding: .35rem 0; color: var(--muted); position: relative; }
.steps li:not(:last-child)::before { content: ""; position: absolute; left: .6rem; top: 1.75rem; bottom: -.45rem; width: 2px; background: var(--line); }
.steps li.done:not(:last-child)::before { background: var(--primary); }
.step-mark { width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); flex: none; margin-top: .15rem; display: grid; place-items: center; }
.step-body { display: grid; }
.step-label { font-weight: 600; }
.step-detail { font-variant-numeric: tabular-nums; }
.steps li.done, .steps li.active { color: var(--text); }
.steps li.done .step-mark { background: var(--primary); border-color: var(--primary); }
.steps li.done .step-mark::after { content: ""; width: .32rem; height: .6rem; border: solid var(--on-primary); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.steps li.active .step-mark { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.steps li.active .step-mark::after { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--primary); animation: pulse 1.4s ease-in-out infinite; }
.steps li.failed { color: var(--danger); }
.steps li.failed .step-mark { border-color: var(--danger); background: var(--danger-soft); }
.progress:indeterminate { background: linear-gradient(90deg, var(--surface-2) 0%, var(--primary) 50%, var(--surface-2) 100%) var(--surface-2); background-size: 40% 100%; background-repeat: no-repeat; animation: indet 1.6s ease-in-out infinite; }
.progress:indeterminate::-webkit-progress-bar { background: transparent; }
.progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes indet { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* Analysenliste */
.analysis-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .25rem; }
.analysis-list a { display: flex; gap: .75rem; align-items: center; padding: .65rem .5rem; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.analysis-list a:hover { background: var(--surface-2); }
.analysis-list a > span:first-of-type { display: grid; }
.analysis-list .icon { color: var(--primary); }

/* Bericht */
.report-layout { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; margin-bottom: 1rem; }
@media (min-width: 1000px) { .report-layout { grid-template-columns: minmax(0, 1fr) 340px; } .side { position: sticky; top: 76px; } }
.report { font-size: 1.04rem; line-height: 1.65; }
.report p, .report li { max-width: 75ch; }
.report h2, .report h3 { margin-top: 1.5rem; padding-top: .25rem; }
.report h2:first-child, .report h3:first-child { margin-top: 0; }
.report ul { padding-left: 1.2rem; }
.report li { margin-bottom: .4rem; }
.ref { display: inline-block; font-size: .78rem; font-weight: 650; line-height: 1.4; padding: 0 .4rem; margin: 0 .1rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); text-decoration: none; vertical-align: .1em; }
.ref:hover { background: var(--primary); color: var(--on-primary); }
.ref-bad { background: var(--warn-soft); color: var(--warn); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0 0 .75rem; }
.kpis div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem; text-align: center; }
.kpis dt { font-size: .75rem; color: var(--muted); }
.kpis dd { margin: 0; font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
table.mini { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
table.mini th, table.mini td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mini thead th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-wrap { overflow-x: auto; }
meter { width: 5rem; height: .55rem; vertical-align: middle; }
meter::-webkit-meter-bar { background: var(--surface-2); border: 0; border-radius: 999px; }
meter::-webkit-meter-optimum-value { background: var(--primary); border-radius: 999px; }
meter::-moz-meter-bar { background: var(--primary); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; font-size: .875rem; }
.bars li { display: grid; grid-template-columns: 1fr 5rem 2rem; gap: .5rem; align-items: center; }
.bars .num { text-align: right; font-variant-numeric: tabular-nums; }
.weekdays { display: flex; gap: .3rem; flex-wrap: wrap; }
.weekdays span { display: grid; text-align: center; min-width: 2.3rem; padding: .3rem; background: var(--surface-2); border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
.weekdays b { font-size: .75rem; color: var(--muted); font-weight: 600; }
.sources .source { border-top: 1px solid var(--line); }
.source summary { cursor: pointer; padding: .7rem 0; min-height: 44px; }
.source[open] { background: var(--surface-2); margin: 0 -1.25rem; padding: 0 1.25rem; }
.source.flash-target { animation: hl 1.6s ease-out; }
@keyframes hl { from { background: var(--primary-soft); } }
.source-text { padding: 0 0 1rem; white-space: normal; max-width: 75ch; }
.answer { margin-top: 1rem; }
.facts { display: grid; gap: .5rem; margin: 0 0 1rem; }
.facts div { display: grid; grid-template-columns: 11rem 1fr; gap: .5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.secret { background: var(--surface); padding: .1rem .4rem; border-radius: 4px; user-select: all; }

/* Benutzer */
.user-list { list-style: none; padding: 0; margin: 0; }
.user-list > li { border-bottom: 1px solid var(--line); }
.user-list summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; padding: .7rem 0; min-height: 44px; }
.user-list .inactive { opacity: .6; }
.inline-edit { padding-bottom: .75rem; }

/* Login */
.login-head { text-align: center; margin-bottom: 1.5rem; }
.login-head .brand-mark { margin-bottom: .75rem; }

.foot { padding-top: 0; color: var(--muted); font-size: .85rem; }
.foot p { display: flex; gap: .5rem; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 1rem; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .top, .foot, .no-print, .side, .callout.warn + .callout, .skip { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .report-layout { display: block; }
  .ref { background: none; color: #000; border: 1px solid #999; }
  .source { break-inside: avoid; }
  .source:not([open]) { display: none; }
}
