/* CortexHunter WebUI — ohne externe Ressourcen (strenge CSP). */
:root {
  --bg: #f5f7fb; --panel: #ffffff; --panel2: #f8fafd; --ink: #162033; --muted: #66748b; --line: #e3e8f0;
  --accent: #3b5bdb; --accent-ink: #fff; --accent-soft: #e7ecff;
  --good: #1b8a4b; --good-soft: #e2f5ea; --warn: #b26a00; --warn-soft: #fdf1d9;
  --bad: #c43a2f; --bad-soft: #fce8e5; --info: #2b6aa3; --info-soft: #e4effa;
  --shadow: 0 1px 2px rgba(20,30,60,.05), 0 2px 8px rgba(20,30,60,.05); --r: 12px; --side: 244px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1218; --panel: #161c25; --panel2: #1a212c; --ink: #e6ebf2; --muted: #93a0b3; --line: #262e3a;
    --accent: #7090ff; --accent-ink: #0b1220; --accent-soft: #1c2745;
    --good: #4cc27e; --good-soft: #13281c; --warn: #e3a948; --warn-soft: #2a2211;
    --bad: #f0806f; --bad-soft: #2e1a17; --info: #6db3ee; --info-soft: #13222f; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1218; --panel: #161c25; --panel2: #1a212c; --ink: #e6ebf2; --muted: #93a0b3; --line: #262e3a;
  --accent: #7090ff; --accent-ink: #0b1220; --accent-soft: #1c2745;
  --good: #4cc27e; --good-soft: #13281c; --warn: #e3a948; --warn-soft: #2a2211;
  --bad: #f0806f; --bad-soft: #2e1a17; --info: #6db3ee; --info-soft: #13222f; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
.m0 { margin: 0; } .grow { flex: 1; min-width: 0; } .right { text-align: right; } .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted, .hint { color: var(--muted); } .hint { font-size: 12.5px; } .err { color: var(--bad); }
.num { font-variant-numeric: tabular-nums; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Gerüst */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 10px 14px; }
.brand.big { font-size: 20px; padding: 0 0 8px; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: block; }
.about-head { gap: 18px; } .about-logo { width: 64px; height: 64px; border-radius: 16px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.log { display: grid; } .log-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px; flex-wrap: wrap; } .log-row:last-child { border-bottom: 0; } .nowrap { white-space: nowrap; }
code.wrap { overflow-wrap: anywhere; font-size: 12px; } .sec { font-size: 16px; margin: 8px 0; }
.card.plain { box-shadow: none; }
.nav-label { padding: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; }
#nav a:hover { background: var(--panel2); }
#nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#nav .pill { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 8px; }
.conn { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; }
.dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.main { padding: 24px 28px 90px; max-width: 1240px; width: 100%; margin: 0 auto; min-width: 0; }
.page-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 700; } .lead { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; margin: 4px 0 10px; }
.opt { display: flex; gap: 8px; align-items: baseline; font-size: 14px; } .opt input { flex: none; }
.stack { display: grid; gap: 16px; } .grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } .split { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

/* Bausteine */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px 0; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; font-weight: 650; } .card-body { padding: 14px 18px 18px; }
.kpi { padding: 14px 16px; } .kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; } .kpi-sub { color: var(--muted); font-size: 12.5px; }
.btn { padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; }
.btn:hover { background: var(--panel2); } .btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); } .btn.sm { padding: 4px 10px; font-size: 13px; } .btn.wide { width: 100%; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 4px; border-radius: 7px; color: var(--muted); display: grid; } .icon-btn:hover { background: var(--panel2); color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: inherit; margin-right: 8px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; } .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; } .badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid; }
.notice.ok { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.notice .ic { margin-top: 2px; }
.empty { text-align: center; padding: 26px 14px; color: var(--muted); } .empty-title { font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.loading { padding: 30px; text-align: center; color: var(--muted); } .spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes sp { to { transform: rotate(360deg); } } @media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.meter { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; } .meter > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter.stacked { display: flex; height: 12px; } .meter.stacked > i { border-radius: 0; }

/* Formulare */
.field { display: grid; gap: 5px; margin-bottom: 14px; min-width: 0; } .field-label { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.in { width: 100%; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); min-width: 0; } .in:focus { border-color: var(--accent); }
textarea.in { resize: vertical; min-height: 70px; } .form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; } .sw-in { position: absolute; opacity: 0; pointer-events: none; }
.sw { width: 40px; height: 22px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .15s; margin-top: 1px; }
.sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.sw-in:checked + .sw { background: var(--accent); } .sw-in:checked + .sw::after { transform: translateX(18px); } .sw-in:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text { display: grid; } .toggle-label { font-weight: 600; }
.chipbox { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: text; } .chipbox:focus-within { border-color: var(--accent); }
.chips { display: contents; } .chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: 7px; padding: 2px 4px 2px 9px; font-size: 13px; }
.chip-x { border: 0; background: none; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 4px; } .chip-x:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.chip-in { flex: 1; min-width: 140px; border: 0; background: none; outline: 0; padding: 4px; } .chip-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chip-count { white-space: nowrap; }

