/* 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; }
/* Bot-Nachricht mit Avatar */
.msgrow { display: flex; align-items: flex-end; gap: 8px; align-self: flex-start; max-width: 86%; }
.msgrow .msg { max-width: none; min-width: 0; }
.avatar { width: var(--av-size, 36px); height: var(--av-size, 36px); flex: none; border-radius: 50%; background: #fff;
  border: 1px solid var(--line); object-fit: cover; }
.msg.typing { display: flex; gap: 4px; align-items: center; padding: 13px 14px; }
.msg.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: typing 1.2s infinite ease-in-out; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .msg.typing i { animation: none; opacity: .6; } }
.topbar .mascot { margin-left: auto; height: var(--mascot-size, 120px); width: auto; margin-bottom: -8px; }
/* Pakete: gesperrte Funktionen, Paketverwaltung, „Mein Paket“ */
.feature-hidden { display: none !important; }
.locked { position: relative; }
.locked > :not(.lockbar) { opacity: .45; pointer-events: none; }
.mode.locked, .tool.locked { cursor: default; }
.lockbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); }
.lockbar .btn { pointer-events: auto; }
.pk-group { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.pk-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer; }
.pk-item .grow > span:last-child { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.pk-item.soon { opacity: .55; cursor: default; }
.pk-def { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 14px; margin-top: 8px; }
.pk-def summary { cursor: pointer; }
.pk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer; }
.pk-chip.soon { opacity: .6; }
.pk-have { padding: 8px 12px; border-radius: var(--radius-s); background: var(--panel-2); color: var(--muted); font-size: 14px; }
.pk-have.on { background: var(--ok-bg); color: var(--ok); font-weight: 500; }
.pk-sum { background: var(--panel-2); border-radius: var(--radius-s); padding: 12px 14px; display: grid; gap: 4px; font-size: 14px; }
.pk-sum > div { display: flex; justify-content: space-between; gap: 12px; }
.pk-sum .tot { border-top: 1px solid var(--line-2); padding-top: 6px; margin-top: 2px; font-size: 15px; }
/* Hilfe & Feedback (schwebend unten rechts) */
.helpfab { position: fixed; right: 22px; bottom: 22px; z-index: 40; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow-h); transition: transform .15s ease-out, box-shadow .15s; }
.helpfab svg { width: 22px; height: 22px; }
.helpfab:hover { box-shadow: 0 4px 10px rgba(0,0,0,.08), 0 18px 44px rgba(0,0,0,.12); }
.helpfab:active { transform: scale(.96); }
.helppop { position: fixed; right: 22px; bottom: 86px; z-index: 41; width: min(380px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.16);
  padding: 0 10px 10px; transform-origin: bottom right; animation: helpin .16s ease-out; }
