:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #dfe1e6;
  --text: #16171a;
  --text-2: #4e5058;
  --muted: #80848e;
  --accent: #5865f2;
  --accent-ink: #ffffff;
  --accent-soft: #eceefe;
  --ok: #1a7f4b;
  --ok-soft: #e3f5ea;
  --warn: #a15c00;
  --warn-soft: #fff2dc;
  --bad: #c62828;
  --bad-soft: #fde8e8;
  --series-1: #2a78d6;
  --grid: #e8e9ed;
  --shadow: 0 1px 2px rgba(16, 17, 20, 0.06), 0 4px 16px rgba(16, 17, 20, 0.05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #111214;
    --surface: #1a1b1e;
    --surface-2: #232428;
    --border: #2e3035;
    --text: #f2f3f5;
    --text-2: #b5bac1;
    --muted: #8a8e97;
    --accent: #6d78f5;
    --accent-ink: #ffffff;
    --accent-soft: #262a4a;
    --ok: #4fc27f;
    --ok-soft: #173424;
    --warn: #f0a93b;
    --warn-soft: #3a2c12;
    --bad: #f26b6b;
    --bad-soft: #3d1c1c;
    --series-1: #3987e5;
    --grid: #2a2c31;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111214;
  --surface: #1a1b1e;
  --surface-2: #232428;
  --border: #2e3035;
  --text: #f2f3f5;
  --text-2: #b5bac1;
  --muted: #8a8e97;
  --accent: #6d78f5;
  --accent-ink: #ffffff;
  --accent-soft: #262a4a;
  --ok: #4fc27f;
  --ok-soft: #173424;
  --warn: #f0a93b;
  --warn-soft: #3a2c12;
  --bad: #f26b6b;
  --bad-soft: #3d1c1c;
  --series-1: #3987e5;
  --grid: #2a2c31;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { padding: 12px 20px; font-size: 15px; width: 100%; margin-top: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Einzelseiten (Login, Verifizierung) ── */
.page-center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.narrow { width: 100%; max-width: 480px; padding: 28px; }
.card.narrow h1 { margin-bottom: 6px; }
.card.narrow p { color: var(--text-2); margin: 6px 0; }
.lang { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.lang h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.facts { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
.facts li { margin: 2px 0; }
.hint { font-size: 12px; color: var(--muted) !important; margin-top: 14px !important; }
.badge-icon {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; font-weight: 700; margin-bottom: 14px;
}
.badge-icon.ok { background: var(--ok-soft); color: var(--ok); }
.badge-icon.bad { background: var(--bad-soft); color: var(--bad); }

/* ── App-Layout ── */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand img { width: 32px; height: 32px; border-radius: 50%; }
.brand b { font-size: 15px; }
.guild-select { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button[aria-current='page'] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ico { width: 18px; height: 18px; }
.user-box { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px; border-top: 1px solid var(--border); }
.user-box img { width: 30px; height: 30px; border-radius: 50%; }
.user-box .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; }

.main { padding: 24px 28px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--accent-soft); color: var(--accent); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.section { margin-bottom: 16px; }
.section > .card > h2 { margin-bottom: 4px; }
.section > .card > .desc { color: var(--text-2); margin: 0 0 12px; font-size: 13px; }

/* ── KPI-Kacheln ── */
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }

/* ── Formularfelder ── */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.field.stack { flex-direction: column; align-items: stretch; }
.field .lbl { min-width: 0; }
.field .lbl b { font-weight: 500; display: block; }
.field .lbl small { color: var(--muted); font-size: 12px; display: block; }
.field input[type='number'], .field select, .field input[type='text'], .field textarea {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); min-width: 0;
}
.field input[type='number'] { width: 96px; text-align: right; }
.field input[type='time'] { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.field select { max-width: 240px; }
.field textarea { width: 100%; min-height: 64px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.field.error input, .field.error select, .field.error textarea { border-color: var(--bad); }
.field .err { color: var(--bad); font-size: 12px; }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: 0.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--bad); }
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.add-row select, .add-row input { flex: 1; min-width: 0; }

/* ── Modul-Kacheln ── */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.module { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.module .txt { flex: 1; min-width: 0; }
.module .txt b { display: block; }
.module .txt small { color: var(--muted); font-size: 12px; }

/* ── Tabellen & Listen ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.events { display: flex; flex-direction: column; }
.event { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.event:last-child { border-bottom: 0; }
.event .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--muted); }
.event .dot.danger { background: var(--bad); }
.event .dot.warn { background: var(--warn); }
.event .dot.ok { background: var(--ok); }
.event .dot.info { background: var(--accent); }
.event .t { color: var(--muted); font-size: 12px; white-space: nowrap; }
.event .d { color: var(--text-2); font-size: 12px; word-break: break-word; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }
.findings { list-style: none; padding: 0; margin: 0; }
.findings li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.findings li:last-child { border-bottom: 0; }
.findings .ic { width: 22px; flex: none; text-align: center; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-cell img { width: 22px; height: 22px; border-radius: 50%; }

/* ── Diagramm ── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.active { filter: brightness(1.15); }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 150px; z-index: 5;
  transform: translate(-50%, calc(-100% - 10px));
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); }
.tooltip .row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.score-ring { display: flex; align-items: center; gap: 14px; }
.score-ring svg { width: 64px; height: 64px; flex: none; }
.score-ring .track { stroke: var(--surface-2); }

/* ── Toast & Dialog ── */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500;
  transition: all 0.2s; z-index: 50; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; max-width: 440px; width: calc(100% - 32px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog p { color: var(--text-2); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Login ── */
.login h1 { margin: 6px 0 4px; }
.login .features { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 6px; color: var(--text-2); }

@media (max-width: 960px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 16px 16px 60px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .field { flex-wrap: wrap; }
  .field select { max-width: 100%; }
}

/* ── Eigene Icons ── */
.icon {
  width: 18px; height: 18px; flex: none; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon.sm { width: 15px; height: 15px; }
.icon.accent, .info-ic { color: var(--accent); }
.ok-ic { color: var(--ok); }
.warn-ic { color: var(--warn); }
.bad-ic { color: var(--bad); }
.muted-ic { color: var(--muted); }
.with-icon { display: inline-flex; align-items: center; gap: 8px; }
h2.with-icon { display: flex; gap: 10px; }
.label .with-icon { gap: 6px; }
.btn .icon { width: 16px; height: 16px; }
.pill .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.icon-badge {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.icon-badge .icon { width: 20px; height: 20px; }
.event { grid-template-columns: 30px 1fr auto; }
.ev-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.ev-icon .icon { width: 15px; height: 15px; }
.ev-icon.danger { background: var(--bad-soft); color: var(--bad); }
.ev-icon.warn { background: var(--warn-soft); color: var(--warn); }
.ev-icon.ok { background: var(--ok-soft); color: var(--ok); }
.ev-icon.info { background: var(--accent-soft); color: var(--accent); }
.banner { display: flex; align-items: flex-start; gap: 10px; }
.banner .icon { margin-top: 1px; }
.findings .icon { margin-top: 1px; }
.badge-icon .icon { width: 26px; height: 26px; }
.chip button { display: inline-grid; place-items: center; }
.chip button .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-toggle { padding: 6px 8px; vertical-align: middle; }
.tooltip .row .with-icon { gap: 6px; }
.lang-chip {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; padding: 1px 6px;
  border-radius: 4px; background: var(--surface-2); color: var(--text-2); margin-right: 6px; vertical-align: 1px;
}
.lang h2 { color: var(--text-2); }
.facts { list-style: none; padding-left: 0; }
.facts li { display: flex; gap: 8px; align-items: flex-start; }
.facts .icon { width: 16px; height: 16px; color: var(--ok); margin-top: 2px; }