/* Tabellen, Tabs, Listen */
.table-wrap { overflow-x: auto; } table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; } td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; } tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); } td.r, th.r { text-align: right; } td.nw { white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; } .tab { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tab.on { color: var(--accent); border-color: var(--accent); } .tab-badge { margin-left: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; font-size: 11px; padding: 0 7px; }
.list { display: grid; gap: 6px; } .list-item { text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; display: grid; gap: 2px; }
.list-item:hover { background: var(--panel2); } .list-item.on { border-color: var(--accent); background: var(--accent-soft); } .list-item .t { font-weight: 650; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); } .check:last-child { border-bottom: 0; }
.check .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; margin-top: 1px; } .check.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.check .tick .ic { width: 13px; height: 13px; stroke-width: 3; } .check a { color: var(--accent); }
.target { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); } .target:last-child { border-bottom: 0; }
.settings-nav { display: grid; gap: 4px; position: sticky; top: 16px; } .settings-nav button { text-align: left; padding: 8px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; } .settings-nav button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 280px); gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; } .setting:last-child { border-bottom: 0; }
.setting .unit { display: flex; gap: 8px; align-items: center; } .setting .unit span { color: var(--muted); white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.result { margin-top: 10px; } .result .notice { margin-bottom: 8px; }
.model-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(220px, 1fr) auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); } .model-row:last-child { border-bottom: 0; }

/* Dialog, Drawer, Meldungen, Speicherleiste */
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--ink); width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 70px rgba(0,0,0,.35); } .dlg.wide { width: min(760px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(8,12,20,.55); } .dlg > header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg h3 { font-size: 16px; } .dlg-body { padding: 16px 18px; max-height: 70vh; overflow: auto; } .dlg > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel2); border-radius: 0 0 14px 14px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0,0,0,.25); z-index: 30; display: flex; flex-direction: column; }
.drawer > header { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; } .drawer-body { padding: 16px 18px; overflow: auto; flex: 1; display: grid; gap: 14px; align-content: start; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(400px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); } .toast.err { background: var(--bad); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
.savebar { position: fixed; left: var(--side); right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 12px 28px; display: flex; gap: 10px; align-items: center; z-index: 20; box-shadow: 0 -6px 20px rgba(0,0,0,.08); }
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; } .login { width: min(420px, 100%); padding: 26px; display: grid; gap: 4px; }

@media (max-width: 980px) { .g3, .g2, .split { grid-template-columns: 1fr; } .setting, .model-row { grid-template-columns: 1fr; } .form-row { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; } .side { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  #nav { display: flex; gap: 4px; } .nav-label, .side-foot .hint, .conn { display: none; } .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; } #nav a { white-space: nowrap; }
  .main { padding: 16px 14px 90px; } .savebar { left: 0; padding: 12px 14px; }
}
