/* ===== Grundlagen ===================================================== */
:root {
  --brand: #0f766e;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --soft: #f8fafc;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
  --sidebar: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 .8em; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; } .right { text-align: right; }
.nowrap { white-space: nowrap; } .hidden { display: none !important; } .w100 { width: 100%; }
.mt0{margin-top:0}.mt1{margin-top:8px}.mt2{margin-top:16px}.mt3{margin-top:24px}.mb0{margin-bottom:0}.mb1{margin-bottom:8px}.mb2{margin-bottom:16px}

/* ===== Layout ========================================================= */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; font-weight: 650; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand:hover { text-decoration: none; }
.brand img { max-height: 30px; max-width: 120px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-size: 13px; }
.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 8px 12px; color: #cbd5e1; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar .count { margin-left: auto; font-style: normal; background: rgba(255,255,255,.15); color: #fff; font-size: 11px; padding: 0 7px; border-radius: 10px; }
.sidebar-foot { padding: 10px 18px; font-size: 11px; color: #475569; }
.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--panel); border-bottom: 1px solid var(--line); height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 22px; }
.topbar .search { flex: 1; max-width: 420px; }
.topbar .search input { width: 100%; background: var(--soft); }
.studio-switch select { font-weight: 600; min-width: 160px; }
.studio-name { font-weight: 600; }
.user-menu { margin-left: auto; position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .dropdown { position: absolute; right: 0; top: 42px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px; min-width: 190px; }
.user-menu .dropdown a, .user-menu .dropdown div { display: block; padding: 7px 10px; border-radius: 6px; }
.user-menu .dropdown a:hover { background: var(--soft); text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 650; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.menu-toggle { display: none; }
.content { padding: 22px; max-width: 1600px; width: 100%; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { background: var(--panel); width: 100%; max-width: 380px; padding: 30px; border-radius: 14px; box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 18px; } .auth-brand img { max-height: 48px; margin-bottom: 10px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }

/* ===== Karten & Raster ================================================ */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; } .card.flush > .card-head { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; }
.grid-sidebar-left { grid-template-columns: 300px minmax(0, 1fr); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.kpi .delta { font-size: 12px; } .delta.up { color: var(--ok); } .delta.down { color: var(--err); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ===== Formulare ====================================================== */
label { display: block; font-weight: 550; font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=tel], input[type=date], input[type=datetime-local], input[type=time], input[type=color], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; min-height: 36px; transition: border-color .15s, box-shadow .15s;
}
input[type=color] { padding: 2px; width: 60px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.field-hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 450; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }
.inline-form { display: inline; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0 0 14px; }
legend { font-weight: 650; padding: 0 6px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; width: 36px; height: 20px; background: var(--line-strong); border-radius: 20px; position: relative; transition: background .15s; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: left .15s; }
.switch input:checked { background: var(--brand); } .switch input:checked::after { left: 18px; }

/* ===== Buttons ======================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550; padding: 7px 14px; min-height: 36px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 85%, #000); }
.btn-danger { color: var(--err); border-color: #fecaca; } .btn-danger:hover { background: #fef2f2; }
.btn-ghost { border-color: transparent; background: transparent; } .btn-ghost:hover { background: var(--soft); }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; } .btn-wa:hover { background: #1fb457; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; padding: 6px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--soft); color: var(--text); }

/* ===== Tabellen ======================================================= */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--soft); white-space: nowrap; }
.table tr:hover td { background: #fbfdff; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 18px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 18px; }

/* ===== Badges, Chips, Flash =========================================== */
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.badge-gray { background: #f1f5f9; color: #475569; } .badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; } .badge-red { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #b45309; } .badge-purple { background: #ede9fe; color: #6d28d9; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: #eef2f7; color: #334155; border-left: 3px solid var(--tag, #94a3b8); }
.tag .x { cursor: pointer; opacity: .6; } .tag .x:hover { opacity: 1; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h2 { color: var(--text); }
.callout { background: var(--soft); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 12px 14px; }

/* ===== Tabs ============================================================ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-nav { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 74px; }
.settings-nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 10px 4px; font-weight: 600; }
.settings-nav a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text); }
.settings-nav a:hover { background: var(--soft); text-decoration: none; }
.settings-nav a.active { background: color-mix(in srgb, var(--brand) 12%, #fff); color: var(--brand); font-weight: 600; }

/* ===== Kanban ========================================================== */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; min-height: calc(100vh - 200px); }
.kcol { flex: 0 0 272px; background: #eef1f5; border-radius: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.kcol-head { padding: 10px 12px 8px; border-top: 3px solid var(--c, #94a3b8); border-radius: 10px 10px 0 0; }
.kcol-head .t { font-weight: 650; display: flex; justify-content: space-between; gap: 6px; }
.kcol-head .s { font-size: 12px; color: var(--muted); }
.kcol-body { padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.kcol-body.drag-over { background: color-mix(in srgb, var(--brand) 10%, transparent); border-radius: 0 0 10px 10px; }
.kcard { background: #fff; border-radius: 8px; padding: 9px 10px; margin-bottom: 7px; box-shadow: var(--shadow); cursor: grab; border: 1px solid transparent; }
.kcard:hover { border-color: var(--line-strong); }
.kcard.dragging { opacity: .45; }
.kcard .n { font-weight: 600; color: var(--text); display: block; }
.kcard .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.kcard.rotting { border-left: 3px solid var(--err); }
.kcard .tags { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }

/* ===== Zeitleiste ===================================================== */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ic { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; font-size: 13px; color: var(--muted); }
.timeline .ic.t-wa_in, .timeline .ic.t-wa_out { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.timeline .ic.t-email_out, .timeline .ic.t-email_in { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.timeline .ic.t-aidoo { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.timeline .ic.t-ai { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.timeline .head { display: flex; justify-content: space-between; gap: 8px; }
.timeline .head b { font-weight: 600; }
.timeline .body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; color: #334155; }
.timeline .body.html { white-space: normal; }

/* ===== Modal =========================================================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow: auto; }
.modal.lg { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Sonstiges ======================================================= */
.pager { display: flex; gap: 4px; justify-content: center; margin: 16px 0 4px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 32px; padding: 5px 9px; border-radius: 7px; text-align: center; border: 1px solid var(--line); background: #fff; }
.pager .cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager .dots { border: 0; background: transparent; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters > * { flex: 0 1 auto; }
.filters input, .filters select { min-width: 140px; }
.copy-box { display: flex; gap: 6px; }
.copy-box input, .copy-box textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--soft); }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.dl dt { color: var(--muted); font-size: 12.5px; } .dl dd { margin: 0; word-break: break-word; }
.progress { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, #94a3b8); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.sortable-handle { cursor: grab; color: var(--muted); padding: 0 6px; user-select: none; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-output { line-height: 1.6; }
.ai-output h1, .ai-output h2, .ai-output h3 { margin-top: 1em; }
.ai-output ul { padding-left: 20px; }
.step-card { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 12px 14px; position: relative; }
.step-connector { width: 2px; height: 18px; background: var(--line-strong); margin: 0 auto; }
.step-card .step-type { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.step-card .step-num { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; display: grid; place-items: center; }

/* ===== Responsiv ======================================================= */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar, .grid-sidebar-left { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-block; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; }
  .topbar .uname { display: none; }
  .content { padding: 16px; }
}
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } .topbar .search { display: none; } }
label > input[type=color] { display: block; }
.settings-main { min-width: 0; }
body.has-nav .content { padding-bottom: 96px; } /* Platz für den Assistenten-Button */
.page-head .actions select, .page-head .actions input:not([type=checkbox]) { width: auto; min-width: 0; }
.page-head form.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-table th, .team-table td { padding: 8px 9px; font-size: 13px; }
