:root {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --ink: #23262a;
  --muted: #6b6f75;
  --line: #e2e0d8;
  --accent: #ffdf5c;
  --accent-ink: #363a3c;
  --kunde: #eef3fb;
  --agent: #fff8d9;
  --ok: #1f7a4a;
  --warn-bg: #fff3d6;
  --warn-line: #e8c56a;
  --info-bg: #eef3f8;
  --info-line: #c9d6e4;
  --fehler: #b3261e;
  --code: #f0eee8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17191c;
    --panel: #212428;
    --ink: #e8e6e1;
    --muted: #9a9ea5;
    --line: #34383e;
    --kunde: #22303f;
    --agent: #3a3420;
    --ok: #5fc48d;
    --warn-bg: #3b311a;
    --warn-line: #7a6326;
    --info-bg: #1f2a36;
    --info-line: #34475c;
    --fehler: #ff8a80;
    --code: #2b2f34;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.2px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; margin: 12px 0 6px; }
code, pre { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
code { background: var(--code); padding: 1px 4px; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--code); padding: 10px; border-radius: 8px; overflow: auto; max-height: 360px; }
.muted { color: var(--muted); }
.klein { font-size: 12.5px; }
.pad { padding: 18px; }
.fehler { color: var(--fehler); }
[hidden] { display: none !important; }

button, select, input {
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 11px;
}
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primaer { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.link { border: 0; background: none; padding: 0; text-decoration: underline; color: var(--muted); }
button.klein { padding: 1px 7px; font-size: 12px; }

/* ---------------------------------------------------------- Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  display: grid;
  gap: 12px;
}
.login-card form { display: grid; gap: 12px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { color: var(--ink); }

/* ---------------------------------------------------------- Kopf */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-right: 8px; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); display: inline-block; }
.agent-wahl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.agent-wahl select { color: var(--ink); max-width: 340px; }
.spacer { flex: 1; }
.logout { display: flex; align-items: center; gap: 8px; margin: 0; }

/* ---------------------------------------------------------- Raster */
.grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  align-items: start;
}
.widget-col { position: sticky; top: 70px; display: grid; gap: 8px; }
.widget-box {
  height: min(680px, calc(100vh - 150px));
  min-height: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}
.widget-frame { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.status { font-size: 13px; color: var(--muted); padding: 0 4px; }
.status[data-art="ok"] { color: var(--ok); }
.status[data-art="warn"] { color: #a26b00; }
.status[data-art="fehler"] { color: var(--fehler); }
.hinweis { font-size: 13px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--info-line); background: var(--info-bg); }
.hinweis[data-art="warn"] { border-color: var(--warn-line); background: var(--warn-bg); }

.side { display: grid; gap: 16px; min-width: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  min-width: 0;
}
.card > summary { cursor: pointer; font-weight: 600; }
details > summary { cursor: pointer; margin-top: 10px; color: var(--muted); font-size: 13px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; margin-bottom: 10px; }
.filter, .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.filter select, .filter input { font-size: 13px; padding: 4px 8px; }
.actions button { font-size: 13px; padding: 4px 10px; }

/* ---------------------------------------------------------- Szenario */
.sz-kopf { margin-bottom: 8px; }
.sz-block { margin: 8px 0; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); font-weight: 600; }
blockquote { margin: 4px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--agent); border-radius: 0 8px 8px 0; }
.sz-block ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------------------------------------------------------- Protokoll */
.meta { font-size: 13px; margin-bottom: 10px; overflow-wrap: anywhere; }
.verlauf { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.turn { padding: 8px 12px; border-radius: 12px; max-width: 92%; }
.turn p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.turn .wer { font-size: 12px; font-weight: 600; color: var(--muted); }
.turn.kunde { background: var(--kunde); justify-self: end; }
.turn.agent { background: var(--agent); }
.turn.system { background: var(--code); font-size: 13px; }
.werkzeuge ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 13px; }
.ereignisse { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: 12.5px; display: grid; gap: 2px; }
.ereignisse time { color: var(--muted); }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .widget-col { position: static; }
  .widget-box { height: 620px; }
}
