/* Kontrollterminal – helles, ruhiges Design (weiß, viel Luft, feine Linien, Systemschrift) */
:root {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #f5f5f7; --line: #e8e8ed; --line-2: #d2d2d7;
  --text: #1d1d1f; --muted: #6e6e73; --faint: #86868b;
  --brand: #0071e3; --brand-2: #eaf3fe; --brand-h: #0077ed;
  --ok: #1d8a3e; --ok-bg: #e9f6ec; --warn: #b25e00; --warn-bg: #fff4e5; --err: #d70015; --err-bg: #fdecee;
  --radius: 18px; --radius-s: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
  --shadow-h: 0 2px 6px rgba(0,0,0,.06), 0 16px 40px rgba(0,0,0,.08);
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; font: 15px/1.47 var(--font); letter-spacing: -0.01em; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: #b3d7ff; }

/* --- Rahmen --- */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: rgba(251,251,253,.8); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.02em; padding: 2px 10px 20px; line-height: 1.2; }
.logo .dot { width: 30px; height: 30px; border-radius: 9px; background: var(--text); display: grid; place-items: center; color: #fff; font-size: 15px; flex: none; }
.nav { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 10px; color: var(--text); cursor: pointer;
  border: 0; background: none; text-align: left; width: 100%; font-size: 14px; transition: background .15s; }
.nav:hover { background: rgba(0,0,0,.04); }
.nav.active { background: rgba(0,0,0,.06); font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: none; color: var(--muted); stroke-width: 1.8; }
.nav.active svg { color: var(--brand); }
.side .spacer { flex: 1; }
.badge-count { margin-left: auto; background: var(--brand); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 600; padding: 0 7px; line-height: 18px; }
.navsec { font-size: 12px; color: var(--faint); font-weight: 600; padding: 18px 10px 6px; }
.ctx { padding: 0 6px 14px; display: flex; flex-direction: column; gap: 8px; }
.ctx select { font-size: 13px; padding: 7px 10px; background-color: #fff; }
.ctx label { font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .02em; }
.me { padding: 14px 10px 4px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 10px; }
.me b { color: var(--text); display: block; font-size: 13px; font-weight: 600; }
.me a { cursor: pointer; }

main { padding: 40px 48px 80px; max-width: 1240px; width: 100%; min-width: 0; }
.topbar { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.topbar h1 { font-size: 34px; line-height: 1.12; font-weight: 600; letter-spacing: -0.028em; margin: 0; }
.topbar .sub { color: var(--muted); margin-top: 6px; font-size: 17px; letter-spacing: -0.015em; }
.topbar .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.topbar .actions select { width: auto; }

/* --- Karten & Raster --- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; padding: 24px 26px; margin-bottom: 20px; }
.card h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
.card h3 { font-size: 15px; font-weight: 600; }
.card .hint, .hint { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.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)); }
.grid > .card { margin-bottom: 0; }

/* --- Formulare --- */
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; color: var(--text); }
label.f small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], input[type=search], input[type=month], select, textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: #fff; outline: none;
  font-size: 15px; transition: border-color .15s, box-shadow .15s; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2386868b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 13px center; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,113,227,.15); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
textarea.big { min-height: 340px; font-family: var(--mono); font-size: 13px; }
textarea.code { font-family: var(--mono); font-size: 12px; min-height: 120px; }
td input[type=text], td input[type=number], td input[type=email], td select { padding: 7px 10px; font-size: 14px; }
td select { padding-right: 30px; background-position: right 10px center; }

/* --- Buttons --- */
.btn { border: 1px solid transparent; background: var(--panel-2); color: var(--text); padding: 9px 18px; border-radius: 980px; cursor: pointer;
  font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none;
  transition: background .15s, transform .05s; }
