:root {
  --bg: #0f1720;
  --bg2: #151f2b;
  --card: #1b2734;
  --card2: #223141;
  --line: #2c3d4f;
  --text: #e7edf3;
  --muted: #9fb0c0;
  --accent: #3b82f6;
  --green: #22c55e;
  --green-bg: #103021;
  --red: #ef4444;
  --red-bg: #331617;
  --amber: #f59e0b;
  --amber-bg: #33260a;
  --info: #38bdf8;
  --info-bg: #0e2733;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #16233200, #0f1720), var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #16222f, #121b26);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, #2563eb, #22c55e);
  display: grid; place-items: center; font-size: 22px; font-weight: 700; color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
}
h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.engine-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #6b7280; }
.dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.bad { background: var(--red); box-shadow: 0 0 8px var(--red); }

main { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }

/* Tabs */
.tabs { max-width: 1080px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; color: var(--muted); font-size: 14.5px; font-weight: 600; padding: 14px 18px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* Dokumentation */
.docs-intro { margin-bottom: 6px; }
.doc-ref-inline { color: var(--accent); font-weight: 600; }
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 8px 0 24px; }
.doc-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.doc-card:hover { border-color: #38506a; }
.doc-top { display: flex; align-items: center; justify-content: space-between; }
.doc-icon { font-size: 22px; }
.doc-badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #1c2b3a; border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; }
.doc-title { font-size: 15.5px; font-weight: 700; }
.doc-desc { font-size: 13px; color: var(--muted); line-height: 1.45; flex: 1; }
.doc-covers { font-size: 11.5px; color: var(--muted); }
.doc-covers b { color: #b9c8d6; }
.doc-open { display: inline-block; margin-top: 4px; align-self: flex-start; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.doc-open:hover { filter: brightness(1.1); }

/* Markdown-Reader */
.doc-reader { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 24px; overflow: hidden; }
.reader-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card2); font-weight: 700; }
.reader-body { padding: 8px 22px 22px; max-height: 620px; overflow: auto; }
.markdown { font-size: 14px; line-height: 1.6; color: var(--text); }
.markdown h1 { font-size: 22px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-top: 24px; }
.markdown h2 { font-size: 18px; margin-top: 22px; }
.markdown h3 { font-size: 15.5px; margin-top: 18px; }
.markdown a { color: var(--accent); }
.markdown code { background: #0d1620; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: 12.5px; font-family: Consolas, monospace; }
.markdown pre { background: #0d1620; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }
.markdown pre code { border: none; padding: 0; }
.markdown table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.markdown th { background: var(--card2); }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 4px 14px; color: var(--muted); }

/* Fundstellen-Tabelle */
.ref-table { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ref-row { display: grid; grid-template-columns: 1.6fr 1.4fr 1.4fr; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #223040; align-items: center; font-size: 13.5px; }
.ref-row:last-child { border-bottom: none; }
.ref-head { background: var(--card2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.ref-fam { display: flex; align-items: center; gap: 8px; }
.ref-row a { color: var(--accent); text-decoration: none; }
.ref-row a:hover { text-decoration: underline; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-align: left; }

/* Doku-Verweis an der Regel */
.doc-ref { font-size: 11.5px; color: var(--muted); white-space: nowrap; padding-left: 10px; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.doc-ref:hover { color: var(--accent); border-color: var(--accent); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line); border-radius: 16px;
  background: var(--bg2); padding: 46px 24px; text-align: center;
  cursor: pointer; transition: .18s border-color, .18s background, .18s transform;
}
.dropzone:hover { border-color: var(--accent); background: #17222f; }
.dropzone.drag { border-color: var(--green); background: #14241c; transform: scale(1.005); }
.dz-icon { font-size: 34px; color: var(--accent); }
.dz-title { font-size: 18px; font-weight: 600; margin: 10px 0 4px; }
.dz-hint { color: var(--muted); font-size: 13.5px; margin: 0; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

/* Loading / error */
.loading { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 30px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: var(--red-bg); border: 1px solid var(--red); color: #ffd7d7; padding: 16px 18px; border-radius: var(--radius); margin-top: 18px; }
.hidden { display: none !important; }

/* Banner */
.result { margin-top: 24px; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow); flex-wrap: wrap;
}
.banner.valid { background: linear-gradient(135deg, #0e2b1c, #123a26); border: 1px solid #1e6b45; }
.banner.invalid { background: linear-gradient(135deg, #331416, #401a1c); border: 1px solid #8a2b2f; }
.banner.warn { background: linear-gradient(135deg, #33280a, #3d2f0c); border: 1px solid #8a6a1f; }
.banner-main { display: flex; align-items: center; gap: 18px; }
.banner-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 700; flex: none; }
.banner.valid .banner-icon { background: var(--green); color: #04220f; }
.banner.invalid .banner-icon { background: var(--red); color: #2a0708; }
.banner.warn .banner-icon { background: var(--amber); color: #2a1e04; }
.banner-title { font-size: 22px; font-weight: 700; }
.banner-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.banner-counts { display: flex; gap: 10px; flex-wrap: wrap; }
.pill { padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.pill.g { background: var(--green-bg); color: #86efac; border: 1px solid #1e6b45; }
.pill.r { background: var(--red-bg); color: #fca5a5; border: 1px solid #8a2b2f; }
.pill.a { background: var(--amber-bg); color: #fcd34d; border: 1px solid #8a6a1f; }
.pill.i { background: var(--info-bg); color: #7dd3fc; border: 1px solid #1d5f7a; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 20px 0 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.card-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.card-val { font-size: 14.5px; font-weight: 600; word-break: break-word; }

.section-title { font-size: 16px; margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

/* Steps */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.step .mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 15px; }
.step.ok .mark { background: var(--green-bg); color: var(--green); border: 1px solid #1e6b45; }
.step.bad .mark { background: var(--red-bg); color: var(--red); border: 1px solid #8a2b2f; }
.step-name { font-weight: 600; }
.step-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* Kriterien header + filters */
.crit-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.filters { display: flex; align-items: center; gap: 14px; }
.switch { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
#search { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; color: var(--text); font-size: 13.5px; min-width: 220px; }
#search:focus { outline: none; border-color: var(--accent); }
.crit-note { color: var(--muted); font-size: 12.5px; margin: 2px 0 14px; }

/* Groups */
.groups { display: flex; flex-direction: column; gap: 10px; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.group-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; user-select: none; }
.group-head:hover { background: var(--card2); }
.chev { transition: transform .18s; color: var(--muted); font-size: 12px; }
.group.open .chev { transform: rotate(90deg); }
.group-title { font-weight: 600; font-size: 14.5px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #23303f; border: 1px solid var(--line); color: var(--muted); }
.src { font-size: 10.5px; padding: 2px 7px; border-radius: 6px; background: #1c2b3a; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.group-counts { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.mini { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.mini.g { background: var(--green-bg); color: #86efac; }
.mini.r { background: var(--red-bg); color: #fca5a5; }
.mini.a { background: var(--amber-bg); color: #fcd34d; }
.mini.i { background: var(--info-bg); color: #7dd3fc; }
.group-body { display: none; border-top: 1px solid var(--line); }
.group.open .group-body { display: block; }

.rule { display: flex; gap: 12px; padding: 11px 16px; border-bottom: 1px solid #223040; }
.rule:last-child { border-bottom: none; }
.rule .rmark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 13px; margin-top: 1px; }
.rule.passed .rmark { background: var(--green-bg); color: var(--green); }
.rule.failed .rmark { background: var(--red-bg); color: var(--red); }
.rule.warning .rmark { background: var(--amber-bg); color: var(--amber); }
.rule.info .rmark { background: var(--info-bg); color: var(--info); }
.rule.failed { background: #24141557; }
.rule.warning { background: #2a220a40; }
.rbody { flex: 1; min-width: 0; }
.rid { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; color: #cfe0f0; background: #1a2735; border: 1px solid var(--line); padding: 1px 7px; border-radius: 5px; margin-right: 8px; }
.rtext { font-size: 13.5px; }
.rmsg { margin-top: 6px; font-size: 12.5px; color: #ffc9c9; background: #2a1416; border: 1px solid #5b2529; border-radius: 8px; padding: 8px 10px; }
.rule.warning .rmsg { color: #fde3a7; background: #2a2109; border-color: #5b4a1a; }
.rule.info .rmsg { color: #b8e6fb; background: #0e2431; border-color: #1d5f7a; }
.rmsg .xpath { display: block; margin-top: 4px; font-family: Consolas, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }

/* Regel aufklappbar -> zugehörige Rechnungsfelder */
.rhead { display: flex; align-items: baseline; gap: 0; flex-wrap: wrap; }
.rhead .rtext { flex: 1 1 200px; }
.rule.expandable .rhead { cursor: pointer; }
.rtoggle { margin-left: auto; font-size: 12px; color: var(--accent); white-space: nowrap; padding-left: 10px; }
.rule.expandable:hover .rtoggle { text-decoration: underline; }
.rdetail { margin-top: 8px; }
.fpanel-inner { background: #0d1620; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.frow { display: flex; align-items: center; gap: 10px; padding: 7px 11px; border-bottom: 1px solid #16202b; font-size: 13px; }
.frow:last-child { border-bottom: none; }
.frow.absent { opacity: .7; }
.fcode { font-family: Consolas, monospace; font-size: 11.5px; color: #cfe0f0; background: #1a2735; border: 1px solid var(--line); padding: 1px 7px; border-radius: 5px; flex: none; }
.fname { color: var(--muted); font-size: 12.5px; }
.fval { color: #d6f5df; font-weight: 600; word-break: break-word; }
.frow.present .fcode { border-color: #1e6b45; }
.fgroup { color: var(--muted); font-style: italic; font-size: 12px; }
.frow .jump { margin: 0 0 0 8px; padding: 2px 9px; flex: none; }
.frow .lineno { margin-left: auto; }

/* Zeilennummer-Badge */
.lineno { display: inline-block; font-family: Consolas, monospace; font-size: 11px; color: #7dd3fc; background: #0e2431; border: 1px solid #1d5f7a; border-radius: 5px; padding: 1px 7px; margin-right: 8px; white-space: nowrap; }
.rmsg .lineno { margin-right: 8px; }

/* Hinweis / no-match */
.banner .banner-icon { }
.banner.warn .banner-icon { background: var(--amber); color: #2a1e04; }
.hint-box { background: var(--amber-bg); border: 1px solid #8a6a1f; color: #fde3a7; padding: 14px 16px; border-radius: var(--radius); font-size: 13.5px; margin: 14px 0; }
.mono { font-family: Consolas, "Cascadia Code", monospace; font-size: 12.5px; word-break: break-all; }
.muted-note { color: var(--muted); font-weight: 400; font-size: 12px; }

/* Buttons */
.btn-small { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-weight: 600; }
.btn-small:hover { filter: brightness(1.1); }
.jump { display: inline-block; margin-top: 7px; background: #17303f; color: #7dd3fc; border: 1px solid #1d5f7a; border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.jump:hover { background: #1d3d4f; }

/* Rechnungsinhalt */
.content-view { background: #0d1620; border: 1px solid var(--line); border-radius: var(--radius); max-height: 560px; overflow: auto; font-size: 13px; margin-top: 4px; }
.crow { display: flex; align-items: baseline; border-bottom: 1px solid #16202b; white-space: nowrap; }
.crow:hover { background: #13202c; }
.cline { flex: none; width: 44px; text-align: right; padding: 4px 10px 4px 0; color: #52627a; font-family: Consolas, monospace; font-size: 11px; user-select: none; border-right: 1px solid #1b2837; background: #0a121b; position: sticky; left: 0; }
.cbody { padding: 4px 10px; }
.cname { color: #9ec5ff; font-weight: 600; }
.cval { color: #e7edf3; }
.cattr { color: var(--muted); font-size: 11.5px; font-style: italic; }
.cattr b { color: #cbd5e1; font-style: normal; }
.cempty { color: #44515f; }
.crow.hl { background: #33280a; outline: 2px solid var(--amber); }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 22px; border-top: 1px solid var(--line); }
.foot a { color: var(--accent); }

@media (max-width: 620px) {
  .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .banner { flex-direction: column; align-items: flex-start; }
}
