/* Backstage – Kundenportal im SP-Services-Design (dunkler Kopf, Limette als Akzent) */
:root {
  --bg: #f2f3ef;
  --panel: #ffffff;
  --ink: #1d211c;
  --muted: #5a6058;
  --line: #dfe3dc;
  --dark: #0c0d0d;
  --accent: #b6e55b;
  --accent-ink: #4d6a1c;
  --accent-soft: #f1f9e3;
  --warn-bg: #fff3d6;
  --warn: #8a5a00;
  --err-bg: #fdecea;
  --err: #c0392b;
  --info-bg: #e8f1fb;
  --info: #1f5d9c;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent-ink); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .3em; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 0 0 .8em; }
h3 { font-size: .95rem; margin: 0 0 .4em; }
p { margin: 0 0 .8em; }
code { background: #eef0ea; padding: 1px 6px; border-radius: 5px; font-size: .88em; overflow-wrap: anywhere; }
pre { background: var(--dark); color: #e8ece4; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
pre code { background: none; padding: 0; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Kopf */
.topbar { background: var(--dark); border-bottom: 4px solid var(--accent); }
.topbar-inner { max-width: 980px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; }
.brand, .login-brand { color: #fff; font-weight: 800; font-size: 1.2rem; text-decoration: none; letter-spacing: -.01em; }
.brand span, .login-brand span { color: var(--accent); font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin-left: 10px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #a7ada4; text-decoration: none; padding: 5px 12px; border-radius: 8px; }
.nav a:hover, .nav a.active { color: #fff; background: #1f2320; }
.who { color: #a7ada4; font-size: .85rem; text-decoration: none; }
.who:hover { color: #fff; }

main { max-width: 980px; margin: 0 auto; padding: 26px 16px 72px; }
main.plain { padding-top: 8vh; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.back { font-size: .85rem; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--ink); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.narrow.wide-form { max-width: 680px; }
.card.empty { text-align: center; padding: 36px 22px; }
.login-wrap { max-width: 400px; margin: 0 auto; }
.login-card { background: var(--dark); border: 0; border-bottom: 5px solid var(--accent); color: #e8ece4; padding: 30px 28px; }
.login-card .muted { color: #a7ada4; font-size: .9rem; margin-top: 10px; }
.login-card label { color: #a7ada4; }
.login-card input { background: #181b18; border-color: #2c312c; color: #fff; }

/* Formulare */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin: 14px 0 5px; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #c9cfc5; background: #fff; color: var(--ink); font: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 0; border-color: var(--accent-ink); }
.hint { font-size: .82rem; color: var(--muted); margin: 6px 0 10px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: .9rem; margin: 0; }
.check input { width: 17px; height: 17px; accent-color: var(--accent-ink); }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form .btn.primary, form > .btn { margin-top: 14px; }
form.inline .btn, .actions .btn { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid #c9cfc5; background: #fff; color: var(--ink); font: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--dark); }
.btn.primary:hover { background: #a5d946; border-color: #a5d946; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.topbar .btn.ghost { color: #a7ada4; }
.topbar .btn.ghost:hover { color: #fff; border-color: #3a403a; }
.btn.sm { padding: 4px 10px; font-size: .8rem; }
.btn.wide { width: 100%; margin-top: 20px; }

/* Hinweise */
.flash, .callout { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; border-left: 5px solid var(--accent); background: var(--accent-soft); overflow-wrap: anywhere; }
.flash.error, .callout.err { background: var(--err-bg); border-color: var(--err); }
.flash.warn, .callout.warn { background: var(--warn-bg); border-color: #e0a800; }
.flash.secret { background: var(--warn-bg); border-color: #e0a800; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; user-select: all; }
.callout.plan { background: var(--warn-bg); border-color: #e0a800; }
.callout p { margin: .4em 0 .8em; }
.callout .reject input { width: 220px; padding: 8px 10px; }

/* Listen */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs a { padding: 5px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.tabs a.active { background: var(--dark); color: #fff; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.list .card { border: 0; margin: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #fafbf8; }
.list-main { flex: 1; min-width: 200px; }
.list-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list-sub { display: block; font-size: .84rem; color: var(--muted); }
.line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; font-size: .92rem; }
.sub { border-top: 1px solid var(--line); padding: 6px 0 16px; }
.sub.new { background: #fafbf8; margin: 10px -22px -20px; padding: 16px 22px 20px; border-radius: 0 0 var(--radius) var(--radius); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: #eef0ea; color: var(--muted); }
.badge.s-waiting_ai, .badge.s-working { background: var(--info-bg); color: var(--info); }
.badge.s-waiting_customer { background: var(--accent-soft); color: var(--accent-ink); }
.badge.s-approval { background: var(--warn-bg); color: var(--warn); }
.badge.s-failed { background: var(--err-bg); color: var(--err); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--err); margin-right: 6px; }
.dot.on { background: #5fa80f; }

/* Gespräch */
.thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; max-width: 86%; align-self: flex-start; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: #d5eaa9; }
.msg.r-ai { border-left: 5px solid var(--accent); }
.msg.r-admin:not(.mine) { border-left: 5px solid var(--dark); }
.msg.r-system { align-self: center; background: transparent; border-style: dashed; font-size: .88rem; color: var(--muted); max-width: 100%; }
.msg-head { display: flex; gap: 10px; align-items: baseline; font-size: .82rem; margin-bottom: 4px; }
.msg-body p:last-child, .msg-body ul:last-child { margin-bottom: 0; }
.msg-body ul { margin: 0 0 .8em; padding-left: 1.3em; }
.msg-body h3, .msg-body h4, .msg-body h5, .msg-body h6 { font-size: 1rem; margin: .6em 0 .3em; }
.state { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; padding: 4px 2px; flex-wrap: wrap; }
.state.done { justify-content: center; }
.spinner { width: 16px; height: 16px; border: 3px solid var(--line); border-top-color: var(--accent-ink); border-radius: 50%; animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.reply label { margin-top: 0; }

.protocol { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.protocol summary { padding: 12px 16px; cursor: pointer; font-size: .88rem; color: var(--muted); }
.protocol-body { background: var(--dark); color: #cfd6ca; font: .78rem/1.55 ui-monospace, Consolas, monospace; padding: 12px 14px; max-height: 420px; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
.ev { white-space: pre-wrap; overflow-wrap: anywhere; }
.ev .muted { color: #6f776c; }
.ev-kind { color: var(--accent); }
.ev.k-error .ev-kind, .ev.k-error .ev-body { color: #ff8e80; }
.ev.k-write .ev-kind { color: #ffd166; }

@media (max-width: 600px) {
  .msg { max-width: 100%; }
  .card { padding: 16px; }
  .sub.new { margin: 10px -16px -16px; padding: 14px 16px 16px; }
}
