@font-face { font-family: 'Inter'; src: url('../../fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../../fonts/inter-v20-latin-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../../fonts/inter-v20-latin-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../../fonts/inter-v20-latin-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --primary: #2DACE2; --primary-hover: #1f97cb; --primary-soft: #eaf7fd; --brand-dark: #2A2B40;
  --bg: #f1f5f9; --surface: #fff; --ink: #0f172a; --ink-soft: #64748b; --ink-faint: #94a3b8;
  --line: #e2e8f0; --line-strong: #cbd5e1;
  --ok: #059669; --ok-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb; --bad: #dc2626; --bad-soft: #fef2f2;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --series-1: #2588c4; --series-2: #d97a0f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-hover); }
.num { font-variant-numeric: tabular-nums; }
h1 { font-size: 22px; font-weight: 700; color: var(--brand-dark); letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 700; color: var(--brand-dark); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Gerüst ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand-dark); color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; text-decoration: none; font-weight: 700; }
.side .brand img { height: 28px; filter: brightness(0) invert(1); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; color: #cbd5e1; text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { background: rgba(45,172,226,.14); color: #fff; border-left-color: var(--primary); }
.side nav a .cnt { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; padding: 0 6px; min-width: 20px; text-align: center; }
.side svg { width: 18px; height: 18px; flex: none; }
.side .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 12.5px; }
.side .foot a, .side .foot button { color: #cbd5e1; background: none; border: none; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
main { padding: 28px 32px 80px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--ink-soft); margin-top: 4px; max-width: 70ch; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 12px 16px 0; min-width: 0; }
  .side .brand { padding: 0 0 10px; }
  .side nav { flex-direction: row; overflow-x: auto; gap: 0; margin: 0 -16px; padding: 0 16px; scrollbar-width: none; }
  .side nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 10px 10px; flex: none; }
  .side nav a.on { border-bottom-color: var(--primary); }
  .side .foot { display: none; }
  main { padding: 20px 16px 60px; }
}

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--line); padding: 20px; margin-bottom: 16px; }
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); padding: 16px 18px; }
.kpi .k { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 700; color: var(--brand-dark); font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.kpi a { color: inherit; text-decoration: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; font-weight: 600; font-size: 13px; line-height: 1.2;
  border: 1px solid var(--line-strong); background: #fff; color: var(--brand-dark); cursor: pointer; text-decoration: none; transition: border-color .15s, color .15s, background .15s; min-height: 36px; }
.btn:hover { border-color: var(--primary); color: var(--primary-hover); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 5px 10px; min-height: 30px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border: 1px solid; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: #a7f3d0; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: #fde68a; }
.badge.bad { color: var(--bad); background: var(--bad-soft); border-color: #fecaca; }
.badge.off { color: var(--ink-soft); background: #f8fafc; border-color: var(--line); }
.badge.info { color: #0369a1; background: var(--primary-soft); border-color: #bae6fd; }

.alert { padding: 12px 14px; border: 1px solid; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert.ok { background: var(--ok-soft); border-color: #a7f3d0; color: #065f46; }
.alert.bad { background: var(--bad-soft); border-color: #fecaca; color: #991b1b; }
.alert.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.alert.info { background: var(--primary-soft); border-color: #bae6fd; color: #075985; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f8fafc; }
table.list td.r, table.list th.r { text-align: right; }
table.list .main { font-weight: 600; color: var(--brand-dark); text-decoration: none; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.empty { padding: 28px 10px; text-align: center; color: var(--ink-soft); }

dl.facts { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Formulare ---------- */
.form-row { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 6px 20px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.form-row:last-of-type { border-bottom: none; }
.form-row > label { font-weight: 600; color: var(--brand-dark); padding-top: 8px; }
.form-row .help { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } .form-row > label { padding-top: 0; } }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); background: #fff; min-height: 38px; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,172,226,.15); }
textarea { min-height: 200px; resize: vertical; line-height: 1.55; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; min-height: 120px; }
.check { display: flex; gap: 8px; align-items: center; padding-top: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.tabs { display: flex; border-bottom: 1px solid var(--line-strong); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: 10px 16px; font-weight: 600; color: var(--ink-soft); text-decoration: none; border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on, .tabs button.on { color: var(--brand-dark); border-bottom-color: var(--primary); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }
.pill { padding: 6px 12px; border: 1px solid var(--line-strong); background: #fff; font-weight: 600; font-size: 13px; color: var(--ink-soft); text-decoration: none; }
.pill.on { border-color: var(--primary); color: var(--brand-dark); background: var(--primary-soft); }

/* ---------- Diagramme ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--sans); fill: var(--ink-soft); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bars .row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr 52px; gap: 10px; align-items: center; font-size: 13px; }
.bars .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { height: 10px; background: #f1f5f9; }
.bars .fill { height: 100%; background: var(--series-1); }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--brand-dark); }

/* ---------- Kalkulation (übernommen aus tools/anfragen/regeln.html) ---------- */
.schema-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1000px) { .schema-layout { grid-template-columns: 260px 1fr; align-items: start; } }
.slist { background: #fff; border: 1px solid var(--line); }
.slist button { display: flex; justify-content: space-between; gap: 8px; width: 100%; border: none; border-bottom: 1px solid var(--line); background: #fff; padding: 11px 14px; cursor: pointer; text-align: left; }
.slist button:hover { background: #f8fafc; }
.slist button.on { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.slist .n { font-weight: 600; color: var(--brand-dark); }
.slist .v { color: var(--ink-soft); font-size: 12.5px; }
.slist .v.bad { color: var(--bad); font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.field .sub { font-size: 11.5px; color: var(--ink-faint); }
table.rows { width: 100%; border-collapse: collapse; }
.rows th { font-size: 12px; text-align: left; color: var(--ink-soft); font-weight: 600; padding: 6px 6px 6px 0; border-bottom: 1px solid var(--line); }
.rows td { padding: 5px 6px 5px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rows td.r, .rows th.r { text-align: right; }
.rows .x { border: none; background: none; color: var(--ink-faint); cursor: pointer; font-size: 18px; padding: 0 6px; }
.rows .x:hover { color: var(--bad); }
.bar { height: 6px; background: var(--line); position: relative; min-width: 60px; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--primary); }
.summary { display: flex; flex-wrap: wrap; gap: 22px; margin: 14px 0 4px; align-items: center; }
.summary .kpi { border: none; padding: 0; }
.summary .kpi .v { font-size: 18px; }
.summary .kpi .v.bad { color: var(--bad); }
.matrix-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); }
.matrix { border-collapse: collapse; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 3px 4px; white-space: nowrap; }
.matrix th { position: sticky; top: 0; background: #f8fafc; font-size: 12px; text-align: left; z-index: 1; }
.matrix td:first-child, .matrix th:first-child { position: sticky; left: 0; background: #fff; font-weight: 600; z-index: 2; }
.matrix th:first-child { background: #f8fafc; z-index: 3; }
.matrix input { width: 64px; min-height: 30px; padding: 4px 6px; border: 1px solid var(--line); text-align: right; }
.matrix input.diff { background: #fffbeb; border-color: #fcd34d; }
.matrix .ref { color: var(--ink-soft); font-size: 12px; }
.matrix .ref span { border-bottom: 1px dotted var(--ink-faint); cursor: help; }
.sources { font-size: 12.5px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
.pane { display: none; }
.pane.on { display: block; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--brand-dark); color: #fff; padding: 12px 20px; display: flex; justify-content: center; gap: 12px; align-items: center;
  transform: translateY(100%); transition: transform .25s; z-index: 20; }
.savebar.show { transform: none; }
.savebar .btn { border-color: #fff; }
.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--brand-dark); color: #fff; padding: 10px 16px; font-weight: 600;
  transition: .25s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; border-top: 3px solid var(--primary); padding: 28px; }
.auth img { height: 40px; margin-bottom: 18px; }
.auth h1 { margin-bottom: 4px; }
.auth p { color: var(--ink-soft); margin-bottom: 18px; }
.auth label { display: block; font-weight: 600; margin: 12px 0 4px; }
.auth .btn { width: 100%; margin-top: 18px; }

iframe.mail-preview { width: 100%; height: 560px; border: 1px solid var(--line); background: #f1f5f9; }
pre.mail-text { white-space: pre-wrap; font-family: var(--sans); background: #f8fafc; border: 1px solid var(--line); padding: 14px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.lead { color: var(--ink-soft); margin-bottom: 14px; max-width: 80ch; }
.hint { font-size: 12px; color: var(--ink-faint); }
.status-list { list-style: none; }
.status-list li { display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; gap: 4px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.status-list li:last-child { border-bottom: none; }
@media (max-width: 640px) { .status-list li { grid-template-columns: 1fr auto; } .status-list li .muted { grid-column: 1 / -1; grid-row: 2; } }
