/* Treuhänder-Plattform — keine Inline-Styles (CSP: default-src 'self') */
:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2430; --muted: #6b7280; --line: #e3e6eb;
  --primary: #1f4e79; --primary-hover: #163a5c; --ok: #1e7d4f; --warn: #a15c00; --err: #b42318;
  --ok-bg: #e8f5ee; --warn-bg: #fff4e0; --err-bg: #fdecea; --info-bg: #e9f1fb;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 15px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
h5 { font-size: .95rem; margin: .75rem 0 .25rem; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Layout */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--primary); color: #fff; padding: .6rem 1.5rem; }
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 600; }
.topbar nav { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.topbar button.link { color: #fff; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.narrow { max-width: 440px; margin: 3rem auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.inline { display: inline; }

/* Forms */
label { display: block; font-weight: 500; margin-bottom: .75rem; }
label.checkbox, label.choice { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; border: 1px solid #c9ced6; border-radius: 6px; font: inherit; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0e6; border-color: var(--primary); }
input.code-input { font-size: 1.4rem; letter-spacing: .3rem; text-align: center; }
input.short { width: 6rem; display: inline-block; }
.btn { display: inline-block; padding: .5rem .95rem; border-radius: 6px; border: 1px solid #c9ced6; background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--err); border-color: #f0b4ae; }
.btn-small { padding: .2rem .55rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-decoration: underline; }

/* Flash & Badges */
.flashes { margin-bottom: 1rem; }
.flash { padding: .65rem .9rem; border-radius: 6px; margin-bottom: .5rem; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #b9e1cb; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #f4c7c1; }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: #f2d7a6; }
.flash-info, .flash-message { background: var(--info-bg); color: var(--primary); border-color: #c5d9f1; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #eef0f3; color: var(--muted); }
.badge-aktiv, .badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-entwurf { background: #eef0f3; color: var(--muted); }
.badge-abgeschlossen { background: var(--info-bg); color: var(--primary); }
.badge-warnung { background: var(--warn-bg); color: var(--warn); }
.badge-fehler, .badge-missing { background: var(--err-bg); color: var(--err); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; font-size: .9rem; color: var(--muted); }
table.compact td, table.compact th { padding: .3rem .5rem; font-size: .88rem; }
table.dist { width: auto; min-width: 420px; }
table.dist td { border: 0; padding: .15rem .5rem; }
td.bar { width: 200px; }
progress { width: 100%; height: .8rem; accent-color: var(--primary); }

/* Survey navigation */
.survey-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.crumbs { color: var(--muted); }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.stat { font-size: 1.6rem; font-weight: 600; }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { padding: .4rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; }
.steps .done { color: var(--ok); }
.steps .todo { color: var(--muted); }

/* Form builder */
.question-card { border-left: 4px solid var(--primary); }
.question-card.system { border-left-color: #c9ced6; background: #fafbfc; }
.lang-block { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; margin-bottom: .5rem; }
.lang-block summary { cursor: pointer; font-weight: 600; }
.options-preview { margin: .25rem 0 0; padding-left: 1.2rem; color: var(--muted); }

/* Public survey */
body.public-body { background: #f3f1ec; }
.public { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.lang-switch { text-align: right; font-size: .9rem; margin-bottom: 1rem; }
fieldset.question { border: 1px solid var(--line); background: #fff; border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1rem; }
fieldset.question legend { font-weight: 600; padding: 0 .25rem; }
fieldset.has-error { border-color: var(--err); }
.error-text { color: var(--err); margin: .25rem 0 .5rem; }
.req { color: var(--err); }
.qnum { color: var(--muted); }
.scale { display: flex; flex-wrap: wrap; gap: .35rem; }
.scale-item { display: flex; flex-direction: column; align-items: center; font-weight: 400; margin: 0; min-width: 2.4rem; }
.scale-labels { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-top: .25rem; }
table.matrix td { text-align: center; }
table.matrix th[scope=row] { color: var(--text); font-weight: 500; }

/* Analysis */
.cleaner-text { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: .6rem .8rem; cursor: text; }
.suppressed { color: var(--warn); font-style: italic; }
ul.texts li { margin-bottom: .4rem; }
.check-ok { color: var(--ok); }
.check-warnung { color: var(--warn); }
.check-fehler { color: var(--err); }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; }
.codes { columns: 2; font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; }
