:root {
  --bg: #0b1020; --bg2: #101733; --card: rgba(255,255,255,.045); --card-solid: #141a33; --line: rgba(255,255,255,.09);
  --text: #e6e9f2; --muted: #98a2b8; --brand: #6366f1; --brand2: #8b5cf6;
  --ok: #22c55e; --warn: #f59e0b; --danger: #ef4444; --info: #38bdf8;
  --radius: 14px; --sidebar: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(99,102,241,.18), transparent 60%), var(--bg);
  color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: #a5b4fc; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }

/* Layout */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: rgba(11,16,32,.92); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px; z-index: 50; backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 4px 8px 16px; }
.logo-mark { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; font-weight: 800; font-size: 22px; }
.logo-mark.sm { width: 30px; height: 30px; font-size: 16px; border-radius: 9px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; margin-bottom: 2px; }
nav a:hover { background: rgba(255,255,255,.05); color: var(--text); }
nav a.active { background: rgba(99,102,241,.2); color: #fff; box-shadow: inset 0 0 0 1px rgba(99,102,241,.45); }
.ico { width: 20px; text-align: center; }
.pill { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(11,16,32,.85); backdrop-filter: blur(10px); z-index: 20; }
.topbar h2 { font-size: 18px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.view { padding: 22px 24px 60px; max-width: 1400px; }
.menu-btn { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }

/* Karten & Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.kpi { display: flex; justify-content: space-between; align-items: center; }
.kpi .label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kpi .value { font-size: 30px; font-weight: 800; margin-top: 2px; }
.kpi .value.red { color: #fca5a5; }
.kpi .em { font-size: 26px; opacity: .8; }

/* Formulare */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #c7cde0; }
.input, .select, textarea.input {
  width: 100%; background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 12px; font: inherit; outline: none; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
textarea.input { min-height: 90px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.select option { background: #141a33; }
.select.small, .input.small { padding: 6px 10px; font-size: 12.5px; width: auto; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); }
.check b { display: block; font-size: 13.5px; }
.check small { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border: 0;
  border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text); font-weight: 600; }
.btn.danger { background: rgba(239,68,68,.18); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.btn.ok { background: rgba(34,197,94,.18); border: 1px solid rgba(34,197,94,.4); color: #86efac; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 4px 9px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: rgba(255,255,255,.07); }
.link-btn { background: none; border: 0; color: #a5b4fc; cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { text-decoration: underline; }

/* Schalter */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #334155; border-radius: 999px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge.ai { background: rgba(99,102,241,.16); color: #c7d2fe; border-color: rgba(99,102,241,.35); }
.badge.need { background: rgba(239,68,68,.16); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.badge.human { background: rgba(245,158,11,.16); color: #fcd34d; border-color: rgba(245,158,11,.4); }
.badge.done { background: rgba(148,163,184,.16); color: #cbd5e1; border-color: rgba(148,163,184,.3); }
.badge.ok { background: rgba(34,197,94,.16); color: #86efac; border-color: rgba(34,197,94,.4); }
.badge.fail { background: rgba(239,68,68,.16); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.badge.wait { background: rgba(56,189,248,.14); color: #7dd3fc; border-color: rgba(56,189,248,.35); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .em { font-size: 28px; display: block; margin-bottom: 6px; }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Fakten-Liste */
.fact { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: rgba(255,255,255,.03); }
.fact.off { opacity: .55; }
.fact .txt { white-space: pre-wrap; word-break: break-word; font-size: 13px; max-height: 120px; overflow: auto; }
.fact .meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.thumbs { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.drop { border: 2px dashed rgba(255,255,255,.18); border-radius: 12px; padding: 20px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: rgba(99,102,241,.08); color: var(--text); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; color: var(--muted); font-size: 12.5px; }
.progress { height: 7px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); transition: width .4s; }

/* Inbox / Chat */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; height: calc(100vh - 150px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.inbox-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .tools { padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.chip.on { background: rgba(99,102,241,.25); color: #fff; border-color: rgba(99,102,241,.6); }
.threads { overflow-y: auto; flex: 1; }
.thread { display: block; padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,.05); cursor: pointer; text-decoration: none; color: inherit; }
.thread:hover { background: rgba(255,255,255,.04); }
.thread.on { background: rgba(99,102,241,.16); }
.thread .t1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.thread .t2 { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread .t3 { display: flex; gap: 6px; margin-top: 5px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: rgba(0,0,0,.2); min-height: 0; }
.bubble { max-width: 70%; padding: 9px 13px; border-radius: 12px; word-break: break-word; white-space: pre-wrap; position: relative; }
.bubble.in { background: #1e293b; align-self: flex-start; border-bottom-left-radius: 3px; }
.bubble.ai { background: rgba(99,102,241,.3); align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble.human { background: rgba(34,197,94,.22); align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble.system { background: rgba(245,158,11,.16); align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble .who { font-size: 11px; font-weight: 700; opacity: .8; display: block; margin-bottom: 2px; }
.bubble .time { font-size: 10.5px; opacity: .6; display: block; margin-top: 3px; text-align: right; }
.bubble.deleted { opacity: .5; font-style: italic; }
.bubble .del { position: absolute; top: 2px; right: 4px; display: none; font-size: 11px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.bubble:hover .del { display: block; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 42px; max-height: 120px; resize: none; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); }

/* Berichte */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.bars .bar i { display: block; width: 100%; background: linear-gradient(180deg, var(--brand2), var(--brand)); border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .bar b { color: var(--text); font-size: 11.5px; margin-bottom: 3px; }
.hbar { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 12.5px; }
.hbar .name { width: 120px; flex-shrink: 0; color: #c7cde0; }
.hbar .track { flex: 1; height: 10px; background: rgba(255,255,255,.07); border-radius: 999px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); }
.hbar .n { width: 36px; text-align: right; color: var(--muted); }

/* Alerts, Modals, Toasts, Popover */
.alert { padding: 11px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid; font-size: 13px; }
.alert.warn { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.4); color: #fcd34d; }
.alert.err { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.4); color: #fca5a5; }
.alert.info { background: rgba(56,189,248,.1); border-color: rgba(56,189,248,.35); color: #bae6fd; }
#banner { padding: 0 24px; }
#banner .alert { margin-top: 14px; max-width: 1352px; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; }
.modal h3 { font-size: 17px; margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1e293b; border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--danger); }
.popover { position: fixed; z-index: 150; width: 280px; background: #1b2240; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 14px 40px rgba(0,0,0,.5); font-size: 12.5px; }
.popover dl { margin: 0; display: grid; grid-template-columns: 86px 1fr; gap: 4px 8px; }
.popover dt { color: var(--muted); }
.popover dd { margin: 0; }
.menu { position: fixed; z-index: 150; background: #1b2240; border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 190px; box-shadow: 0 14px 40px rgba(0,0,0,.5); }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit; }
.menu button:hover { background: rgba(255,255,255,.07); }
.code { background: #0a0f1f; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12px; white-space: pre; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.line-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: rgba(255,255,255,.03); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px; width: 100%; max-width: 380px; text-align: center; backdrop-filter: blur(12px); }
.login-card h1 { margin: 14px 0 4px; font-size: 24px; }
.login-card .alert { text-align: left; margin-top: 16px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f2937; border-radius: 10px; padding: 11px 16px; font-weight: 700; text-decoration: none; margin: 20px 0 14px; }
.btn-google:hover { filter: brightness(.95); }
.btn-google.disabled { opacity: .5; pointer-events: none; }

/* Test-Chat / Widget-Vorschau */
.phone { max-width: 460px; }
.phone .chat-msgs { height: 420px; border-radius: 12px; border: 1px solid var(--line); }
.preview-box { background: #0f172a; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); max-width: 320px; }
.preview-box .ph { padding: 12px 14px; font-weight: 700; color: #fff; }
.preview-box .pb { padding: 14px; background: #090d16; min-height: 110px; }
.preview-box .pm { background: #1e293b; padding: 8px 12px; border-radius: 12px; display: inline-block; font-size: 13px; }

@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-block; }
  .cols-3, .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 16px 14px 60px; }
  .topbar { padding: 12px 14px; }
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; }
  .inbox .chat { min-height: 70vh; }
  .inbox.chat-open .inbox-list { display: none; }
  .inbox:not(.chat-open) .chat { display: none; }
  .bubble { max-width: 88%; }
}