@keyframes helpin { from { opacity: 0; transform: scale(.97) translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .helppop { animation: none; } }
.helphead { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 12px 12px;
  border-bottom: 1px solid var(--line); margin: 0 -10px; padding-left: 22px; padding-right: 14px; }
.iconbtn { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.iconbtn:hover { background: var(--panel-2); color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; }
.helplead { margin: 14px 12px 6px; color: var(--muted); }
.helpitem { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px; border: 0; background: none; border-radius: 14px;
  text-align: left; cursor: pointer; }
.helpitem:hover, .helpitem:focus-visible { background: var(--panel-2); outline: none; }
.helpitem .hicon { width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; background: var(--panel); }
.helpitem .hicon svg { width: 20px; height: 20px; }
.helpitem .grow { flex: 1; min-width: 0; }
.helpitem .grow > b { display: block; font-weight: 600; }
.helpitem .grow > span { display: block; color: var(--muted); font-size: 14px; line-height: 1.35; }
.helpitem .chev { width: 16px; height: 16px; color: var(--faint); flex: none; }
@media (max-width: 760px) { .helpfab { right: 14px; bottom: 14px; } .helppop { right: 16px; bottom: 76px; } }
/* Avatar-Karte (Persona) und Import-Fenster */
.avslot { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.avprev { width: 64px; height: 96px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--panel-2);
  color: var(--faint); font-size: 11px; text-align: center; overflow: hidden; }
.avprev.round { width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 1px solid var(--line); }
.avprev img { width: 100%; height: 100%; object-fit: contain; }
.avedit { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.avedit > .grow { min-width: 220px; }
.avstage { position: relative; border-radius: 14px; overflow: hidden; outline: none; width: max-content;
  background: repeating-conic-gradient(#ececf0 0% 25%, #fafafc 0% 50%) 50% / 16px 16px; }
.avstage:focus-visible { box-shadow: 0 0 0 3px var(--brand-2), 0 0 0 4px var(--brand); }
.avstage canvas { display: block; cursor: grab; touch-action: none; }
.avstage canvas:active { cursor: grabbing; }
.avstage.over::after { content: ""; position: absolute; inset: 0; border: 2px dashed var(--brand); border-radius: 14px; pointer-events: none; }
.avdrop { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; text-align: center;
  color: var(--text); font-size: 14px; }
.avpreview { padding: 16px; border-radius: var(--radius-s); background: var(--panel-2); min-height: 90px; display: flex; align-items: flex-end; }
.avpreview.full { justify-content: center; }
.avpreview .msgrow { max-width: 100%; }
.avpreview canvas.avatar { padding: 0; }
.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; } }
.mtop, .sideback { display: none; }
@media (max-width: 900px) {
  /* Oben eine schmale Leiste mit Menü-Knopf, das Menü fährt von links herein */
  .layout { grid-template-columns: minmax(0, 1fr); }
  .mtop { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 45; height: 56px;
    padding: 0 12px; padding-top: env(safe-area-inset-top); background: rgba(251,251,253,.9);
    backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
  .mmenu { width: 44px; height: 44px; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; cursor: pointer; flex: none; }
  .mmenu:active { background: rgba(0,0,0,.06); }
  .mmenu svg { width: 24px; height: 24px; }
  .mtitle { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
  .mtitle b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtitle span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; height: auto; width: min(300px, 86vw);
    transform: translateX(-102%); transition: transform .25s ease; background: #fbfbfd; box-shadow: none;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .sideback { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .25s; display: block; }
  body.menu-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.18); }
  body.menu-open .sideback { opacity: 1; pointer-events: auto; }
  body.menu-open { overflow: hidden; }
  .nav { padding: 11px 10px; font-size: 15px; }
  .ctx select { font-size: 16px; padding: 10px 12px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  main { padding: 18px 16px 90px; }
  .topbar { margin-bottom: 18px; align-items: flex-start; }
  .topbar h1 { font-size: 26px; }
  .topbar .sub { font-size: 15px; }
  .topbar .actions { margin-left: 0; flex-wrap: wrap; width: 100%; }
  .topbar .mascot { display: none; }
  .card { padding: 18px 16px; border-radius: 16px; }
  .modal > .card { padding: 20px 16px; border-radius: 18px; max-height: 92vh; }
  /* iOS zoomt bei Eingabefeldern unter 16 px ins Bild */
  input, select, textarea, td input[type=text], td input[type=number], td input[type=email], td select { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 36px; padding: 6px 13px; }
  /* breite Tabellen scrollen in ihrer Karte statt die Seite zu verbreitern */
  table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 10px 8px; }
  pre, .keybox, .mono { max-width: 100%; overflow-x: auto; overflow-wrap: anywhere; }
  .grid > *, .row > * { min-width: 0; }
  input[type=file] { max-width: 100%; }
  .toast { left: 16px; right: 16px; transform: none; bottom: calc(16px + env(safe-area-inset-bottom)); text-align: center; }
  .login { margin: 8vh 16px; padding: 28px 20px; }
}
@media (prefers-reduced-motion: reduce) { .side, .sideback { transition: none; } }

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

/* Logos */
.loginlogo { margin-bottom: 18px; }
.loginlogo img { max-height: 56px; max-width: 280px; display: block; }
.sidelogo { max-height: 38px; max-width: 200px; object-fit: contain; object-position: left center; }
.logo.haslogo .dot, .logo.haslogo #brandname { display: none; }
.me .powered { display: block; margin-top: 8px; font-size: 11px; color: var(--faint); }
.brandup { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.brandup .item { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.logoprev { min-height: 56px; min-width: 120px; display: grid; place-items: center; background: var(--panel-2); border-radius: 10px; color: var(--faint); font-size: 12px; padding: 8px; }
.logoprev img { max-height: 48px; max-width: 200px; }
.me .powered img { display: block; margin-top: 6px; max-height: 22px; max-width: 150px; object-fit: contain; object-position: left center; }
.me .powered a { display: block; width: fit-content; color: inherit; }
.me .powered a img { height: 22px; width: auto; }
.me .powered a:hover img { opacity: .8; }

/* ---------- Terminbuch ---------- */
.tbtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tbtabs button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.tbtabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tblist .tbday { font-weight: 600; margin: 16px 0 6px; text-transform: capitalize; }
.tblist .tbday:first-child { margin-top: 0; }
.tbrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: 6px; }
.tbrow.cancelled { opacity: .55; }
.tbrow.cancelled b { text-decoration: line-through; }
.tbrow .grow { flex: 1; min-width: 200px; }
.tbtime { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 58px; }
.tbtime small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.small { font-size: 13px; }
.tbtable input:not([type=checkbox]) { padding: 6px 8px; }
.tbtable td { vertical-align: top; }
.tbtable td input[data-k=name], .tbtable td input[data-k=beschreibung] { width: 100%; min-width: 160px; }
.tbtable td input[data-k=beschreibung] { margin-top: 4px; }
.tbperson { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; margin-bottom: 10px; }
.tbchips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.tbhours { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.tbhours label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.tbhours input { padding: 6px 7px; font-size: 13px; }
#tbsvc { overflow-x: auto; }
@media (max-width: 900px) { .tbhours { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#tbstatus { width: auto; }
.tbstate { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; padding: 16px 18px; margin-bottom: 14px;
  border-radius: var(--radius-s); background: var(--warn-bg); border: 1px solid #f3d9b1; }
.tbstate > div { flex: 1; min-width: 220px; }
.tbtoggle { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-s); background: var(--panel-2); cursor: pointer; }
.tbtoggle b { display: block; }
.tbtoggle small { display: block; color: var(--muted); font-size: 13px; }
.tactions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tbhide { display: none !important; }
