/* ===========================================================================
   AgentFlow24 Voice – Design-System (Basis: b_smart CRM)
   =========================================================================== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f2;
  --border-strong: #d3d9e6;
  --text: #1e2433;
  --text-soft: #5b6478;
  --text-mute: #8a93a6;
  --primary: #4338ca;
  --primary-600: #4f46e5;
  --primary-700: #3730a3;
  --primary-soft: #eef0fe;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --amber: #d97706;
  --amber-soft: #fdf1de;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --blue: #0ea5e9;
  --violet: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 28, 51, .06);
  --shadow: 0 4px 16px rgba(20, 28, 51, .08);
  --shadow-lg: 0 12px 32px rgba(20, 28, 51, .14);
  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
small { color: var(--text-mute); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #171b2e;
  color: #c8cede;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 18px 14px;
}
.brand {
  font-size: 20px; font-weight: 750; color: #fff;
  letter-spacing: -.02em; padding: 6px 8px 20px;
}
.brand .dot { color: var(--blue); }
.brand em { font-style: normal; font-weight: 500; color: #8b93ab; font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: #b7bed2; font-weight: 500; transition: .12s;
}
.nav-link .ico { width: 18px; text-align: center; opacity: .8; font-size: 15px; }
.nav-link:hover { background: #232841; color: #fff; }
.nav-link.active { background: var(--primary-600); color: #fff; box-shadow: var(--shadow-sm); }

.sidebar-foot { border-top: 1px solid #2a3049; padding-top: 12px; margin-top: 8px; }
.user { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-600); color: #fff;
  display: grid; place-items: center; font-weight: 650;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { color: #fff; font-size: 13px; }
.user-meta small { color: #7e86a0; text-transform: capitalize; }
.logout {
  display: block; text-align: center; padding: 8px;
  border-radius: var(--radius-sm); background: #232841;
  color: #b7bed2; font-weight: 500; font-size: 13px;
}
.logout:hover { background: #2c3350; color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topsearch { flex: 1; max-width: 520px; position: relative; }
.topsearch-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-mute); }
.topsearch input {
  width: 100%; padding: 9px 14px 9px 36px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); font-size: 13.5px; color: var(--text);
}
.topsearch input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar-actions { margin-left: auto; }

.content { padding: 26px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: .12s; white-space: nowrap;
}
.btn:hover { border-color: var(--text-mute); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-primary:hover { background: var(--primary-700); border-color: var(--primary-700); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--text-soft); font-size: 13.5px; margin-top: 2px; }
.crumbs { color: var(--text-mute); font-size: 12.5px; margin-bottom: 6px; }
.crumbs a:hover { color: var(--primary); }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat .label { color: var(--text-mute); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.cols-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 980px) { .cols-2 { grid-template-columns: 1fr; } }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
}
.badge.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.indigo { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill-hot { background: var(--red-soft); color: var(--red); }
.pill-warm { background: var(--amber-soft); color: var(--amber); }
.pill-cold { background: #e6f1fb; color: #2563eb; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 11px 14px; color: var(--text-mute);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl a.link { color: var(--primary); font-weight: 600; }
table.tbl a.link:hover { text-decoration: underline; }

/* ---------- Kanban ---------- */
.board-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.board-tab {
  padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
}
.board-tab.active { background: #171b2e; color: #fff; border-color: #171b2e; }

.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol { flex: 0 0 288px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kcol-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kcol-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.kcol-title { font-weight: 650; font-size: 13.5px; }
.kcol-count { margin-left: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 650; color: var(--text-soft); }
.kcol-sum { font-size: 11.5px; color: var(--text-mute); padding: 6px 14px 2px; }
.kcol-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 60px; display: flex; flex-direction: column; gap: 9px; }
.kcol-body.drag-over { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -6px; border-radius: var(--radius); }

.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: grab;
}
.kcard:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.kcard.dragging { opacity: .5; }
.kcard-title { font-weight: 650; font-size: 13.5px; margin-bottom: 4px; }
.kcard-title a:hover { color: var(--primary); }
.kcard-org { color: var(--text-mute); font-size: 12px; }
.kcard-meta { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.kcard-val { margin-left: auto; font-weight: 700; font-size: 12.5px; color: var(--text); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 12.5px; color: var(--text-soft); }
.field input, .field select, .field textarea, .filter input, .filter select {
  padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; color: var(--text); background: #fff; font-weight: 500;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-hint { font-weight: 500; color: var(--text-mute); font-size: 11.5px; }
fieldset.group { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; }
fieldset.group > legend { font-weight: 650; font-size: 13px; padding: 0 8px; color: var(--text); }

/* ---------- Filters ---------- */
.filter { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter input[type=search] { min-width: 260px; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-info { background: var(--primary-soft); color: var(--primary-700); }
.empty { text-align: center; color: var(--text-mute); padding: 40px 20px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .t-title { font-weight: 600; font-size: 13px; }
.timeline .t-time { color: var(--text-mute); font-size: 11.5px; }
.timeline .t-body { color: var(--text-soft); font-size: 13px; margin-top: 2px; white-space: pre-wrap; }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; font-size: 13.5px; }
.dl dt { color: var(--text-mute); font-weight: 600; }
.dl dd { margin: 0; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,20,35,.5); display: none; place-items: center; z-index: 100; }
.modal-backdrop.open { display: grid; }
.modal { background: #fff; border-radius: var(--radius); width: min(440px, 92vw); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 650; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(1200px 600px at 30% -10%, #2b3050, #12162a); }
.login-card { background: #fff; width: min(400px, 92vw); border-radius: 16px; padding: 34px 32px; box-shadow: var(--shadow-lg); }
.login-brand { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.login-brand .dot { color: var(--blue); }
.login-brand em { font-style: normal; font-weight: 500; color: var(--text-mute); }
.login-sub { color: var(--text-soft); margin: 4px 0 22px; font-size: 13.5px; }
.login-form { display: flex; flex-direction: column; gap: 15px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 12.5px; color: var(--text-soft); }
.login-form input { padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 14px; }
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- Utilities ---------- */
.row { display: flex; gap: 10px; align-items: center; }
.gap-lg { gap: 18px; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.mb { margin-bottom: 16px; }
.muted { color: var(--text-mute); }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); margin: 4px 0 12px; }

/* ===========================================================================
   Voice-spezifisch
   =========================================================================== */
.brand .wave { color: #22d3ee; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.preset { display: flex; flex-direction: column; gap: 8px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: .12s; }
.preset:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.preset h3 { font-size: 15px; margin: 0; }
.preset p { color: var(--text-soft); margin: 0; font-size: 13px; flex: 1; }
.dir-in { background: #e0f7fb; color: #0e7490; }
.dir-out { background: var(--primary-soft); color: var(--primary); }

.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.steps a { padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); }
.steps a:hover { border-color: var(--primary); color: var(--primary); }
.step-anchor { scroll-margin-top: 80px; }

.chat { display: flex; flex-direction: column; gap: 8px; max-height: 560px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
.bubble.bot { background: var(--primary-soft); color: var(--text); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble.user { background: #ecfdf5; color: var(--text); border-bottom-right-radius: 4px; align-self: flex-end; }
.bubble .who { display: block; font-size: 11px; font-weight: 700; color: var(--text-mute); margin-bottom: 2px; }
.toolcall { align-self: center; font-size: 11.5px; color: var(--text-mute); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 999px; padding: 3px 11px; }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.checklist .ok { color: var(--green); font-weight: 700; }
.checklist .no { color: var(--amber); font-weight: 700; }
code.copy { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; font-size: 12.5px; word-break: break-all; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.vars code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12px; cursor: pointer; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.mic-btn { width: 84px; height: 84px; border-radius: 50%; border: none; background: var(--primary-600); color: #fff; font-size: 30px; cursor: pointer; box-shadow: var(--shadow); }
.mic-btn.on { background: var(--red); animation: pulse 1.2s infinite; }
.inline-form { display: inline; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-soft); }
.check input { width: 16px; height: 16px; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .content { padding: 16px; }
}
.grid > * { min-width: 0; }
fieldset.group { min-width: 0; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; }
pre { overflow-x: auto; }
