:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --fg: #171a20;
  --muted: #626977;
  --line: #e3e6eb;
  --soft: #f0f2f5;
  --brand: #0f766e;
  --brand-fg: #ffffff;
  --brand-soft: #e6f4f2;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a20; --fg: #e8eaee; --muted: #9aa1ad; --line: #272b33; --soft: #1e2128;
    --brand: #2dd4bf; --brand-fg: #062a26; --brand-soft: #12302d; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a20; --fg: #e8eaee; --muted: #9aa1ad; --line: #272b33; --soft: #1e2128;
  --brand: #2dd4bf; --brand-fg: #062a26; --brand-soft: #12302d; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 750; letter-spacing: .04em; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-fg); display: grid; place-items: center; font-size: 15px; }
.logo small { display: block; font-weight: 500; letter-spacing: 0; color: var(--muted); font-size: 12px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--fg); text-decoration: none; font-weight: 500; }
.nav:hover { background: var(--soft); }
.nav[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.nav .count { margin-left: auto; background: var(--brand); color: var(--brand-fg); border-radius: 999px; font-size: 11.5px; padding: 0 7px; font-weight: 650; }
.side-foot { margin-top: auto; font-size: 12.5px; color: var(--muted); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.sub { color: var(--muted); margin-top: 4px; }
.crumb { color: var(--muted); text-decoration: none; font-size: 13px; }

/* Bausteine */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; 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(4, minmax(0, 1fr)); }
.kpi .v { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .h { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.tab { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tab[aria-current="page"] { color: var(--fg); border-color: var(--brand); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 34px 12px; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--fg); border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .nav:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

label.field, div.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13.5px; }
label.field .hint, div.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input[type="color"] { padding: 2px; height: 38px; width: 64px; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form { display: flex; flex-direction: column; gap: 14px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--soft); }
.tbl { overflow-x: auto; }

.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.badge.brand { color: var(--brand); background: var(--brand-soft); }

.code { position: relative; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all; }
.code .btn { position: absolute; top: 8px; right: 8px; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; position: relative; }
.bars div:hover { opacity: 1; }
.bars-x { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

.transcript { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--brand); color: var(--brand-fg); border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--soft); border-bottom-left-radius: 4px; }
.bubble time { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }

.hours { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; align-items: center; }
.hours .iv { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hours input[type="time"] { width: 118px; }
.svc-row { display: grid; grid-template-columns: 1.6fr 90px 1fr 2fr auto; gap: 8px; align-items: start; }
.svc-head { font-size: 12px; color: var(--muted); font-weight: 600; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .panel { width: 100%; max-width: 400px; }
.auth .logo { padding: 0 0 16px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 10; font-weight: 500; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); color: #fff; }

.hidden { display: none !important; }

/* Wirkungsbericht drucken / als PDF speichern */
@media print {
  .side, .tabs, .crumb, .btn, form .actions, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .panel { break-inside: avoid; box-shadow: none; }
  body { background: #fff; color: #000; }
}

/* Eingebettet in der FLOWPARI-Verwaltung */
.embedded .side { height: 100vh; }
.embedded .side .logo, .embedded .hide-embedded { display: none !important; }
.embedded .main { padding-top: 20px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .logo { padding: 4px 10px; width: 100%; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 48px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .svc-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .hours { grid-template-columns: 1fr; }
}
