:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e3e7ef;
  --line2: #eef1f6;
  --text: #1d2433;
  --muted: #667085;
  --accent: #2f5bea;
  --accent-soft: #e9efff;
  --good: #12a150;
  --good-soft: #e6f6ed;
  --warn: #d98a00;
  --warn-soft: #fff4dc;
  --bad: #d92d20;
  --bad-soft: #fdeceb;
  --side: #121a2f;
  --side2: #1b2540;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); overflow: hidden; }
#app { display: flex; height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Sidebar ---------- */
#sidebar { width: 236px; flex-shrink: 0; background: var(--side); color: #cbd3e6; display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 18px; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #4f7cff, #8a5cff); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; opacity: .65; }
#nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; user-select: none; }
.nav-item:hover { background: var(--side2); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; }
.nav-item .count { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 10px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.nav-foot { display: flex; flex-direction: column; gap: 10px; }
.ai-state { font-size: 11.5px; padding: 8px 10px; border-radius: 8px; background: var(--side2); line-height: 1.4; cursor: pointer; }
.ai-state b { color: #fff; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #8a93a8; }
.dot.on { background: #31d07f; }

/* ---------- Main ---------- */
#main { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.page { flex: 1; overflow: auto; padding: 24px 28px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.split { flex: 1; display: grid; min-height: 0; }
.split > * { min-height: 0; overflow: auto; }
.split.three { grid-template-columns: 240px minmax(420px, 1fr) 350px; }
.split.two { grid-template-columns: 300px 1fr; }
.list-pane { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.list-pane .lp-head { padding: 16px 14px 10px; border-bottom: 1px solid var(--line2); }
.list-pane .lp-head h1 { font-size: 18px; margin-bottom: 10px; }
.list-pane .lp-body { flex: 1; overflow: auto; padding: 6px; }
.edit-pane { padding: 20px 24px 40px; }
.side-pane { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }

/* ---------- Elements ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: 13px; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #f6f8fc; border-color: #cfd6e4; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #2549c9; }
.btn.ai { background: linear-gradient(135deg, #5b5cf0, #9a4dff); color: #fff; border-color: transparent; }
.btn.ai:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #f4c2bd; }
.btn.ghost-light { background: transparent; color: #dfe5f3; border-color: rgba(255,255,255,.18); }
.btn.ghost-light:hover { background: var(--side2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--line2); color: var(--text); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 550; }
label.f.full { grid-column: 1 / -1; }
input[type=text], input[type=email], input[type=date], input[type=password], input[type=url], input[type=search], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; font-size: 13.5px; color: var(--text); width: 100%; outline: none; }
input:focus, select:focus, textarea:focus, .rte-body:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
input[type=color] { width: 42px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }

.list-item { padding: 10px 11px; border-radius: 8px; cursor: pointer; margin-bottom: 2px; border: 1px solid transparent; }
.list-item:hover { background: #f5f7fb; }
.list-item.active { background: var(--accent-soft); border-color: #cdd9ff; }
.list-item .li-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--line2); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: #a46700; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ai { background: #f0e9ff; color: #6d3fd8; }

.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; gap: 4px; flex-shrink: 0; }
.tab { padding: 11px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { flex: 1; overflow: auto; padding: 14px 16px 30px; }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 42px; margin-bottom: 8px; }
.empty h2 { color: var(--text); }

/* Findings */
.finding { display: flex; gap: 9px; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; font-size: 13px; line-height: 1.4; background: #f7f8fb; }
.finding .fi { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; font-weight: 700; margin-top: 1px; }
.finding.good { background: var(--good-soft); } .finding.good .fi { background: var(--good); }
.finding.warn { background: var(--warn-soft); } .finding.warn .fi { background: var(--warn); }
.finding.bad { background: var(--bad-soft); } .finding.bad .fi { background: var(--bad); }
.finding.info .fi { background: #8a93a8; }
.finding q { font-style: italic; quotes: '„' '“'; }

.score { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ring { --v: 0; --c: var(--accent); width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--line2) 0); flex-shrink: 0; }
.ring > div { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 750; font-size: 19px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 3px 9px; border-radius: 14px; font-size: 12px; background: var(--line2); }
.chip.ok { background: var(--good-soft); color: #0d7a3c; }
.chip.miss { background: var(--bad-soft); color: #b42318; }

/* KPI */
.kpi { padding: 16px 18px; }
.kpi .v { font-size: 28px; font-weight: 750; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.pipeline { display: flex; height: 12px; border-radius: 8px; overflow: hidden; background: var(--line2); margin: 8px 0 10px; }
.pipeline > div { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line2); cursor: pointer; }
.task:last-child { border-bottom: 0; }
.task .ti { font-size: 18px; width: 24px; text-align: center; }
.task .tt { font-weight: 600; }
.task:hover .tt { color: var(--accent); }

/* Status */
.st { font-size: 11.5px; padding: 2px 8px; border-radius: 12px; font-weight: 600; color: #fff; }

/* Rich text editor */
.rte { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 5px; border-bottom: 1px solid var(--line2); background: #fafbfd; border-radius: 10px 10px 0 0; position: sticky; top: 0; z-index: 2; }
.rte-bar button { border: 0; background: transparent; padding: 4px 8px; border-radius: 6px; cursor: pointer; min-width: 30px; font-size: 13px; }
.rte-bar button:hover { background: var(--line2); }
.rte-bar .sep { width: 1px; background: var(--line); margin: 3px 4px; }
.rte-body { min-height: 300px; padding: 16px 20px; outline: none; line-height: 1.6; font-size: 14.5px; border-radius: 0 0 10px 10px; }
.rte-body p { margin: 0 0 .8em; }
.rte-body.small { min-height: 70px; padding: 8px 12px; font-size: 13.5px; }

/* Preview */
.preview-wrap { background: #e9ecf3; border-radius: 10px; padding: 14px; overflow: hidden; }
.preview-scale { transform-origin: top left; }
.preview-scale iframe { border: 0; width: 820px; display: block; background: #e9ecf3; }

/* File preview */
.file-view { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 10px; background: #f0f2f7; }
.file-img { max-width: 100%; max-height: 520px; display: block; margin: 0 auto; border-radius: 8px; box-shadow: var(--shadow); }
.thumb { height: 140px; background: #f0f2f7; border-radius: 8px 8px 0 0; display: grid; place-items: center; overflow: hidden; font-size: 40px; color: #9aa3b5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-card { padding: 0; cursor: pointer; overflow: hidden; transition: transform .1s, box-shadow .1s; }
.doc-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.1); }
.doc-card .dc-body { padding: 11px 13px; }
.doc-card .dc-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

/* Repeater (CV) */
.rep-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #fcfcfe; }
.rep-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.rep-head b { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-row { display: grid; grid-template-columns: 1fr 120px 30px; gap: 6px; margin-bottom: 6px; align-items: center; }

/* AI output */
.ai-out { border: 1px solid #dccfff; background: #faf7ff; border-radius: 10px; padding: 12px 14px; margin-top: 12px; font-size: 13.5px; line-height: 1.55; max-height: 520px; overflow: auto; white-space: pre-wrap; }
.ai-out.html { white-space: normal; }
.ai-out.loading::after { content: '▍'; animation: blink 1s infinite; color: #7c4dff; }
@keyframes blink { 50% { opacity: 0; } }
.ai-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-actions .btn { justify-content: flex-start; white-space: normal; text-align: left; line-height: 1.25; padding: 8px 10px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner.dark { border-color: rgba(0,0,0,.12); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
#modalRoot .backdrop { position: fixed; inset: 0; background: rgba(15,20,35,.45); display: grid; place-items: center; z-index: 50; animation: fade .12s; }
.modal { background: #fff; border-radius: 14px; width: min(720px, 94vw); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 96vw); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line2); display: flex; align-items: center; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1d2433; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 420px; font-size: 13px; animation: fade .15s; }
.toast.good { background: #0f7a3e; } .toast.bad { background: #b42318; }

/* Drop overlay */
#dropOverlay { position: fixed; inset: 0; background: rgba(47,91,234,.12); border: 3px dashed var(--accent); display: none; place-items: center; z-index: 70; pointer-events: none; }
#dropOverlay.on { display: grid; }
#dropOverlay div { background: #fff; padding: 26px 34px; border-radius: 14px; font-size: 18px; font-weight: 650; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
#dropOverlay small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 6px; }
.dropzone { border: 2px dashed #c9d2e5; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfe; }
.dropzone:hover { border-color: var(--accent); color: var(--accent); }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
table.tbl tr.click { cursor: pointer; }
table.tbl tr.click:hover td { background: #f7f9fc; }

.grade-big { font-size: 44px; font-weight: 800; line-height: 1; }
.timeline { border-left: 2px solid var(--line); padding-left: 14px; margin-left: 6px; }
.timeline div { position: relative; margin-bottom: 10px; font-size: 13px; }
.timeline div::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.md h4 { margin: 12px 0 4px; font-size: 14px; }
.md ul { margin: 4px 0 8px; padding-left: 20px; }
.md p { margin: 0 0 8px; }
.grid > .card + .card { margin-top: 0; }
.auto-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------- Web: Login ---------- */
#loginScreen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: linear-gradient(135deg, #121a2f 0%, #2a3a6e 100%); padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 28px; width: min(400px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-err { color: var(--bad); min-height: 18px; margin-top: 10px; }

/* ---------- Kleine Bildschirme (Web) ---------- */
@media (max-width: 1000px) {
  #sidebar { width: 64px; padding: 12px 8px; }
  .brand { justify-content: center; padding-bottom: 14px; }
  .brand > div:last-child, .nav-item .count, .ai-state, .nav-foot .btn { display: none; }
  .nav-item { justify-content: center; font-size: 0; padding: 10px 0; }
  .nav-item .ico { font-size: 18px; width: auto; }
  .split.three, .split.two { grid-template-columns: 1fr !important; overflow: auto; }
  .split > * { overflow: visible; }
  .list-pane .lp-body { max-height: 220px; }
  .grid.g2, .grid.g3, .grid.g4 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
