:root {
    --bg: #f6f7f9; --card: #fff; --line: #e3e6ea; --text: #1d2330; --muted: #6b7280;
    --accent: #4f46e5; --accent-soft: #eef2ff; --danger: #b42318; --danger-soft: #fef3f2;
    --warn-soft: #fffaeb; --warn: #93370d; --radius: 10px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.main { max-width: 920px; margin: 32px auto; padding: 0 24px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
input[type=text], input[type=email], input[type=password], select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }
input[type=text], input[type=email], input[type=password] { flex: 1; }
button, .btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; display: inline-block; }
button.ghost { background: #fff; color: var(--text); border-color: var(--line); }
button.danger { background: #fff; color: var(--danger); border-color: #fecdca; }
button:disabled { opacity: .5; cursor: default; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { background: transparent; color: var(--muted); border-color: transparent; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }
.list { display: grid; gap: 10px; }
.item { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); }
.item:hover { border-color: var(--accent); }
.item .name { font-weight: 600; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #f2f4f7; color: #344054; white-space: nowrap; }
.badge.owner { background: var(--accent-soft); color: var(--accent); }
.badge.editor { background: #ecfdf3; color: #067647; }
.badge.archived { background: var(--warn-soft); color: var(--warn); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.msg.error { background: var(--danger-soft); color: var(--danger); }
.msg.info { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; padding: 28px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.login { max-width: 460px; margin: 80px auto; text-align: center; }
.login .logo { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; margin-bottom: 12px; }
.crumb { font-size: 14px; margin-bottom: 8px; display: inline-block; }
textarea { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
textarea.mono, pre.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
pre.code, pre.source { background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 520px; white-space: pre-wrap; margin: 8px 0 0; }
pre.source { font-family: inherit; font-size: 14px; }
.msg.ok { background: #ecfdf3; color: #067647; }
.badge.st-gueltig { background: #ecfdf3; color: #067647; }
.badge.st-wartet_auf_verarbeitung { background: var(--warn-soft); color: var(--warn); }
.badge.st-entwurf { background: #f2f4f7; color: #344054; }
table.errors td { vertical-align: top; }
table.errors code, td code { font-size: 12.5px; }
summary { cursor: pointer; color: var(--accent); }
label { color: var(--muted); }
form.stack { display: grid; gap: 10px; margin-top: 8px; text-align: left; }
form.stack input { width: 100%; }
.login form button { width: 100%; }
.linkbox input { flex: 1; font-size: 13px; }
.badge.us-aktiv { background: #ecfdf3; color: #067647; }
.badge.us-eingeladen { background: var(--warn-soft); color: var(--warn); }
.badge.us-gesperrt { background: var(--danger-soft); color: var(--danger); }
.who a { font-weight: 600; }
input.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- S3: Ansichten ---------- */
.version-head h1 { margin: 0; }
.version-picker { max-width: 260px; }
.view-tabs { flex-wrap: wrap; margin: 14px 0 0; border-top: 1px solid var(--line); padding-top: 12px; }
.view-tabs .tab { padding: 6px 14px; border-radius: 8px; color: var(--muted); }
.view-tabs .tab.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.view-tabs .tab.disabled { opacity: .4; cursor: not-allowed; }
a.btn.ghost-btn { background: #fff; color: var(--text); border-color: var(--line); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .count { font-size: 13px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.split > .card { margin-bottom: 0; }
.detail { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.empty-detail { text-align: center; padding: 40px 20px; }
.tree-card { padding: 12px; }
.tgroup h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 6px; }
ul.tree, ul.tree ul { list-style: none; margin: 0; padding: 0; }
ul.tree ul { padding-left: 18px; border-left: 1px dashed var(--line); margin-left: 11px; }
.tn-row { display: flex; align-items: center; gap: 2px; }
.tn-toggle { width: 22px; height: 26px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 13px; flex: none; }
.tn-toggle.spacer { display: inline-block; }
.tn-label { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; text-align: left; padding: 5px 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text); }
.tn-label:hover { background: #f2f4f7; }
.tn-label.sel { background: var(--accent-soft); border-color: #c7d2fe; }
.tn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn.ctx > .tn-row .tn-label { opacity: .5; }
.dot-offen { color: #dc6803; font-size: 10px; }
.small { font-size: 12px; }
.chip { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #f2f4f7; color: #475467; white-space: nowrap; flex: none; }
.chip.typ-bereich { background: #eef2ff; color: #3730a3; }
.chip.typ-rolle { background: #ecfdf3; color: #067647; }
.chip.typ-datenobjekt { background: #fdf2fa; color: #9e165f; }
.chip.typ-regel { background: #fffaeb; color: #93370d; }
.chip.typ-seite { background: #f0f9ff; color: #026aa2; }
.chip.typ-datei { background: #f4f3ff; color: #5925dc; }
.badge.offen { background: #fef0c7; color: #93370d; font-weight: 600; }
.badge.festgelegt { background: #f2f4f7; color: #344054; }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 12px; }
dl.fields dt { color: var(--muted); font-size: 13px; }
dl.fields dd { margin: 0; overflow-wrap: anywhere; }
.detail h3 { font-size: 13px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .03em; }
pre.quote { position: relative; max-height: 220px; font-size: 13px; }
pre.quote mark { background: #fde68a; border-radius: 3px; padding: 1px 0; }
ul.links, ul.sentences { margin: 0; padding-left: 18px; }
ul.links li, ul.sentences li { margin: 3px 0; }
.art { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); }
button.linklike { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
pre.raw-json { max-height: 70vh; }
.textview .intro { margin: 0 0 12px; }
.tgroup-text header h2 { margin-bottom: 4px; }
.tgroup-text header p { margin: 0 0 6px; }
.tel { padding: 10px 12px; border-left: 3px solid transparent; border-radius: 6px; margin: 8px 0; scroll-margin-top: 16px; }
article.tel { border-top: 1px solid var(--line); border-radius: 0; }
.tel h3 { margin: 0 0 4px; font-size: 15px; }
.tel p { margin: 0 0 4px; }
.tel.is-offen { border-left-color: #f79009; background: #fffcf5; }
.tel.sel { outline: 2px solid var(--accent); outline-offset: 2px; background: var(--accent-soft); }

@media (max-width: 760px) {
    .top { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
    .who { flex-wrap: wrap; gap: 8px; }
    .main { margin: 16px auto; padding: 0 12px; }
    .card { padding: 14px; }
    h1 { font-size: 20px; }
    .split { grid-template-columns: 1fr; }
    .detail { position: static; max-height: none; }
    .version-picker { max-width: 100%; }
    table { display: block; overflow-x: auto; }
    dl.fields { grid-template-columns: 1fr; gap: 2px; }
    dl.fields dd { margin-bottom: 6px; }
    .row.spread { gap: 10px; }
    input[type=text], input[type=email], input[type=password] { min-width: 0; width: 100%; }
}

/* ---------- S4.1: Architektur ---------- */
.arch-scroll { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.arch-svg { display: block; margin: 0 auto; font-family: inherit; }
.arch-svg text { font-size: 14px; fill: var(--text); pointer-events: none; }
.arch-rolle, .arch-box, .arch-obj, .arch-arrow { cursor: pointer; }
.arch-rolle rect { fill: #ecfdf3; stroke: #067647; stroke-width: 1.5; }
.arch-rolle text { font-weight: 600; fill: #054f31; }
.arch-box > rect { fill: #f8faff; stroke: #a5b4fc; stroke-width: 1.5; }
.arch-box.ohne > rect { fill: #fafafa; stroke: #d0d5dd; stroke-dasharray: 6 4; }
.arch-kind { font-size: 11px !important; letter-spacing: .06em; fill: var(--muted) !important; }
.arch-name { font-size: 17px !important; font-weight: 700; }
.arch-obj rect { fill: #fdf2fa; stroke: #f9a8d4; }
.arch-obj text { font-size: 13px !important; fill: #831843 !important; }
.arch-none, .arch-foot { font-size: 12px !important; fill: var(--muted) !important; }
.arch-svg .offen > rect { stroke: #f79009 !important; stroke-dasharray: 5 3; }
.arch-arrow path { fill: none; stroke: #98a2b3; stroke-width: 2; }
.arch-arrow circle { fill: #fff; stroke: #98a2b3; stroke-width: 1.5; }
.arch-count { font-size: 12px !important; font-weight: 700; fill: #344054 !important; }
#pw-arrow path { fill: #98a2b3; }
.arch-arrow.hl path, .arch-arrow.hl circle { stroke: var(--accent); stroke-width: 3; }
.arch-arrow.hl .arch-count { fill: var(--accent) !important; }
.arch-svg .sel > rect { stroke: var(--accent) !important; stroke-width: 3 !important; stroke-dasharray: none; }
.arch-svg .dim { opacity: .25; }
.arch-arrow:hover path { stroke: var(--accent); }
.legend { margin-left: auto; }
@media (max-width: 760px) { .legend { margin-left: 0; width: 100%; } .arch-scroll { padding: 6px; } }

/* ---------- S4.2.0: Schema v2 ---------- */
.chip.typ-funktion { background: #fdf4ff; color: #86198f; }
.badge.abgeleitet { background: #f4f3ff; color: #5925dc; }
.derived-line { font-size: 14px; }
label.toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--text); white-space: nowrap; }
.arch-arrow.bb path { stroke: #c4b5fd; stroke-dasharray: 6 4; }
.arch-arrow.bb circle { stroke: #a78bfa; }