.btn:hover { background: #ebebf0; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-h); }
.btn.danger { color: var(--err); background: transparent; border-color: var(--line-2); }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { padding: 5px 13px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.switch { position: relative; display: inline-block; vertical-align: middle; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #e3e3e8; border-radius: 26px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; background: #fff; border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: #34c759; }
.switch input:checked + span::before { transform: translateX(18px); }

/* --- Bausteine --- */
.tool { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: #fff; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, box-shadow .15s; }
.tool.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tool .head { display: flex; align-items: center; gap: 10px; }
.tool .name { font-weight: 600; font-size: 15px; }
.tool .desc { color: var(--muted); font-size: 13px; }
.tool details summary { cursor: pointer; color: var(--brand); font-weight: 500; font-size: 13px; }
.tool details[open] { padding-top: 6px; }
.tool details > .grid { margin-top: 12px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 980px; font-size: 12px; font-weight: 500; background: var(--panel-2); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.info { background: var(--brand-2); color: var(--brand); }

.kpi { padding: 22px 24px; }
.kpi .v { font-size: 34px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

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

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--faint); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }

.mode { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 20px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  background: #fff; transition: border-color .15s, box-shadow .15s; }
.mode:hover { border-color: var(--faint); }
.mode.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.mode h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode p { margin: 0; color: var(--muted); font-size: 14px; }
.mode ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* --- Chat & Testanruf --- */
.chat { display: flex; flex-direction: column; gap: 8px; height: 420px; overflow-y: auto; padding: 14px; background: var(--panel-2); border-radius: var(--radius); }
.msg { max-width: 80%; padding: 9px 14px; border-radius: 20px; white-space: pre-wrap; font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: #e9e9eb; color: var(--text); border-bottom-left-radius: 6px; }
.msg.system, .msg.tool { align-self: center; background: none; color: var(--muted); font-size: 12px; font-family: var(--mono); max-width: 95%; }
.msg.tool { cursor: pointer; }
.msg.agent { align-self: flex-start; background: var(--brand-2); color: var(--text); border-bottom-left-radius: 6px; }
.msg.notice { align-self: center; background: none; color: var(--muted); font-size: 12px; }
.callbtn { width: 76px; height: 76px; border-radius: 50%; border: 0; background: #34c759; color: #fff; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(52,199,89,.35); transition: transform .1s; }
.callbtn:active { transform: scale(.96); }
.callbtn.live { background: #ff3b30; box-shadow: 0 8px 24px rgba(255,59,48,.35); animation: pulse 1.6s infinite; }
.callbtn svg { width: 30px; height: 30px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,59,48,.45); } 70% { box-shadow: 0 0 0 18px rgba(255,59,48,0); } 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); } }
.level { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; width: 160px; }
.level div { height: 100%; background: #34c759; width: 0; transition: width .08s; }

/* --- Sonstiges --- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(29,29,31,.92); color: #fff; padding: 12px 20px;
  border-radius: 980px; box-shadow: var(--shadow-h); z-index: 99; max-width: 520px; font-size: 14px; backdrop-filter: blur(10px); }
.toast.err { background: var(--err); }
.login { max-width: 400px; margin: 14vh auto; padding: 36px 34px; box-shadow: var(--shadow-h); border: 0; }
.login h2 { font-size: 28px; letter-spacing: -0.025em; margin-bottom: 4px; }
.login .btn.primary { justify-content: center; padding: 11px 18px; font-size: 15px; }
.hidden { display: none !important; }
.info { background: var(--panel-2); border-radius: var(--radius-s); padding: 14px 16px; font-size: 14px; }
.info ol { margin: 6px 0 0; padding-left: 18px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.lcitem { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: 8px; cursor: pointer; background: #fff; }
.lcitem.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.lcitem .t { font-size: 12px; color: var(--muted); }
.diff { font-size: 12px; border-bottom: 1px solid var(--line); padding: 10px 0; }
.diff .p { font-family: var(--mono); font-weight: 600; }
.diff .o { background: var(--err-bg); white-space: pre-wrap; padding: 3px 8px; border-radius: 6px; margin: 4px 0; max-height: 140px; overflow: auto; }
.diff .n { background: var(--ok-bg); white-space: pre-wrap; padding: 3px 8px; border-radius: 6px; max-height: 140px; overflow: auto; }
.fields-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.dist .r { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }
.dist .b { height: 8px; background: var(--brand); border-radius: 4px; }

/* --- Flow-Editor --- */
.flowlayout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; }
.flowlayout > * { min-width: 0; }
.fpalette { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.fpalette .btn { border-left: 0 !important; background: #fff; border: 1px solid var(--line-2); }
.fwrap { height: 620px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: radial-gradient(circle, #dcdce1 1px, transparent 1px) 0 0 / 22px 22px, #fafafc; }
.fcanvas { position: relative; width: 2600px; height: 1400px; }
.fcanvas svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fedge { fill: none; stroke: #b0b0b8; stroke-width: 2; cursor: pointer; pointer-events: stroke; }
.fedge:hover, .fedge.sel { stroke: var(--brand); stroke-width: 3; }
.fedge.tmp { stroke-dasharray: 5 4; pointer-events: none; }
.fnode { position: absolute; width: 172px; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 16px rgba(0,0,0,.05); font-size: 12px; cursor: grab; user-select: none; overflow: visible; }
.fnode::before { content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 3px; border-radius: 0 0 3px 3px; background: var(--c); }
.fnode.sel { box-shadow: 0 0 0 2px var(--brand), 0 6px 16px rgba(0,0,0,.08); }
.fnode .fh { font-weight: 600; padding: 9px 12px 2px; color: var(--c); }
.fnode .fb { padding: 0 12px 8px; color: var(--text); max-height: 48px; overflow: hidden; }
.fnode .fports { border-top: 1px solid var(--line); }
.fnode .fport { display: flex; justify-content: flex-end; align-items: center; gap: 6px; padding: 4px 0 4px 12px; color: var(--muted); font-size: 11px; position: relative; }
.fnode .pout { width: 12px; height: 12px; border-radius: 50%; background: var(--c); border: 2px solid #fff; margin-right: -7px; cursor: crosshair; box-shadow: 0 0 0 1px var(--c); }
.fnode .pin { position: absolute; left: -7px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #b0b0b8; }
.fpanel { max-height: 680px; overflow: auto; }
.fpanel .f { margin-bottom: 12px; }

/* --- Bots & Plattform --- */
.botcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.botcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .2s, transform .2s; }
.botcard:hover { box-shadow: var(--shadow-h); transform: translateY(-2px); }
.botcard.cur { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.botcard h3 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.env { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 980px; letter-spacing: .04em; }
.env.prod { background: var(--ok-bg); color: var(--ok); } .env.staging { background: var(--warn-bg); color: var(--warn); } .env.dev { background: var(--brand-2); color: var(--brand); }
.tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tpl { border: 1px solid var(--line-2); border-radius: var(--radius-s); padding: 14px; cursor: pointer; background: #fff; transition: border-color .15s; }
.tpl:hover { border-color: var(--faint); }
.tpl.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tpl .i { font-size: 24px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.28); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal > .card { width: min(760px, 100%); max-height: 90vh; overflow: auto; border: 0; box-shadow: 0 24px 80px rgba(0,0,0,.18); border-radius: 22px; padding: 30px; }
.keybox { font-family: var(--mono); background: var(--panel-2); padding: 12px; border-radius: var(--radius-s); word-break: break-all; }

/* --- Schmale Bildschirme --- */
@media (max-width: 1100px) { .flowlayout { grid-template-columns: minmax(0, 1fr); } main { padding: 32px 28px 60px; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .spacer, .logo, .navsec, .me { display: none; }
  .nav { width: auto; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  main { padding: 20px 16px 60px; }
  .topbar h1 { font-size: 28px; }
}

/* Feinschliff */
.pill.info { padding: 2px 10px; border-radius: 980px; font-size: 12px; }
#chatin { min-width: 140px; }
.card .row > input.grow { min-width: 0; }
