:root {
  --bg: #f7f7f5; --fg: #1c1c1a; --muted: #6b6b66; --border: #ddd9d0;
  --accent: #2f6f4f; --accent-fg: #fff; --danger: #a4342f; --card: #fff;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17181a; --fg: #e8e6e1; --muted: #9a9890; --border: #33352f;
          --accent: #4f9c76; --accent-fg: #0b120d; --danger: #d9615c; --card: #202224; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--fg); }
.topnav { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; padding: .75rem 1.5rem;
          border-bottom: 1px solid var(--border); background: var(--card); align-items: center; }
.topnav a { color: var(--fg); text-decoration: none; }
.topnav a.brand { font-weight: 700; }
.topnav a:hover { color: var(--accent); }
.content { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
h1 { margin-top: 0; }
.muted { color: var(--muted); }
.stat-row { display: flex; gap: 1rem; margin: 1rem 0 2rem; flex-wrap: wrap; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: 8px;
             padding: 1rem 1.5rem; min-width: 140px; }
.stat-num { font-size: 2rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }
.table { width: 100%; border-collapse: collapse; margin: .5rem 0 1.5rem;
         display: block; overflow-x: auto; max-width: 100%; }
.table th, .table td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv th { text-align: left; vertical-align: top; padding: .3rem .8rem .3rem 0; color: var(--muted); }
.kv td { padding: .3rem 0; }
pre.json, pre.report-md { background: var(--card); border: 1px solid var(--border); border-radius: 6px;
     padding: .75rem; overflow-x: auto; font-size: .85rem; }
form { margin: .5rem 0 1rem; }
label { display: inline-flex; flex-direction: column; gap: .2rem; margin: .3rem .6rem .3rem 0;
        font-size: .85rem; color: var(--muted); vertical-align: top; }
input, select, button { font: inherit; padding: .35rem .5rem; border-radius: 6px; border: 1px solid var(--border);
       background: var(--card); color: var(--fg); }
button { cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-secondary { background: transparent; }
.run-panel { margin: 1.5rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.run-grid { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.run-form { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0; padding: .5rem;
            border: 1px dashed var(--border); border-radius: 6px; max-width: 100%; }
.run-form input[type="number"] { width: 6rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; }
.badge-running { background: #e8c04a33; color: #a67c00; }
.badge-done { background: #2f6f4f33; color: var(--accent); }
.badge-error { background: #a4342f33; color: var(--danger); }
.err { color: var(--danger); white-space: pre-wrap; }
.filter-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.pager { display: flex; gap: 1rem; align-items: center; }
.suggestion-card { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; background: var(--card); }
#llm-preview { margin-top: 1rem; }
#job-live { margin-top: .75rem; font-size: .9rem; }

/* Dashboard-Cockpit */
.intro { max-width: 70ch; line-height: 1.5; }
.stat-tile.stat-good { border-color: var(--accent); }
.stat-tile.stat-warn { border-color: #b8860b; }
.stat-tile.stat-locked { border-color: var(--muted); }
.stat-row-small .stat-tile { padding: .6rem 1rem; }
.stat-row-small .stat-num { font-size: 1.3rem; }
.badge-locked { background: #6b6b6633; color: var(--muted); }
.badge-warn { background: #e8c04a33; color: #a67c00; margin-left: .3rem; }
.checkbox-inline { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.checkbox-inline input { flex: none; }

/* Explorer-artige Review-Seite: eigenes Layout, kein zentriertes .content */
body.review-page .content { max-width: none; padding: 0; height: calc(100vh - 53px); display: flex; }
.review-shell { display: flex; flex-direction: column; width: 100%; height: 100%; }
.review-topbar { border-bottom: 1px solid var(--border); background: var(--card); padding: .6rem 1rem; flex: none; }
.topbar-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin: 0; }
.topbar-form label.grow { flex: 1 1 420px; }
.topbar-form label.grow input { width: 100%; }
.review-body { flex: 1; display: grid; grid-template-columns: 300px 1fr 320px; min-height: 0; }
.review-list { border-right: 1px solid var(--border); overflow-y: auto; padding: .75rem; }
.review-preview { overflow: auto; background: #00000008; display: flex; align-items: stretch; }
.review-info { border-left: 1px solid var(--border); overflow-y: auto; padding: .75rem; }
.filter-form-compact { display: flex; gap: .4rem; margin-bottom: .5rem; }
.filter-form-compact input, .filter-form-compact select { flex: 1; min-width: 0; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { border-radius: 6px; }
.doc-list li.active { background: var(--accent); }
.doc-list li.active a { color: var(--accent-fg); }
.doc-list a { display: block; padding: .4rem .5rem; text-decoration: none; color: var(--fg); border-radius: 6px; }
.doc-list a:hover { background: var(--border); }
.doc-name { display: block; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { display: block; font-size: .75rem; color: var(--muted); }
.doc-list li.active .doc-meta { color: var(--accent-fg); opacity: .85; }
.doc-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.doc-text { width: 100%; margin: 0; padding: 1rem; white-space: pre-wrap; }
.center { margin: auto; text-align: center; }
.ref-form label { display: block; }

/* Explorer (virtuelle Ordner + Staging) */
body.explorer-page .content { max-width: none; padding: 0; height: calc(100vh - 53px); display: flex; }
.explorer-shell { display: flex; flex-direction: column; width: 100%; height: 100%; }
.explorer-topbar { border-bottom: 1px solid var(--border); background: var(--card); padding: .6rem 1rem; flex: none;
                   display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.explorer-body { flex: 1; display: grid; grid-template-columns: 220px minmax(480px, 3fr) minmax(360px, 2fr); min-height: 0; }
.explorer-tree { border-right: 1px solid var(--border); overflow-y: auto; padding: .75rem; }
.explorer-middle { overflow-y: auto; padding: 0; display: flex; flex-direction: column; min-height: 0; }
.explorer-list { overflow-y: auto; flex: 1 1 auto; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.explorer-detail { padding: .75rem; overflow-y: auto; flex: none; max-height: 55%; }
.name-row { display: flex; gap: 1rem; align-items: flex-end; margin: .3rem 0; }
.name-row label { margin: 0; }
.name-row label.grow { flex: 1 1 auto; }
.name-row label.grow input { width: 100%; box-sizing: border-box; }
.namen-suche-wrap { position: relative; margin: .3rem 0 .6rem; }
.namen-suche-wrap input { width: 100%; box-sizing: border-box; }
.namen-suche-liste { list-style: none; margin: 0; padding: 0; position: absolute; z-index: 5;
                     left: 0; right: 0; background: var(--card); border: 1px solid var(--border);
                     border-radius: 6px; max-height: 340px; overflow-y: auto; }
.namen-suche-liste:empty { display: none; }
.namen-suche-liste li { padding: .35rem .6rem; cursor: pointer; font-size: .85rem; border-bottom: 1px solid var(--border); }
.namen-suche-liste li:last-child { border-bottom: none; }
.namen-suche-liste li:hover { background: var(--accent); color: var(--accent-fg); }
.namen-suche-typ { font-weight: 600; color: var(--muted); }
.buchung-info-row { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.buchung-col { flex: 1 1 300px; min-width: 260px; }
.info-col { flex: 1 1 260px; min-width: 240px; }
.info-col table.kv { width: 100%; table-layout: fixed; }
.info-col table.kv th { width: 42%; }
.info-col table.kv td { word-break: break-word; }
.explorer-preview { border-left: 1px solid var(--border); overflow: auto; background: #00000008;
                    display: flex; align-items: stretch; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list li { margin: .1rem 0; display: flex; align-items: center; gap: .15rem; }
.tree-list a { text-decoration: none; color: var(--fg); display: block; padding: .25rem .4rem; border-radius: 6px;
              flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-list a:hover { background: var(--border); }
.tree-actions { display: flex; gap: .1rem; flex: none; opacity: .5; }
.tree-actions:hover { opacity: 1; }
.tree-act { background: none; border: none; cursor: pointer; color: var(--muted); font-size: .75rem;
           padding: .1rem .3rem; border-radius: 4px; line-height: 1.4; }
.tree-act:hover { background: var(--border); color: var(--fg); }
.tree-list a.active { background: var(--accent); color: var(--accent-fg); }
.tree-list .tree-count { color: var(--muted); font-size: .75rem; }
.tree-list.nested { padding-left: 1rem; }
.new-folder-form { display: flex; gap: .3rem; margin-top: .75rem; }
.new-folder-form input { flex: 1; min-width: 0; }
.explorer-list table.table td, .explorer-list table.table th { padding: .3rem .4rem; font-size: .85rem; }
.explorer-list tr.selected { background: var(--accent); color: var(--accent-fg); }
.explorer-list tr.selected a { color: var(--accent-fg); }
.status-chip { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .7rem; }
.status-entwurf { background: #6b6b6633; color: var(--muted); }
.status-freigegeben { background: #e8c04a33; color: #a67c00; }
.status-produktiv { background: #2f6f4f33; color: var(--accent); }
.status-abgelehnt { background: #a4333333; color: #c0392b; }
.konto-list { list-style: none; margin: .3rem 0; padding: 0; }
.konto-list label { display: block; flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; color: var(--fg); }
.konto-list input { width: auto; margin-right: .4rem; }
.radio-row { display: flex; gap: 1rem; margin: .3rem 0; }
.radio-row label { flex-direction: row; align-items: center; gap: .3rem; font-size: .9rem; color: var(--fg); }
.radio-row input { width: auto; }
textarea { font: inherit; width: 100%; border-radius: 6px; border: 1px solid var(--border);
          background: var(--card); color: var(--fg); padding: .4rem .5rem; }
