/* ==========================================================================
   OktopusEngine Admin — design system
   ========================================================================== */
:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #09090b;
    --text-2: #3f3f46;
    --muted: #71717a;
    --primary: #09090b;
    --primary-hover: #27272a;
    --ring: 0 0 0 3px rgba(9, 9, 11, .1);
    --success: #15803d;
    --success-soft: #f0fdf4;
    --success-line: #bbf7d0;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-line: #fecaca;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --info: #1d4ed8;
    --info-soft: #eff6ff;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-xs: 0 1px 2px rgba(9, 9, 11, .05);
    --shadow-sm: 0 1px 3px rgba(9, 9, 11, .06), 0 1px 2px rgba(9, 9, 11, .04);
    --shadow-md: 0 8px 24px rgba(9, 9, 11, .08), 0 2px 6px rgba(9, 9, 11, .04);
    --sidebar-w: 252px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}

a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a.link:hover { text-decoration-color: var(--text); }

h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 16px; }

.icon { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

code {
    font-family: var(--mono); font-size: .85em;
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 1px 5px; border-radius: 4px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px;
    font: inherit; font-weight: 500; font-size: 13.5px; line-height: 1;
    border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-sm); gap: 6px; }
.btn-icon { width: 30px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
label, .label { display: block; font-weight: 500; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.5; }
.optional { color: var(--muted); font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], select, textarea {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    font: inherit; font-size: 14px; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.5; }
select {
    appearance: none; padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
input::placeholder, textarea::placeholder { color: #a1a1aa; }
input:focus, select:focus, textarea:focus { border-color: var(--text); box-shadow: var(--ring); }
input.is-invalid, textarea.is-invalid, select.is-invalid { border-color: var(--danger); }
input[type=file] { font: inherit; font-size: 13px; color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button {
    font: inherit; font-weight: 500; font-size: 13px;
    height: 32px; padding: 0 12px; margin-right: 10px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }

.error { color: var(--danger); font-size: 12.5px; margin-top: 6px; }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 400; font-size: 13.5px; margin: 0; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; }

/* Toggle switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; margin: 0; font-weight: 400; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
    position: relative; flex-shrink: 0; width: 36px; height: 20px; margin-top: 1px;
    background: var(--border-strong); border-radius: 999px; transition: background .15s;
}
.switch-track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch.field { margin-bottom: 20px; }
.switch-text strong { display: block; font-weight: 500; font-size: 13.5px; }
.switch-text span { color: var(--muted); font-size: 12.5px; }

/* ---------- Alerts / badges ---------- */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--radius); margin-bottom: 20px;
    font-size: 13.5px; border: 1px solid;
}
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 8px; border-radius: 999px;
    font-size: 12px; font-weight: 500; white-space: nowrap;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }
.badge-active, .badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.badge-inactive, .badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-admin { background: var(--text); color: #fff; border-color: var(--text); }
.badge-admin::before { display: none; }
.badge-user::before { display: none; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.logo {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: 0;
}
.nav { padding: 6px 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #a1a1aa; padding: 18px 10px 6px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    height: 36px; padding: 0 10px; border-radius: var(--radius);
    color: var(--text-2); font-weight: 500; font-size: 13.5px;
    transition: background .12s, color .12s;
}
.nav-link .icon { color: var(--muted); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--text); }
.nav-link.active .icon { color: var(--text); }
.nav-count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 500; }

.user-card {
    display: flex; align-items: center; gap: 10px;
    margin: 12px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    display: grid; place-items: center; font-weight: 600; font-size: 12px; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-meta { flex: 1; min-width: 0; line-height: 1.35; }
.user-meta strong { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 56px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 32px; border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 20;
}
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs .current { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumbs .sep { color: #d4d4d8; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 32px; width: 100%; max-width: 1240px; margin: 0 auto; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs); margin-bottom: 20px;
}
.card-body { padding: 22px 24px; }
.card-head {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-foot {
    display: flex; justify-content: flex-end; align-items: center; gap: 10px;
    padding: 14px 24px; border-top: 1px solid var(--border); background: #fcfcfc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card-narrow { max-width: 680px; }
.card-danger { border-color: var(--danger-line); }
.card-danger .card-head { border-color: var(--danger-line); }

.section-title { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 14px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 18px 20px; box-shadow: var(--shadow-xs);
}
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-icon { width: 32px; height: 32px; border-radius: var(--radius); background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 8px; line-height: 1.1; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left; font-size: 12px; color: var(--muted); font-weight: 500;
    padding: 10px 16px; background: #fcfcfc; border-bottom: 1px solid var(--border); white-space: nowrap;
}
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfc; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user strong { display: block; font-weight: 500; }
.cell-user span { display: block; color: var(--muted); font-size: 12.5px; }

.toolbar { display: flex; gap: 10px; padding: 14px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search-input { position: relative; flex: 1; max-width: 320px; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 140px; }

.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.pagination-wrap { padding: 14px 24px; border-top: 1px solid var(--border); }
.pagination-wrap:empty { display: none; }
.pagination li > * {
    display: grid; place-items: center; min-width: 32px; height: 32px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface);
}
.pagination li > a:hover { background: var(--surface-2); }
.pagination li.active > * { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination li.disabled > * { color: #a1a1aa; }

/* ---------- Empty states ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 24px; }
.empty-state { text-align: center; padding: 56px 24px; }
.empty-icon {
    width: 48px; height: 48px; margin: 0 auto 16px; border-radius: var(--radius-lg);
    background: var(--surface-2); border: 1px solid var(--border);
    display: grid; place-items: center; color: var(--text-2);
}
.empty-state h2 { font-size: 16px; }
.empty-state p { max-width: 420px; margin: 6px auto 20px; color: var(--muted); }

/* ---------- Lists ---------- */
.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 24px; border-bottom: 1px solid var(--border); font-size: 13.5px;
    transition: background .12s;
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: #fcfcfc; }
.list-row-main { flex: 1; min-width: 0; }
.list-row-main strong { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-main span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Chatbots ---------- */
.bot-avatar {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--radius);
    background: var(--primary); color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 650; overflow: hidden;
}
.bot-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bot-avatar-sm { width: 30px; height: 30px; font-size: 11px; border-radius: var(--radius-sm); }
.bot-avatar-lg { width: 56px; height: 56px; font-size: 16px; border-radius: var(--radius-lg); }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 20px; }
.bot-card {
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.bot-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.bot-card-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.bot-card-title { flex: 1; min-width: 0; }
.bot-card-title strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card-title span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-stats { display: grid; grid-template-columns: repeat(3, 1fr); padding: 16px 20px 18px; gap: 8px; }
.bot-stats strong { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.bot-stats span { font-size: 12px; color: var(--muted); }
.bot-card-foot { display: flex; align-items: center; gap: 6px; padding: 10px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.color-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); display: inline-block; }

/* Chatbot page header + tabs */
.bot-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.bot-header-title { flex: 1; min-width: 0; }
.bot-header-title h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bot-header-title p { color: var(--muted); margin-top: 2px; font-size: 13px; }

/* The divider line is an inset shadow (not a border) so tabs can scroll sideways on small screens without a scrollbar. */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--border); margin-bottom: 24px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    font-size: 13.5px; font-weight: 500; color: var(--muted);
    border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; font-family: inherit;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab .icon { width: 15px; height: 15px; }
.tab-count { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; color: var(--text-2); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; gap: 2px; }
.segmented button {
    display: inline-flex; align-items: center; gap: 7px;
    height: 30px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
    background: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .dot-error { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; align-items: start; }
.builder-side { position: sticky; top: 80px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.preview-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.chat-preview {
    height: 560px; padding: 20px 28px 28px 20px; border-radius: var(--radius-lg);
    background:
        radial-gradient(circle, #d9d9de 1px, transparent 1px) 0 0 / 16px 16px,
        var(--surface-2);
    border: 1px solid var(--border);
}
.tab-panel[hidden] { display: none; }

.avatar-field { display: flex; gap: 18px; align-items: center; }

.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice {
    display: block; position: relative; cursor: pointer; margin: 0;
    border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 14px 14px 42px;
    font-weight: 400; transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice:hover { border-color: var(--border-strong); }
.choice input { position: absolute; left: 14px; top: 16px; }
.choice:has(input:checked) { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.choice-title { display: block; font-weight: 600; font-size: 13.5px; }
.choice-desc { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; line-height: 1.45; }

/* Theme gallery */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.theme-card { position: relative; display: flex; flex-direction: column; gap: 8px; cursor: pointer; margin: 0; font-weight: 400; }
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-mock {
    display: flex; flex-direction: column; gap: 6px; height: 104px; padding: 0 0 10px; overflow: hidden;
    border: 1px solid var(--border); box-shadow: var(--shadow-xs); transition: box-shadow .15s, transform .15s;
}
.theme-card:hover .theme-mock { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.theme-card input:checked + .theme-mock { box-shadow: 0 0 0 2px var(--text); }
.theme-card input:focus-visible + .theme-mock { box-shadow: var(--ring); }
.theme-mock-head { height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.theme-mock-head i { display: block; width: 14px; height: 14px; border-radius: 50%; }
.theme-mock-msg { display: block; width: 58%; padding: 7px 8px; border: 1px solid transparent; }
.theme-mock-msg b { display: block; height: 4px; border-radius: 4px; opacity: .55; }
.theme-mock-msg.bot { margin-inline-start: 8px; }
.theme-mock-msg.user { margin-inline-start: auto; margin-inline-end: 8px; width: 44%; }
.theme-name { font-size: 13px; font-weight: 500; text-align: center; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 18px; }
.color-field label { font-size: 12.5px; }
.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.pf-grid { display: grid; grid-template-columns: minmax(0, 1fr) 160px 80px; gap: 12px; }
.icon-choices { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-choice {
    display: flex; flex-direction: column; align-items: center; gap: 6px; width: 104px; padding: 12px 8px; margin: 0;
    border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 400; font-size: 12px; color: var(--muted);
}
.icon-choice input { position: absolute; opacity: 0; pointer-events: none; }
.icon-choice svg { width: 22px; height: 22px; color: var(--text); }
.icon-choice:has(input:checked) { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); color: var(--text); }
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sound-choice { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; padding-bottom: 6px; }
.sound-choice .choice-title { margin-top: 2px; }
.input-suffix { display: flex; align-items: center; gap: 10px; }
.input-suffix input { width: 110px; }
.input-suffix span { color: var(--muted); font-size: 13px; }
input[type=number] { height: 38px; padding: 0 12px; font: inherit; font-size: 14px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); outline: none; }
input[type=number]:focus { border-color: var(--text); box-shadow: var(--ring); }
input[type=range] { width: 100%; accent-color: var(--primary); margin-top: 10px; }
.segmented { flex-wrap: wrap; }
.segmented-sm { margin-bottom: 0; }
.segmented-sm button { height: 26px; padding: 0 10px; font-size: 12.5px; }

/* Website preview */
.site-preview {
    position: relative; height: 560px; overflow: hidden; border-radius: var(--radius-lg);
    border: 1px solid var(--border); background: #fff;
}
.fake-site { padding: 14px; display: flex; flex-direction: column; gap: 18px; }
.fake-nav { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.fake-nav i { width: 22px; height: 22px; border-radius: 6px; background: var(--border-strong); margin-right: auto; }
.fake-nav span { width: 38px; height: 7px; border-radius: 4px; background: var(--border); }
.fake-hero { display: flex; flex-direction: column; gap: 10px; padding: 18px 4px; }
.fake-hero b { height: 14px; border-radius: 4px; background: var(--border-strong); width: 80%; }
.fake-hero b + b { width: 55%; }
.fake-hero span { width: 90px; height: 26px; border-radius: 6px; background: var(--text); margin-top: 6px; }
.fake-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fake-cards i { height: 90px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
#site-widget { position: absolute; inset: 0; pointer-events: none; }
#site-widget > * { pointer-events: auto; }

.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.choice-compact { padding: 10px 12px 10px 38px; }
.choice-compact input { left: 12px; top: 13px; }
.choice.is-default { opacity: .5; pointer-events: none; }
.choice.is-default .choice-desc::after { content: " · default"; }
label .icon-sm { margin-top: -2px; color: var(--muted); }

.transcript {
    white-space: pre-wrap; font-size: 12.5px; line-height: 1.55; color: var(--text-2);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 12px; margin-top: 8px; max-height: 220px; overflow-y: auto;
}
details summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
details summary:hover { color: var(--text); }
.filter-tabs { display: flex; gap: 4px; padding: 10px 24px; border-bottom: 1px solid var(--border); }
.filter-tabs a { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--muted); }
.filter-tabs a:hover { color: var(--text); background: var(--surface-2); }
.filter-tabs a.active { color: var(--text); background: var(--surface-2); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer; padding: 0;
    border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong);
    transition: box-shadow .15s, transform .15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.color-input { display: flex; align-items: center; gap: 8px; margin-left: 4px; }
.color-input input[type=color] { width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: none; cursor: pointer; }
.color-input input[type=text] { width: 110px; font-family: var(--mono); font-size: 13px; text-transform: uppercase; }

.qa-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.qa-item { border: 1px solid var(--border); border-radius: var(--radius); background: #fcfcfc; }
.qa-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.qa-number { font-size: 12px; font-weight: 600; color: var(--muted); }
.qa-number::before { content: "Question "; }
.qa-tools { display: flex; gap: 4px; }
.qa-fields { padding: 14px; }
.qa-fields .field { margin-bottom: 14px; }
.qa-fields .field:last-child { margin-bottom: 0; }
#chatbot-form[data-mode="options"] .keywords-field { display: none; }

.code-block {
    position: relative; font-family: var(--mono); font-size: 13px; line-height: 1.6;
    background: #0a0a0a; color: #e4e4e7; border-radius: var(--radius);
    padding: 16px 18px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
    border: 0; width: 100%; resize: none; display: block; height: auto;
}
.code-block:focus { box-shadow: none; }
/* Grows to fit its code where supported; elsewhere any scrollbar is thin and dark to match */
textarea.code-block { field-sizing: content; min-height: 0; max-height: 520px; overflow-y: auto; }
.code-block { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .22) transparent; }
.code-block::-webkit-scrollbar { width: 8px; height: 8px; }
.code-block::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 8px; }
.code-block::-webkit-scrollbar-track, .code-block::-webkit-scrollbar-corner { background: transparent; }
.key-field { display: flex; gap: 8px; }
.key-field input { font-family: var(--mono); font-size: 13px; background: var(--surface-2); }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { position: relative; padding-left: 36px; padding-bottom: 18px; counter-increment: step; color: var(--text-2); }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
    content: counter(step); position: absolute; left: 0; top: -1px;
    width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
    border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; color: var(--text); background: var(--surface);
}
.steps strong { color: var(--text); font-weight: 600; }

.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    padding: 32px 20px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
    background: #fcfcfc; cursor: pointer; transition: border-color .15s, background .15s;
    font-weight: 400; margin: 0;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--text); background: var(--surface-2); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { font-weight: 600; font-size: 14px; margin-top: 10px; }
.dropzone span { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.dropzone .file-name { margin-top: 10px; color: var(--text); font-weight: 500; }

.file-icon {
    width: 36px; height: 36px; border-radius: var(--radius); flex-shrink: 0;
    display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .02em;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-grid .card { margin-bottom: 0; }
.welcome {
    display: flex; justify-content: space-between; align-items: center; gap: 24px;
    background: var(--primary); color: #fff; border-radius: var(--radius-lg);
    padding: 26px 28px; margin-bottom: 24px; overflow: hidden; position: relative;
}
.welcome::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,.08) 1px, transparent 1px) 0 0 / 18px 18px;
    pointer-events: none;
}
.welcome h1 { color: #fff; }
.welcome p { color: #a1a1aa; margin-top: 4px; }
.welcome .btn { position: relative; z-index: 1; background: #fff; color: var(--text); }
.welcome .btn:hover { background: #e4e4e7; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside {
    background: var(--primary); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-aside::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,.09) 1px, transparent 1px) 0 0 / 22px 22px;
    pointer-events: none;
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside .brand { padding: 0; color: #fff; }
.auth-aside .logo { background: #fff; color: var(--text); }
.auth-quote { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; max-width: 420px; }
.auth-quote + p { color: #a1a1aa; margin-top: 14px; max-width: 400px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: #d4d4d8; }
.auth-points li { display: flex; gap: 10px; align-items: center; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; }
.auth-card .subtitle { color: var(--muted); margin: 6px 0 28px; }
.auth-footer { margin-top: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-footer a { color: var(--text); font-weight: 500; }
.btn-google { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-xs); height: 40px; }
.btn-google:hover { background: var(--surface-2); }
.auth-card .btn-primary { height: 40px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: #a1a1aa; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 24px; color: var(--muted); font-size: 13px; }
.back-link:hover { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 1150px) {
    .builder { grid-template-columns: 1fr; }
    .builder-side { position: static; }
    .chat-preview { max-width: 440px; }
}

@media (max-width: 900px) {
    .dash-grid, .mode-options { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* The sidebar becomes a drawer below 900px: see "Mobile app shell" at the end of this file. */
@media (max-width: 800px) {
    .content { padding: 16px 14px; }
    .form-row { grid-template-columns: 1fr; }
    .card-head, .card-body, .list-row, .toolbar, .card-foot, .pagination-wrap { padding-left: 16px; padding-right: 16px; }
    th:first-child, td:first-child { padding-left: 16px; }
    th:last-child, td:last-child { padding-right: 16px; }
}

/* Translations: pre-chat form section */
.tr-prechat{border-top:1px solid var(--border, #e5e5e5);margin-top:8px;padding-top:18px}
.tr-prechat h3{font-size:14px;font-weight:600;margin:0 0 14px}
.tr-field{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:14px}
.tr-field textarea{min-height:0}
@media (max-width:640px){.tr-field{grid-template-columns:1fr}}

/* ---------- Roles ---------- */
.badge-superadmin { background: linear-gradient(135deg, #18181b, #4338ca); color: #fff; border-color: transparent; }
.badge-superadmin::before { display: none; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }

/* ---------- Platform dashboard ---------- */
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; margin-right: 10px; vertical-align: middle; box-shadow: 0 0 0 0 rgba(34,197,94,.5); animation: live-pulse 2s infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.user-avatar.is-online { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #22c55e; }
.online-text { color: var(--success); font-weight: 500; }
.platform-table .cell-user .badge { margin-top: 4px; }
.platform-table td.num, .platform-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bot-list summary { cursor: pointer; white-space: nowrap; list-style: none; }
.bot-list summary::-webkit-details-marker { display: none; }
.bot-list summary::after { content: "▾"; margin-left: 6px; color: var(--muted); font-size: 11px; }
.bot-list[open] summary::after { content: "▴"; }
.bot-list ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.bot-list li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.bot-list li a { font-weight: 500; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--border-strong); }
.bot-list .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.bot-list .dot.on { background: #22c55e; }

/* ---------- Email verification ---------- */
.code-input { font-size: 26px !important; font-weight: 600; letter-spacing: .5em; text-align: center; padding-left: .5em !important; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; height: 56px !important; }
.verify-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--text); font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-button:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.change-email { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; font-size: 13px; }
.change-email summary { cursor: pointer; color: var(--muted); }
.change-email form { display: flex; gap: 8px; margin-top: 12px; }
.change-email input { flex: 1; }
.honeypot { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Login: "Forgot password?" next to the label */
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.small-link { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.small-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Stage 1: organizations, roles, security ---------- */
.nav-org { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-owner { background: var(--text); color: #fff; border-color: var(--text); }
.badge-owner::before { display: none; }

.support-banner { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: #fef3c7; color: #78350f; border-bottom: 1px solid #fde68a; font-size: 13.5px; }
.support-banner form { margin-left: auto; }

.invite-link > div { flex: 1; min-width: 0; }
.copy-row { display: flex; gap: 8px; margin: 10px 0 6px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; background: var(--surface); }

.captcha-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.captcha-row img { border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f6f6f7; }
#captcha { text-transform: uppercase; letter-spacing: .25em; font-weight: 600; max-width: 200px; }

.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; margin-top: 10px; }
.recovery-codes code { font-size: 14px; font-weight: 600; color: var(--text); }
.two-factor-setup { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.two-factor-setup .qr { padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); line-height: 0; }
.two-factor-setup p { margin: 0 0 10px; }
.two-factor-setup .secret { font-size: 13px; letter-spacing: .05em; word-break: break-all; }
.inline-code-form { display: flex; gap: 8px; align-items: center; }
.inline-code-form input { width: 140px; font-variant-numeric: tabular-nums; letter-spacing: .15em; }

.invite-card > summary, .role-card > summary { cursor: pointer; list-style: none; }
.invite-card > summary::-webkit-details-marker, .role-card > summary::-webkit-details-marker { display: none; }
.invite-card:not([open]) > summary, .role-card:not([open]) > summary { border-bottom: 0; }
.role-list { display: grid; gap: 12px; }
.role-card { margin: 0; }
.role-card h2 .badge { margin-left: 6px; vertical-align: middle; }
.perm-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; font-size: 13px; }
.perm-summary ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-2); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-top: 8px; }
.perm-grid fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; display: grid; gap: 8px; }
.perm-grid legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.perm-grid .checkbox { align-items: flex-start; font-size: 13px; }
.checkbox.is-disabled { opacity: .45; cursor: not-allowed; }

.seg-option { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; border-radius: var(--radius-sm); }
.seg-option:has(input:checked) { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 500; }
.seg-option input { margin: 0; }
.chatbot-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); }

.audit-table code.action { font-size: 11.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; margin-right: 6px; color: var(--text-2); }
.inline-select select { height: 30px; font-size: 12.5px; padding: 0 28px 0 8px; }
a.bot-card[aria-disabled="true"] { cursor: default; }

.dash-grid > div > .card + .card { margin-top: 16px; }
.dash-grid > div > .card { margin-bottom: 0; }

.staff-badge { margin-bottom: 14px; gap: 6px; height: 26px; padding: 0 10px; }

/* Q&As per language (Script tab) */
.qa-langs { margin-bottom: 16px; }
.qa-langs .segmented { margin-bottom: 8px; }
.qa-langs .hint { margin: 0 0 8px; }
.qa-count { display: inline-block; min-width: 18px; margin-left: 2px; padding: 0 5px; border-radius: 9px; background: var(--border); font-size: 11px; line-height: 16px; text-align: center; }
.qa-item[hidden] { display: none; }
.qa-source { margin-bottom: 12px; padding: 8px 10px; border-radius: var(--radius); background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.qa-lang-empty { padding: 24px; }
.qa-lang-empty p { max-width: 460px; margin: 0 auto 12px; }
.qa-lang-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.qa-lang-link span { display: block; color: var(--muted); font-size: 12.5px; }#qa-move[hidden], #qa-copy[hidden] { display: none; }
.qa-item.is-translating .qa-fields .field { opacity: .55; pointer-events: none; }

/* Conversations (Insights) */
.chat-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: .03em; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; white-space: nowrap; }
a.chat-id:hover { border-color: var(--text-2); }
.convo-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.transcript { display: flex; flex-direction: column; gap: 14px; padding: 20px 24px 24px; max-height: 72vh; overflow-y: auto; background: var(--surface-2); border-top: 1px solid var(--border); }
.transcript-day { text-align: center; font-size: 11.5px; color: var(--muted); }
.transcript-day span { padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.transcript-row { display: flex; flex-direction: column; max-width: 78%; }
.transcript-row.from-visitor { align-self: flex-end; align-items: flex-end; }
.transcript-row.from-bot { align-self: flex-start; align-items: flex-start; }
.transcript-bubble { padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.from-bot .transcript-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.from-visitor .transcript-bubble { background: var(--text); color: var(--surface); border-bottom-right-radius: 4px; }
.transcript-meta { margin-top: 4px; font-size: 11.5px; color: var(--muted); white-space: normal; }
.transcript-source { font-weight: 500; }
.transcript-source.is-miss { color: var(--danger); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.callback-fact + .callback-fact { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
@media (max-width: 900px) {
    .convo-grid { grid-template-columns: 1fr; }
    .transcript-row { max-width: 92%; }
}
/* Insights page */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.metric { display: flex; flex-direction: column; gap: 2px; padding: 14px 20px; }
.metric + .metric { border-left: 1px solid var(--border); }
.metric-label { font-size: 12.5px; color: var(--muted); }
.metric-value { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.metric-value.is-alert { color: var(--danger); }
.segmented a {
    display: inline-flex; align-items: center; gap: 7px;
    height: 30px; padding: 0 14px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-count { font-size: 11.5px; padding: 0 6px; border-radius: 999px; background: var(--border); color: var(--text-2); }
.search-wide { max-width: 380px; }
.toolbar { align-items: center; }
.toolbar-hint { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.convo-list { list-style: none; margin: 0; padding: 0; }
.convo-list > li + li { border-top: 1px solid var(--border); }
.convo-row { display: flex; align-items: center; gap: 14px; padding: 14px 24px; color: inherit; text-decoration: none; }
.convo-row:hover { background: var(--surface-2); }
.convo-avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 14px; font-weight: 600; }
.convo-avatar.is-known { background: var(--text); border-color: var(--text); color: var(--surface); }
.convo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.convo-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.convo-top strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-top .chat-id { font-size: 11px; padding: 1px 5px; }
.convo-preview { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 12.5px; text-align: right; }
.question-row { display: flex; align-items: center; gap: 14px; padding: 14px 24px; }
.question-row strong { font-weight: 500; overflow-wrap: anywhere; }
.question-row .actions { flex: none; display: flex; align-items: center; gap: 6px; }
@media (max-width: 700px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .metric:nth-child(3) { border-left: 0; }
    .metric:nth-child(n+3) { border-top: 1px solid var(--border); }
    .toolbar-hint { margin-left: 0; width: 100%; }
    .convo-row, .question-row { padding-left: 16px; padding-right: 16px; }
    .convo-side .small { display: none; }
    .question-row { flex-wrap: wrap; }
}
/* Live chat (conversation page + inbox) */
.presence { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.presence::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.presence.is-online { color: var(--success, #16a34a); }
.presence.is-online::before { background: var(--success, #16a34a); }
.live-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 24px; border-top: 1px solid var(--border); background: var(--surface); }
.live-bar.is-waiting { background: var(--danger-soft); }
.live-bar.is-live { background: #ecfdf5; }
.live-bar-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.live-bar-text span { color: var(--text-2); }
.live-bar-actions { display: flex; gap: 8px; }
.transcript-note { text-align: center; font-size: 11.5px; color: var(--muted); }
.transcript-note span { display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--border); background: var(--surface); }
.from-agent .transcript-bubble { background: #eef2ff; border: 1px solid #c7d2fe; border-bottom-left-radius: 4px; }
.from-agent { align-self: flex-start; align-items: flex-start; }
.live-composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 24px; border-top: 1px solid var(--border); }
.live-composer textarea { flex: 1; resize: vertical; min-height: 44px; }
.live-section.is-waiting { border-color: var(--danger-line); }
.live-empty { margin: 0; padding: 18px 24px; color: var(--muted); font-size: 13.5px; }
/* Platform: delete account impact */
.impact-list { margin: 0 0 16px; padding-left: 18px; font-size: 13.5px; line-height: 1.6; }

/* ---------------- Lead Management (CRM) ---------------- */
input[type=tel], input[type=datetime-local], input[type=date], input[type=time] {
    width: 100%; height: 38px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-xs); outline: none; transition: border-color .15s, box-shadow .15s;
}
input[type=tel]:focus, input[type=datetime-local]:focus { border-color: var(--text); box-shadow: var(--ring); }
input[type=number] { width: 100%; }
.icon-xs { width: 12px; height: 12px; vertical-align: -1px; }
.choice + .choice { margin-top: 8px; }

/* Stage colours */
.c-gray { --c: #71717a; --c-soft: #f4f4f5; }
.c-blue { --c: #2563eb; --c-soft: #eff6ff; }
.c-violet { --c: #7c3aed; --c-soft: #f5f3ff; }
.c-amber { --c: #b45309; --c-soft: #fffbeb; }
.c-orange { --c: #c2410c; --c-soft: #fff7ed; }
.c-teal { --c: #0f766e; --c-soft: #f0fdfa; }
.c-green { --c: #15803d; --c-soft: #f0fdf4; }
.c-red { --c: #dc2626; --c-soft: #fef2f2; }
.stage-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--c); background: var(--c-soft); border: 1px solid color-mix(in srgb, var(--c) 22%, transparent); }
.stage-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.stage-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }

/* Hot / warm / cold */
.temp-hot { --t: #dc2626; --t-soft: #fef2f2; }
.temp-warm { --t: #c2410c; --t-soft: #fff7ed; }
.temp-cold { --t: #2563eb; --t-soft: #eff6ff; }
.temp { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; vertical-align: middle; color: var(--t); background: var(--t-soft); }
.temp-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.temp-option { position: relative; display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 400; }
.temp-option input { position: absolute; opacity: 0; pointer-events: none; }
.temp-option strong { color: var(--t); font-size: 13.5px; }
.temp-option span { color: var(--muted); font-size: 12px; }
.temp-option:has(input:checked) { border-color: var(--t); background: var(--t-soft); box-shadow: 0 0 0 1px var(--t); }
.temp-option:has(input:focus-visible) { box-shadow: var(--ring); }
.temp-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.temp-switch label { position: relative; margin: 0; padding: 3px 10px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; }
.temp-switch label input { position: absolute; opacity: 0; pointer-events: none; }
.temp-switch label.is-on { background: var(--surface); color: var(--t); box-shadow: var(--shadow-sm); }
.temp-switch label:has(input:focus-visible) { box-shadow: var(--ring); }

/* Owner */
.owner-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.owner-dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); flex: none; }

/* Lead list */
.crm-filters select { min-width: 0; }
.filter-tabs { flex-wrap: wrap; align-items: center; }
.filter-tabs .tab-count { margin-left: 4px; }
.tab-count.is-alert { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.filter-tabs-end { margin-left: auto; display: inline-flex; gap: 4px; }
.lead-table td { vertical-align: top; }
.lead-cell { min-width: 220px; max-width: 360px; }
.lead-name { font-weight: 500; color: var(--text); }
.lead-name:hover { text-decoration: underline; }
.lead-answers { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 3px; color: var(--text-2); }
.check-col { width: 36px; }
.due { color: var(--text-2); }
.due.is-overdue, .task-row.is-overdue .due, .task-when.is-overdue { color: var(--danger); font-weight: 500; }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bulk-bar[hidden] { display: none; }
.bulk-bar select { width: auto; min-width: 220px; height: 32px; }
.dupe-list { margin: 6px 0; padding-left: 18px; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.input-prefix input { border-radius: 0 var(--radius) var(--radius) 0; }
.crm-form { max-width: 820px; }
.crm-form > .card + .card { margin-top: 16px; }
.crm-form > .form-actions { margin-top: 16px; justify-content: flex-end; }
.card-foot.form-actions { justify-content: flex-end; }

/* Pipeline board */
.board-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.board-filters .search-input { min-width: 220px; }
.board-filters select { width: auto; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x proximity; }
.board-col { flex: 0 0 272px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 230px); scroll-snap-align: start; }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; font-size: 13.5px; }
.board-count { font-size: 12px; color: var(--muted); }
.board-total { margin-left: auto; font-size: 12px; color: var(--text-2); font-weight: 500; }
.board-cards { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px; overflow-y: auto; min-height: 64px; border-radius: var(--radius); transition: background .15s; }
.board-cards.is-over { background: rgba(9, 9, 11, .06); }
.board-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: var(--text); box-shadow: var(--shadow-xs); cursor: pointer; }
.board-card[draggable=true] { cursor: grab; }
.board-card:hover { border-color: var(--border-strong); }
.board-card.is-dragging { opacity: .45; }
.board-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.board-card-top strong { font-weight: 500; font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }
.board-card-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; flex-wrap: wrap; }
.board-value { font-weight: 600; }
.board-owner { margin-left: auto; }
.board-empty { text-align: center; color: var(--muted); font-size: 12.5px; padding: 14px 0; }
.board-more { text-align: center; font-size: 12.5px; color: var(--text-2); padding: 6px; text-decoration: underline; }

/* Lead page */
.lead-title { display: flex; align-items: center; gap: 14px; }
.lead-title h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 18px; background: var(--text); color: #fff; flex: none; }
.stage-path { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; }
.stage-path form { margin: 0; }
.stage-step { height: 32px; padding: 0 14px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.stage-step:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.stage-step:disabled { cursor: default; }
.stage-step.is-passed { color: var(--text-2); background: var(--surface-2); }
.stage-step.is-current { background: var(--text); border-color: var(--text); color: #fff; }
.stage-step.is-won.is-current { background: var(--success); border-color: var(--success); }
.stage-step.is-lost.is-current { background: var(--danger); border-color: var(--danger); }
.stage-step.is-won:not(.is-current):hover:not(:disabled) { color: var(--success); border-color: var(--success-line); }
.stage-step.is-lost:not(.is-current):hover:not(:disabled) { color: var(--danger); border-color: var(--danger-line); }
.stage-path-gap { flex: 0 0 12px; }
.crm-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.crm-main > .card + .card, .crm-side > .card + .card { margin-top: 16px; }
.crm-main > .card, .crm-side > .card { margin-bottom: 0; }
.log-form { display: flex; flex-direction: column; gap: 10px; }
.log-types { margin-bottom: 0; align-self: flex-start; }
.log-actions { display: flex; justify-content: flex-end; }
.timeline { list-style: none; margin: 0; padding: 8px 24px 16px; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; }
.timeline-item + .timeline-item { border-top: 1px dashed var(--border); }
.timeline-item form { margin: 0; }
.timeline-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.timeline-item.is-logged .timeline-icon { background: var(--text); color: #fff; }
.timeline-body { flex: 1; min-width: 0; padding-top: 4px; }
.timeline-meta { font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px; align-items: baseline; }
.timeline-meta strong { font-weight: 500; }
.timeline-text { margin-top: 6px; white-space: pre-line; overflow-wrap: anywhere; font-size: 13.5px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius); padding: 8px 12px; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }
.card-head + .task-list > .task-row:first-child, .task-group-head + .task-list > .task-row:first-child { border-top: 0; }
.task-row form { margin: 0; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-main strong { font-weight: 500; font-size: 13.5px; }
.task-row.is-done .task-main strong { text-decoration: line-through; color: var(--muted); }
.task-check { width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; padding: 0; display: grid; place-items: center; }
.task-check:hover { border-color: var(--success); background: var(--success-soft); }
.task-check.is-checked { background: var(--success); border-color: var(--success); }
.task-check.is-checked::after { content: ""; width: 8px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.task-row.is-overdue { background: #fffafa; }
.task-type { color: var(--muted); margin-top: 1px; }
.task-when { font-size: 12.5px; white-space: nowrap; text-align: right; }
.task-group-head { padding: 14px 24px 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.filter-tabs + .task-group-head { border-top: 0; }
.task-group-head.is-alert { color: var(--danger); }
.task-add, .task-done { border-top: 1px solid var(--border); }
.task-add > summary, .task-done > summary { padding: 12px 20px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 6px; list-style: none; }
.task-add > summary::-webkit-details-marker, .task-done > summary::-webkit-details-marker { display: none; }
.task-add > form { padding: 0 20px 16px; }
.task-add .field { margin-bottom: 12px; }
.task-add .form-row { gap: 12px; }
.task-add [hidden] { display: none; }
.quick-fields { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.quick-field { margin: 0; }
.quick-field select { height: 34px; }
.card-warning { border-color: #fde68a; }
.card-warning .card-head { background: var(--warning-soft); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.side-danger { margin-top: 12px; text-align: right; }

/* Reports */
.metrics-6 { grid-template-columns: repeat(6, 1fr); }
.metric-sub { font-size: 12px; color: var(--muted); }
.link.is-alert { color: var(--danger); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 190px; }
.bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-track { flex: 1; width: 100%; max-width: 36px; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; min-height: 2px; background: #d4d4d8; border-radius: 4px 4px 0 0; display: flex; align-items: flex-end; overflow: hidden; }
.bar-won { width: 100%; background: var(--text); }
.bar-value { font-size: 11px; color: var(--text-2); height: 14px; }
.bar-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; height: 14px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 40px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.hbar-label { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--c, var(--text)); border-radius: 999px; min-width: 2px; }
.hbar-value { text-align: right; font-weight: 500; }
.report-table .num { text-align: right; white-space: nowrap; }
.rate { display: inline-flex; align-items: center; gap: 8px; }
.rate-track { width: 60px; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.rate-fill { display: block; height: 100%; background: var(--success); }
.dash-grid + .card { margin-top: 20px; }

/* Settings */
.stage-editor { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) 150px 120px 70px auto; gap: 10px; align-items: center; }
.stage-row select, .stage-row input { height: 34px; }
.stage-row-tools { display: inline-flex; }
.stage-count { white-space: nowrap; }
.assignee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; margin: 12px 0 0 42px; }
.code-wrap { position: relative; }
.code-copy { position: absolute; top: 8px; right: 8px; }
.hint-list { margin: 14px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.6; }
.hint-list li + li { margin-top: 6px; }
.hint-list code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 1150px) {
    .crm-grid { grid-template-columns: 1fr; }
    .metrics-6 { grid-template-columns: repeat(3, 1fr); }
    .metrics-6 .metric:nth-child(4) { border-left: 0; }
    .metrics-6 .metric:nth-child(n+4) { border-top: 1px solid var(--border); }
}
@media (max-width: 700px) {
    .metrics-6 { grid-template-columns: repeat(2, 1fr); }
    .metrics-6 .metric:nth-child(odd) { border-left: 0; }
    .metrics-6 .metric:nth-child(4) { border-left: 1px solid var(--border); }
    .metrics-6 .metric:nth-child(n+3) { border-top: 1px solid var(--border); }
    .temp-choice { grid-template-columns: 1fr; }
    .stage-row { grid-template-columns: 10px minmax(0, 1fr) auto; }
    .stage-row select, .stage-count { grid-column: 2 / -1; }
    .hbar { grid-template-columns: 110px 1fr 32px; }
    .bar-label { display: none; }
    .assignee-grid { margin-left: 0; }
    .board-col { flex-basis: 84vw; }
    .task-row, .bulk-bar { padding-left: 16px; padding-right: 16px; }
}

/* Files in chats */
.transcript-file { display: flex; flex-direction: column; gap: 8px; }
.transcript-file img { display: block; max-width: 260px; max-height: 220px; border-radius: 8px; object-fit: cover; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(127, 127, 127, .12); color: inherit; font-size: 13px; max-width: 320px; }
.file-chip:hover { background: rgba(127, 127, 127, .2); }
.file-chip-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-size { opacity: .7; white-space: nowrap; }
.live-composer { align-items: flex-end; }
.composer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.composer-main textarea { width: 100%; }
.attach-btn { cursor: pointer; margin: 0 0 4px; }
.attach-chip { display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; }
.attach-chip[hidden] { display: none; }
.attach-chip button { font-size: 16px; line-height: 1; }
.upload-toggle { display: flex; align-items: center; margin: 0; }
.upload-toggle .switch { align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.live-bar-actions { align-items: center; flex-wrap: wrap; }

/* ---------------- Chatbot settings: grouped sections ---------------- */
.settings-nav { display: flex; align-items: flex-end; gap: 6px 28px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 0; border-bottom: 1px solid var(--border); }
.settings-group { display: flex; flex-direction: column; gap: 4px; }
.settings-group-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-left: 2px; }
.settings-group-tabs { display: flex; gap: 2px; }
.settings-group-tabs button {
    display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; margin-bottom: -1px;
    border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-size: 13.5px; font-weight: 500;
    color: var(--muted); cursor: pointer; white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.settings-group-tabs button:hover { color: var(--text); background: var(--surface-2); }
.settings-group-tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.settings-group-tabs .dot-error { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.settings-group-tabs .seg-count { font-weight: 500; }
.save-bar {
    position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
    margin-top: 20px; padding: 12px 16px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 -4px 16px rgba(9, 9, 11, .06);
}
.save-bar-text { margin-right: auto; font-size: 12.5px; color: var(--muted); }

/* Q&A rows fold to a one-line summary */
.qa-head { gap: 8px; padding: 6px 8px 6px 6px; }
.qa-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer; text-align: left; border-radius: var(--radius-sm); }
.qa-toggle:hover { background: var(--surface-2); }
.qa-chevron { flex: none; color: var(--muted); transition: transform .15s; }
.qa-item.is-folded .qa-chevron { transform: rotate(-90deg); }
.qa-number { flex: none; }
.qa-number::before { content: "Q"; }
.qa-title { min-width: 0; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-badge { flex: none; margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--info-soft); color: var(--info); font-size: 11.5px; font-weight: 500; white-space: nowrap; max-width: 46%; overflow: hidden; text-overflow: ellipsis; }
.qa-badge[hidden] { display: none; }
.qa-item.is-folded .qa-head { border-bottom-color: transparent; }
.qa-item.is-folded .qa-fields { display: none; }
.qa-item { background: var(--surface); }
.qa-fields { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.qa-fields > .field, .qa-fields > .qa-source { grid-column: 1 / -1; }
.qa-fields > .question-field, .qa-fields > .keywords-field { grid-column: auto; }
.qa-head-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.qa-head-actions [hidden] { display: none; }
.qa-list { gap: 8px; }
@media (max-width: 800px) {
    .settings-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .settings-nav::-webkit-scrollbar { display: none; }
    .qa-fields { grid-template-columns: 1fr; }
    .qa-fields > .question-field, .qa-fields > .keywords-field { grid-column: 1 / -1; }
    .save-bar-text { display: none; }
}

/* ---------------- Live agent desk (one conversation) ---------------- */
.agent-desk { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; height: calc(100vh - 128px); min-height: 560px; }
.agent-chat { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.agent-chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.agent-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 16px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.agent-avatar.is-known { background: var(--text); border-color: var(--text); color: #fff; }
.agent-who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.agent-who strong { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-who > span { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--muted); }
.agent-who .chat-id { font-size: 11px; padding: 0 5px; }
.dot-sep { color: var(--border-strong); }
.agent-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.agent-actions form { margin: 0; }
.agent-state { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.agent-state strong { font-weight: 600; color: var(--text); }
.agent-state .icon { color: var(--muted); flex: none; }
.agent-state.is-waiting { background: var(--danger-soft); border-bottom-color: var(--danger-line); }
.agent-state.is-live { background: #ecfdf5; border-bottom-color: var(--success-line); }
.agent-state.is-missed { background: var(--warning-soft); border-bottom-color: #fde68a; }
.agent-state .live-dot { margin-right: 0; flex: none; width: 8px; height: 8px; }
.live-dot.is-red { background: var(--danger); box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); }

.agent-transcript { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 20px 24px; background: #f7f7f8; }
/* Agent's view: the customer on the left, your side (bot and team) on the right. */
.agent-transcript .transcript-row.from-visitor { align-self: flex-start; align-items: flex-start; }
.agent-transcript .transcript-row.from-bot, .agent-transcript .transcript-row.from-agent { align-self: flex-end; align-items: flex-end; }
.agent-transcript .from-visitor .transcript-bubble { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; box-shadow: var(--shadow-xs); }
.agent-transcript .from-bot .transcript-bubble { background: #eceef1; color: var(--text-2); border: 0; border-radius: 14px 14px 4px 14px; }
.agent-transcript .from-agent .transcript-bubble { background: var(--text); color: #fff; border: 0; border-radius: 14px 14px 4px 14px; }
.agent-transcript .from-agent .file-chip, .agent-transcript .from-agent .file-chip:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.agent-transcript .transcript-meta { padding: 0 4px; }
.agent-transcript .transcript-note span { background: var(--surface); }

.agent-composer { padding: 12px 16px 10px; border-top: 1px solid var(--border); background: var(--surface); }
.agent-composer.is-locked { text-align: center; padding: 16px; font-size: 13px; }
.agent-composer .attach-chip { margin-bottom: 8px; }
.agent-composer-box { display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px 6px 8px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.agent-composer-box:focus-within { border-color: var(--text); box-shadow: var(--ring); }
.agent-composer-box textarea { flex: 1; min-height: 34px; max-height: 160px; height: 34px; padding: 7px 4px; border: 0; box-shadow: none; resize: none; background: transparent; }
.agent-composer-box textarea:focus { box-shadow: none; }
.agent-composer-box .btn { flex: none; height: 34px; }
.composer-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin: 0; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; }
.composer-icon:hover { background: var(--surface-2); color: var(--text); }
.agent-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; }
.upload-switch { align-items: center; gap: 8px; font-size: 12.5px; }
.upload-switch .switch-track { transform: scale(.85); transform-origin: left center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

.agent-side { min-height: 0; overflow-y: auto; }
.agent-side .card { margin: 0; }
.side-section { padding: 16px 20px; }
.side-section + .side-section { border-top: 1px solid var(--border); }
.side-section h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.side-section h3 .link { text-transform: none; letter-spacing: 0; font-weight: 500; }
.side-section .facts { font-size: 13px; gap: 7px 14px; }
.side-callback { display: flex; align-items: center; gap: 10px; }
.side-callback + .side-callback { margin-top: 10px; }
.side-callback > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-callback strong { font-weight: 500; font-size: 13.5px; }
.side-danger-zone { padding-top: 12px; padding-bottom: 12px; }
.danger-link { display: inline-flex; align-items: center; gap: 6px; color: var(--danger); font-size: 13px; }

@media (max-width: 1100px) {
    .agent-desk { grid-template-columns: 1fr; height: auto; }
    .agent-chat { height: calc(100vh - 140px); min-height: 520px; }
}
@media (max-width: 700px) {
    .agent-chat-head { flex-wrap: wrap; }
    .agent-actions { width: 100%; margin-left: 0; }
    .agent-transcript { padding: 16px 12px; }
}

.danger-link { text-decoration: none; }

.convo-cta { flex: none; display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 8px 0 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface); }
.convo-cta.is-primary { background: var(--text); border-color: var(--text); color: #fff; }
.convo-row:hover .convo-cta:not(.is-primary) { border-color: var(--border-strong); }
@media (max-width: 700px) { .convo-cta { display: none; } }
.switch[hidden] { display: none; }

/* Agent voice typing */
.composer-mic { border: 0; background: none; padding: 0; }
.composer-mic[hidden] { display: none; }
.composer-mic.is-listening { color: #fff; background: var(--danger); animation: live-pulse-red 1.4s infinite; }
@keyframes live-pulse-red { 0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); } 70% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); } }
@media (prefers-reduced-motion: reduce) { .composer-mic.is-listening { animation: none; } }
.voice-options { display: inline-flex; align-items: center; gap: 12px; }
.voice-options[hidden] { display: none; }
.voice-options select { height: 28px; width: auto; padding: 0 28px 0 8px; font-size: 12px; }
.voice-options .checkbox { font-size: 12px; gap: 6px; }
[data-composer-hint].is-listening { color: var(--danger); font-weight: 500; }

/* ---------------- Oktopus Forms ---------------- */
.form-header { margin-bottom: 16px; }
.form-avatar { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--text); color: #fff; flex: none; }
.form-avatar .icon { width: 24px; height: 24px; }
.form-header .page-actions form { margin: 0; }
.lead-link-on { display: inline-flex; align-items: center; gap: 4px; color: var(--success); font-size: 12.5px; font-weight: 500; }
.forms-table .num { text-align: right; }
.forms-table .actions { justify-content: flex-end; }
.filter-tabs-end .search-input input { height: 32px; }
.toolbar-date { width: auto !important; height: 38px; }
.toolbar-end { margin-left: auto; }

/* Create */
.create-start { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; }
.create-card { margin: 0; }
.create-card h2 { font-size: 16px; margin: 10px 0 4px; }
.create-card p { margin: 0; }
.create-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); }
.create-describe .create-icon { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.template-group { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 10px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.template-card { margin: 0; }
.template-card button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 4px; width: 100%; height: 100%; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); transition: border-color .15s, box-shadow .15s, transform .1s; }
.template-card button:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.template-card button:focus-visible { box-shadow: var(--ring); border-color: var(--text); }
.template-card strong { font-weight: 600; font-size: 14px; }
.template-meta { margin-top: auto; padding-top: 6px; font-size: 12px; color: var(--muted); }
.template-swatch { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: 8px; background: var(--sb); margin-bottom: 8px; }
.template-swatch i { display: block; height: 7px; border-radius: 4px; background: #fff; }
.template-swatch i:last-child { width: 40%; background: var(--sw); }

/* Builder */
.fb-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.fb-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.fb-title input { font-size: 20px; font-weight: 600; border: 1px solid transparent; background: transparent; box-shadow: none; height: 40px; padding: 0 8px; margin-left: -8px; max-width: 420px; }
.fb-title input:hover { border-color: var(--border); }
.fb-title input:focus { border-color: var(--text); background: var(--surface); }
.fb-save-state { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.fb-save-state.is-dirty { color: var(--warning); }
.fb-save-state.is-unpublished { color: var(--info); }
.fb-save-state.is-error { color: var(--danger); white-space: normal; }
.fb-more { position: relative; }
.fb-more > summary { list-style: none; font-size: 18px; }
.fb-more > summary::-webkit-details-marker { display: none; }
.fb-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.fb-more-menu form { margin: 0; }
.fb-more-menu button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.fb-more-menu button:hover, .fb-more-menu button:focus-visible { background: var(--surface-2); }
.fb-more-menu button.danger { color: var(--danger); }
.fb-canvas.is-drop { box-shadow: 0 0 0 3px #a5b4fc; }
.fb-panel > .card + .card { margin-top: 16px; }
.fb-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.fb-panel-head h2 { font-size: 18px; margin: 0 0 4px; }
.fb-panel-head p { margin: 0; max-width: 620px; font-size: 13.5px; }
.fb-section + .fb-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.fb-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fb-section-head h3 { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0; }
.fb-pages, .fb-outline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fb-page-btn, .fb-outline-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; min-width: 0; }
.fb-page-btn:hover, .fb-outline-btn:hover { background: var(--surface-2); }
.fb-page-btn:focus-visible, .fb-outline-btn:focus-visible, .fb-lib-item:focus-visible { box-shadow: var(--ring); }
.fb-pages li.active .fb-page-btn, .fb-outline li.active .fb-outline-btn { background: var(--surface-2); font-weight: 600; }
.fb-page-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: var(--border); flex: none; }
.fb-pages li.active .fb-page-n { background: var(--text); color: #fff; }
.fb-page-btn small { margin-left: auto; color: var(--muted); }
.fb-outline li { display: flex; align-items: center; }
.fb-outline-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-outline-tools { display: flex; opacity: 0; }
.fb-outline li:hover .fb-outline-tools, .fb-outline li:focus-within .fb-outline-tools { opacity: 1; }
.fb-outline-tools button { all: unset; cursor: pointer; padding: 2px 5px; border-radius: 4px; font-size: 12px; }
.fb-outline-tools button:hover { background: var(--surface-2); }
.fb-outline-tools button:disabled { opacity: .3; cursor: default; }
.fb-req { color: var(--danger); }
.fb-ico { width: 22px; height: 22px; border-radius: 5px; display: inline-grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; flex: none; color: var(--text-2); }
.fb-search { height: 34px !important; margin-bottom: 8px; }
.fb-lib-group { margin-top: 6px; }
.fb-lib-group > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; padding: 4px 0; color: var(--text-2); }
.fb-lib-item { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 6px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; cursor: grab; font-size: 12px; line-height: 1.2; background: var(--surface); min-width: 0; }
.fb-lib-item span:last-child { overflow: hidden; text-overflow: ellipsis; }
.fb-lib-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.fb-props-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.fb-props-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.fb-row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.fb-prop { margin-bottom: 12px; }
.fb-prop label { font-size: 12.5px; }
.fb-prop input, .fb-prop select, .fb-prop textarea { font-size: 13px; }
.fb-prop input:not([type=checkbox]):not([type=color]):not([type=range]), .fb-prop select { height: 34px; }
.fb-prop-group + .fb-prop-group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.fb-prop-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.fb-prop-group > summary { cursor: pointer; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 10px; }
.fb-switch { margin: 10px 0; }
.fb-switch .switch-text strong { font-size: 13px; }
.fb-subfields { display: flex; flex-direction: column; gap: 6px; }
.fb-subfield { display: flex; align-items: center; gap: 8px; }
.fb-subfield input[type=text] { height: 32px !important; }
.fb-tip { margin-top: 16px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); font-size: 12.5px; }
.fb-tip ul { margin: 6px 0 0; padding-left: 16px; color: var(--text-2); }
.fb-tip li + li { margin-top: 4px; }
.fb-themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.fb-theme { all: unset; box-sizing: border-box; position: relative; cursor: pointer; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.fb-theme:hover { border-color: var(--border-strong); }
.fb-theme.active, .fb-theme:focus-visible { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.fb-theme-swatch { display: block; padding: 8px; }
.fb-theme-swatch i { display: flex; flex-direction: column; gap: 3px; padding: 6px; }
.fb-theme-swatch b { display: block; height: 5px; border-radius: 3px; }
.fb-theme-name { display: block; font-size: 11.5px; padding: 5px 8px; border-top: 1px solid var(--border); font-weight: 500; }
.fb-theme-del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.fb-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fb-color { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 400; margin: 0; cursor: pointer; }
.fb-color input { width: 28px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; flex: none; }
.fb-range { display: flex; align-items: center; gap: 8px; }
.fb-range input { flex: 1; margin: 0; }
.fb-range output { min-width: 34px; text-align: right; font-size: 12px; color: var(--text-2); }
.fb-contrast { font-size: 12.5px; padding: 8px 10px; border-radius: 6px; background: var(--warning-soft); color: var(--warning); margin: 12px 0 0; }
.fb-contrast.ok { background: var(--success-soft); color: var(--success); }
.fb-rule { margin-bottom: 12px; }
.fb-rule-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.fb-rule-body { padding: 12px 16px 16px; }
.fb-rule-label { margin: 6px 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .03em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.fb-rule-label select { width: auto; height: 28px; font-size: 12px; }
.fb-cond { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.fb-cond select, .fb-cond input { flex: 1 1 160px; height: 34px; font-size: 13px; width: auto; }
.fb-cond .btn-icon { flex: none; }
.danger-link { color: var(--danger) !important; }

/* Share */
.share-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.share-grid > div > .card + .card { margin-top: 16px; }
.share-grid .card { margin-bottom: 0; }
.install-steps { margin: 0; display: grid; gap: 10px; font-size: 13px; }
.install-steps dt { font-weight: 600; }
.install-steps dd { margin: 2px 0 0; color: var(--text-2); }
.share-grid .segmented { margin-bottom: 12px; }

/* Leads mapping */
.map-table { width: 100%; border-collapse: collapse; }
.map-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 0 0 8px; }
.map-table td { padding: 6px 0; vertical-align: top; }
.map-table td:first-child { width: 42%; padding-right: 16px; padding-top: 14px; }
.map-table td:first-child label { font-weight: 500; font-size: 13.5px; }
.map-table select { height: 36px; }

/* Submission */
.answers { display: grid; grid-template-columns: minmax(140px, 35%) 1fr; gap: 12px 20px; margin: 0; font-size: 14px; }
.answers dt { color: var(--muted); }
.answers dd { margin: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.answers dd .answer-text { white-space: pre-line; }
.answer-img { max-width: 240px; max-height: 180px; border-radius: 8px; border: 1px solid var(--border); }
.side-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.side-actions form { margin: 0; }

/* Analytics */
.analytics-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.analytics-head p { margin: 0; }
.analytics-head select { width: auto; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend span { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.lg-views { background: #c7d2fe; }
.lg-subs { background: #4f46e5; }
.bar-track.pair { gap: 2px; max-width: 30px; }
.bar-track.pair span { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; display: block; }
.bar-v { background: #c7d2fe; }
.bar-s { background: #4f46e5; }

@media (max-width: 900px) {
    .create-start, .share-grid { grid-template-columns: 1fr; }
    .answers { grid-template-columns: 1fr; gap: 4px; }
    .answers dd { margin-bottom: 10px; }
}

.alert[hidden] { display: none; }


/* ---------------- Polish: pipeline without sideways scrolling ---------------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; overflow: visible; padding-bottom: 0; align-items: start; }
.board-col { flex: none; max-height: none; min-width: 0; }
.board-cards { max-height: 560px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.board-cards::-webkit-scrollbar { width: 6px; }
.board-cards::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.board-card-top strong { overflow: hidden; text-overflow: ellipsis; }

/* Origin switch (Leads tabs and the dashboard's Chatbots / Forms switch) */
.origin-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.dash-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 20px; }
.origin-tab { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); text-decoration: none; transition: border-color .15s, box-shadow .15s; min-width: 0; }
.origin-tab:hover { border-color: var(--border-strong); }
.origin-tab:focus-visible { box-shadow: var(--ring); outline: none; }
.origin-tab.active { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.origin-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.origin-tab.active .origin-icon { background: var(--text); color: #fff; }
.origin-text { display: flex; flex-direction: column; min-width: 0; }
.origin-text strong { font-weight: 600; font-size: 14px; }
.origin-text span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.origin-hint { margin: -6px 0 14px; font-size: 13px; color: var(--muted); }
.origin-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.origin-chip.is-form { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.origin-chip.is-bot { background: #f0fdfa; border-color: #99f6e4; color: #0f766e; }
.list-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.is-alert-text { color: var(--danger); font-weight: 500; }

/* Create form: blank form as one tidy row */
.create-blank { display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin: 0; flex-wrap: wrap; }
.create-blank-text { flex: 1 1 200px; min-width: 0; }
.create-blank-text h2 { font-size: 15px; margin: 0; }
.create-blank-text p { margin: 2px 0 0; }
.create-blank input[type=text] { flex: 1 1 240px; width: auto; }

/* ---------------- Polish: form builder ---------------- */
.fb-ico { width: 26px; height: 26px; border-radius: 7px; display: inline-grid; place-items: center; background: var(--surface-2); border: 0; color: var(--text-2); flex: none; }
.fb-ico svg { width: 15px; height: 15px; }
.fb-lib-item { padding: 6px 8px; gap: 8px; font-size: 12.5px; border-radius: 8px; transition: border-color .15s, background .15s, box-shadow .15s; }
.fb-lib-item:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-xs); }
.fb-lib-item:hover .fb-ico { background: var(--text); color: #fff; }
.fb-lib-item { min-height: 40px; line-height: 1.25; }
.fb-lib-item span:last-child { white-space: normal; overflow: visible; }
.fb-lib-group { border-top: 1px solid var(--border); padding-top: 4px; }
.fb-lib-group:first-of-type { border-top: 0; }
.fb-lib-group > summary { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; font-size: 12.5px; font-weight: 600; color: var(--text); list-style: none; }
.fb-lib-group > summary::-webkit-details-marker { display: none; }
.fb-lib-group > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-left: 8px; }
.fb-lib-group[open] > summary::after { transform: rotate(45deg); }
.fb-lib-group > summary small { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.fb-search-wrap { position: relative; margin-bottom: 6px; }
.fb-search-wrap .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.fb-search-wrap .fb-search { padding-left: 32px; margin: 0; }
.fb-icon-btn { all: unset; box-sizing: border-box; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: var(--text-2); cursor: pointer; }
.fb-icon-btn svg { width: 15px; height: 15px; }
.fb-icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.fb-icon-btn:focus-visible { box-shadow: var(--ring); }
.fb-icon-btn:disabled { opacity: .3; cursor: default; }
.fb-icon-btn.is-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.fb-outline-tools { gap: 0; }
.fb-outline-tools .fb-icon-btn { width: 24px; height: 24px; }
.fb-outline-btn { padding: 5px 6px; }
.fb-outline-btn .fb-ico { width: 24px; height: 24px; }
.fb-props-head { flex-direction: row; align-items: center; justify-content: space-between; }
.fb-props-head h3 { min-width: 0; }
.fb-props-head > span { flex-basis: 100%; }
.fb-props-head:has(> span) { flex-wrap: wrap; }
.fb-add-link { all: unset; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; padding: 4px 6px; border-radius: 6px; margin: 2px 0 8px -6px; }
.fb-add-link:hover { background: var(--surface-2); color: var(--text); }
.fb-rule-label { text-transform: uppercase; }
.fb-contrast { display: flex; align-items: center; gap: 8px; }
.fb-theme-del { display: grid; place-items: center; padding: 0; }
.fb-theme-del svg { width: 12px; height: 12px; }
.fb-section-head .btn .icon { margin-right: 2px; }
.template-swatch { border: 1px solid var(--border); }
.fb-lib-item { font-size: 12px; } .fb-lib-item span:last-child { overflow-wrap: anywhere; min-width: 0; }

/* "Admin" label next to the product name in the sidebar */
.brand-tag { margin-left: -2px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 999px; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

/* ================= Form builder workspace =================
   One framed workspace: a toolbar, then three panes (fields | form | settings) that each scroll
   on their own, so the page never turns into one long strip. */
.fb-top { margin-bottom: 8px; }
.fb-title { gap: 12px; }
.fb-title input { width: auto; field-sizing: content; min-width: 160px; max-width: min(460px, 100%); }
.fb-tabs { margin-bottom: 16px; }

.fb-shell { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.fb-toolbar { display: flex; align-items: center; gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.fb-toolbar .fb-modes { margin: 0; flex: none; }
.fb-toolbar-hint { margin: 0 0 0 auto; font-size: 12.5px; color: var(--muted); text-align: right; min-width: 0; }

.fb { display: grid; grid-template-columns: 272px minmax(0, 1fr) 316px; height: max(560px, calc(100vh - 250px)); }
.fb-left, .fb-right { min-height: 0; overflow-y: auto; padding: 0; background: var(--surface); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.fb-left { border-right: 1px solid var(--border); }
.fb-right { border-left: 1px solid var(--border); padding: 16px; }
.fb-center { min-width: 0; min-height: 0; overflow-y: auto; padding: 20px 28px 32px; background-color: #f4f4f5; background-image: radial-gradient(#e4e4e7 1px, transparent 1px); background-size: 18px 18px; scrollbar-width: thin; }
.fb[data-mode="logic"], .fb[data-mode="settings"] { grid-template-columns: minmax(0, 1fr); }
.fb[data-mode="logic"] .fb-left, .fb[data-mode="logic"] .fb-right,
.fb[data-mode="settings"] .fb-left, .fb[data-mode="settings"] .fb-right { display: none; }
.fb[data-mode="logic"] .fb-center, .fb[data-mode="settings"] .fb-center { background: var(--surface-2); padding: 28px 24px 40px; }
.fb[data-mode="design"] .fb-left { padding: 16px; }

/* Canvas: the real form, centred like the page it will sit on */
.fb-canvas { max-width: 720px; margin: 0 auto; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; min-height: 360px; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.12); transition: box-shadow .15s; }
.fb-canvas.is-drop { box-shadow: 0 0 0 2px var(--text), 0 8px 24px -12px rgba(0,0,0,.12); }

/* Page strip */
.fb-pagebar { max-width: 720px; margin: 0 auto 14px; display: flex; align-items: center; gap: 8px; }
.fb-pagebar[hidden] { display: none; }
.fb-pagebar-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.fb-page-tab, .fb-add-page { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 6px; border-radius: 999px; font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.fb-page-tab { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.fb-page-tab:hover { border-color: var(--border-strong); color: var(--text); }
.fb-page-tab.active { background: var(--text); border-color: var(--text); color: #fff; }
.fb-page-tab .fb-page-n { width: 20px; height: 20px; background: var(--surface-2); color: var(--text-2); }
.fb-page-tab.active .fb-page-n { background: rgba(255,255,255,.18); color: #fff; }
.fb-page-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.fb-add-page { padding: 0 12px; color: var(--text-2); border: 1px dashed var(--border-strong); flex: none; }
.fb-add-page:hover { color: var(--text); border-color: var(--text); background: var(--surface); }
.fb-page-tab:focus-visible, .fb-add-page:focus-visible { box-shadow: var(--ring); }

/* Left pane: Add fields | Outline */
.fb-left-tabs { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; padding: 0 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
.fb-left-tabs button { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.fb-left-tabs button:hover { color: var(--text); }
.fb-left-tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.fb-left-tabs button:focus-visible { box-shadow: inset var(--ring); }
.fb-left-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); font-size: 11px; display: inline-grid; place-items: center; color: var(--text-2); }
.fb-left-body { padding: 12px; }
.fb-left-note { margin: 0 4px 8px; font-size: 12px; color: var(--muted); }
.fb-left-empty { padding: 16px 8px; font-size: 13px; color: var(--muted); text-align: center; list-style: none; }

/* Field library: one clean list per group */
.fb-search-wrap { margin-bottom: 8px; }
.fb-lib-group { border-top: 0; padding-top: 0; }
.fb-lib-group + .fb-lib-group { margin-top: 2px; }
.fb-lib-group > summary { padding: 8px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-radius: 6px; }
.fb-lib-group > summary:hover { color: var(--text); }
.fb-lib-group > summary small { font-size: 11px; letter-spacing: 0; }
.fb-lib-list { display: flex; flex-direction: column; gap: 1px; padding-bottom: 6px; }
.fb-lib-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 13px; line-height: 1.3; color: var(--text); box-shadow: none; }
.fb-lib-item:hover { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.fb-lib-item:active { cursor: grabbing; }
.fb-lib-item .fb-ico { width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); }
.fb-lib-item:hover .fb-ico { background: var(--text); border-color: var(--text); color: #fff; }
.fb-lib-name { flex: 1; min-width: 0; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis; }
.fb-lib-add { color: var(--muted); opacity: 0; transition: opacity .12s; flex: none; }
.fb-lib-item:hover .fb-lib-add, .fb-lib-item:focus-visible .fb-lib-add { opacity: 1; }

/* Outline */
.fb-outline { gap: 1px; }
.fb-outline li { border-radius: 8px; }
.fb-outline li:hover { background: var(--surface-2); }
.fb-outline li.active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--text); }
.fb-outline-btn { padding: 4px 6px; min-height: 36px; font-size: 13px; }
.fb-outline-btn:hover { background: transparent; }
.fb-outline li.active .fb-outline-btn { background: transparent; }
.fb-outline-tools { padding-right: 4px; }

/* Right pane */
.fb-props-head { margin-bottom: 14px; padding-bottom: 14px; }
.fb-props-head h3 { font-size: 15px; }
.fb-tip { margin-top: 20px; background: var(--surface-2); border: 1px solid var(--border); }

/* Logic and Settings: centred panels */
.fb-panel { max-width: 820px; margin: 0 auto; }
.fb-panel-head { align-items: center; }
.fb-panel-head h2 { font-size: 17px; }
.fb-panel > .empty-state { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 40px 24px; }
.fb-panel > .empty-state h3 { font-size: 15px; margin: 0 0 4px; }
.fb-panel > .empty-state p { margin: 0 auto; }

@media (max-width: 1280px) {
    .fb { grid-template-columns: 248px minmax(0, 1fr) 284px; }
    .fb-center { padding: 16px 16px 28px; }
    .fb-toolbar-hint { display: none; }
}
@media (max-width: 1080px) {
    .fb { grid-template-columns: 248px minmax(0, 1fr); height: auto; }
    .fb-left, .fb-center { height: max(520px, calc(100vh - 250px)); }
    .fb-right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 760px) {
    .fb { grid-template-columns: 1fr; }
    .fb-left { height: auto; max-height: 360px; border-right: 0; border-bottom: 1px solid var(--border); }
    .fb-center { height: auto; padding: 12px; }
    .fb-toolbar { overflow-x: auto; }
}
/* ================= Plans ================= */
/* Sidebar: products the plan doesn't include */
.nav-link.is-locked { color: var(--muted); }
.nav-link.is-locked .icon { opacity: .6; }
.nav-link.is-locked .nav-count .icon { opacity: 1; }

/* Customer Plan page */
.plan-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px; flex-wrap: wrap; }
.plan-summary-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.plan-summary-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--text); color: #fff; flex: none; }
.plan-summary-label { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.plan-summary h2 { margin: 2px 0 2px; font-size: 20px; }
.plan-summary p { margin: 0; }
.plan-products { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.plan-products li { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); }
.plan-products li.is-on { color: var(--text); background: var(--surface); border-color: var(--border-strong); font-weight: 500; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; align-items: stretch; }
.plan-card { position: relative; display: flex; flex-direction: column; padding: 22px; margin: 0; }
.plan-card.is-featured { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.plan-card.is-current { background: var(--surface-2); }
.plan-flag { position: absolute; top: -10px; left: 20px; padding: 2px 8px; border-radius: 999px; background: var(--text); color: #fff; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.plan-card-head h3 { margin: 0; font-size: 17px; }
.plan-card-head p { margin: 4px 0 0; font-size: 13px; min-height: 2.6em; }
.plan-price { margin: 16px 0 0; display: flex; align-items: baseline; gap: 4px; }
.plan-price strong { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.plan-price span { color: var(--muted); font-size: 13px; }
.plan-price-note { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.plan-includes { list-style: none; margin: 18px 0 0; padding: 16px 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; flex: 1; }
.plan-includes li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.plan-includes li > .icon { margin-top: 2px; flex: none; }
.plan-includes li span { display: flex; flex-direction: column; gap: 2px; }
.plan-includes li small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.plan-includes li.is-off { color: var(--muted); }
.plan-includes li.is-off strong { font-weight: 500; text-decoration: line-through; text-decoration-color: var(--border-strong); }
.plan-card-foot { margin-top: 20px; }
.plan-card-foot form { margin: 0; }
.plan-card-foot .btn { width: 100%; justify-content: center; }
.btn.is-static { pointer-events: none; }
.plan-footnote { display: flex; align-items: center; gap: 6px; margin-top: 18px; }

/* Platform: plan on the organization page and list */
.plan-admin .card-body { display: flex; flex-direction: column; gap: 12px; }
.plan-current { display: flex; align-items: baseline; gap: 8px; }
.plan-current strong { font-size: 16px; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); color: var(--muted); }
.plan-chip.is-on { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.plan-change { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-change select { flex: 1 1 180px; width: auto; }
.toolbar select { width: auto; }
.signup-plan { margin-bottom: 16px; }

/* Dashboard without a plan */
.noplan-card { display: flex; align-items: center; gap: 18px; padding: 24px; flex-wrap: wrap; }
.noplan-card > div { flex: 1 1 280px; }
.noplan-card h2 { margin: 0 0 4px; font-size: 18px; }
.noplan-card p { margin: 0; }
.noplan-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--text); color: #fff; flex: none; }
.noplan-products { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.noplan-product { display: flex; gap: 12px; padding: 18px; margin: 0; }
.noplan-product p { margin: 4px 0 0; }
.noplan-in { color: var(--text-2); font-weight: 500; }
.plan-change-label { flex-basis: 100%; margin: 0; font-size: 12.5px; }

/* ---------- Account checks ---------- */
.check-step .qa-head { padding: 8px 10px 8px 14px; }
.check-step-n { font-size: 12px; font-weight: 600; color: var(--muted); }
.check-rule { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr); gap: 12px; }
.check-rule .field[hidden] { display: none; }
.check-result { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.check-result-msg { margin: 0 0 12px; }
.check-result-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.check-result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-result-list li { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.check-result-list li.is-next { border-color: var(--text); }
.check-result-list strong { display: block; font-weight: 500; }
.check-result-list span { display: block; font-size: 12.5px; color: var(--muted); }
.check-result-list .check-link { color: var(--text); font-weight: 500; }
.check-mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid !important; place-items: center; font-size: 11px !important; font-weight: 700; color: #fff !important; background: var(--danger, #dc2626); }
.is-done .check-mark { background: var(--success); }
.is-done strong { color: var(--muted); }
@media (max-width: 800px) { .check-rule { grid-template-columns: 1fr; gap: 0; } }
.check-step input, .check-step select, .check-step textarea { width: 100%; }
.check-step .form-row .field, .check-rule .field { min-width: 0; }
/* Code keeps its indentation but wraps long lines, so there is no sideways scrolling */
.code-block.code-nowrap { white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere; }
.check-step .qa-fields > .check-rule, .check-step .qa-fields > .form-row { grid-column: 1 / -1; }
.check-rule.is-off .field:not(:first-child) { opacity: .4; }
.example-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.example-pick { font-size: 12.5px; padding: 5px 11px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); text-decoration: none; background: var(--surface); }
.example-pick:hover, .example-pick.active { border-color: var(--text); color: var(--text); }
.check-result-list .is-step .check-mark { background: var(--text); }
.check-code { margin: 6px 0 2px; padding: 8px 10px; background: #0a0a0a; color: #e4e4e7; border-radius: 6px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Email automation ---------- */
.call-outcome { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.call-outcome[hidden] { display: none; }
.call-outcome label { margin: 0; font-size: 13px; white-space: nowrap; }
.call-outcome select { max-width: 260px; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.var-chips .example-pick { font-family: var(--mono); font-size: 11.5px; cursor: pointer; }
.email-preview { position: sticky; top: 16px; }
.email-preview-meta { padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 12.5px; display: grid; gap: 4px; }
.email-preview-meta span { display: inline-block; width: 58px; color: var(--muted); }
.email-preview-meta strong { font-weight: 500; word-break: break-word; }
.email-preview-frame { display: block; width: 100%; height: 420px; border: 0; background: #fff; }
.is-ok { color: var(--success); }

/* ==========================================================================
   Mobile app shell, PWA and CRM on phones
   ========================================================================== */
.brand-row { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; }
.brand-row .brand { flex: 1; min-width: 0; }
.nav-toggle, .nav-close, .nav-backdrop, .tabbar, .filter-toggle, .board-jump, .show-touch { display: none; }
button.nav-link { width: 100%; border: 0; background: none; font: inherit; font-weight: 500; font-size: 13.5px; cursor: pointer; text-align: left; }
.nav-link[hidden] { display: none; }

/* "/" hint inside search boxes */
.search-key {
    position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
    min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center;
    font: 500 11px var(--mono); color: var(--muted); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 5px; pointer-events: none;
}
.search-input input:focus ~ .search-key, .search-input input:not(:placeholder-shown) ~ .search-key { display: none; }

/* Leads that have gone quiet */
.is-quiet { color: var(--warning); }
.tab-count.is-warn { background: var(--warning-soft); border-color: #fde68a; color: var(--warning); }
.lead-cell-top { display: flex; align-items: center; gap: 6px; }
.lead-quick { display: inline-flex; gap: 2px; margin-left: auto; opacity: 0; transition: opacity .12s; }
.lead-quick .btn-icon { width: 26px; height: 26px; }
tbody tr:hover .lead-quick, .lead-quick:focus-within { opacity: 1; }

/* Pipeline headline numbers */
.pipe-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.pipe-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.pipe-stat span { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-stat strong { font-size: 20px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
a.pipe-stat.is-warn { border-color: #fde68a; background: var(--warning-soft); }
a.pipe-stat.is-warn strong, a.pipe-stat.is-warn span { color: var(--warning); }
a.pipe-stat.is-warn:hover { border-color: var(--warning); }

/* Board cards: the link fills the card; actions show on touch screens */
.board-card-link { display: block; color: inherit; }
.board-card.is-quiet { border-left: 3px solid #fbbf24; }
.board-card.is-moved { animation: card-moved 1.2s ease-out; }
@keyframes card-moved { 0% { box-shadow: 0 0 0 3px rgba(21, 128, 61, .45); } 100% { box-shadow: var(--shadow-xs); } }
.board-card-actions { display: none; align-items: center; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.board-move { flex: 1; min-width: 0; width: auto; height: 30px !important; font-size: 12.5px !important; margin-left: auto; }

@media (hover: none) {
    .hide-touch, .search-key { display: none; }
    .show-touch { display: inline; }
    .lead-quick { opacity: 1; }
    .board-card-actions { display: flex; }
    .board-card[draggable=true] { cursor: pointer; }
}

/* ---------- Phones and small tablets: the sidebar becomes a drawer ---------- */
@media (max-width: 900px) {
    :root { --topbar-h: 52px; --tabbar-h: 58px; }
    /* Wide tables scroll inside their cards instead of zooming the whole page out. */
    html, body { overflow-x: clip; }
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
        width: min(300px, 86vw); height: 100%; height: 100dvh;
        padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
        transform: translateX(-100%); transition: transform .25s cubic-bezier(.22, 1, .36, 1), visibility .25s;
        visibility: hidden; box-shadow: var(--shadow-md);
    }
    body.nav-open .sidebar { transform: none; visibility: visible; }
    .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(9, 9, 11, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
    body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
    body.nav-open { overflow: hidden; }
    .nav-close, .nav-toggle { display: inline-flex; }
    .nav-toggle { width: 36px; height: 36px; margin-left: -6px; }
    .nav-link { height: 40px; }

    .topbar { height: auto; min-height: var(--topbar-h); padding: env(safe-area-inset-top) 12px 0; gap: 8px; justify-content: flex-start; }
    .topbar .breadcrumbs { flex: 1; }
    /* Only the parent page and the current one fit */
    .breadcrumbs > a, .breadcrumbs > .sep { display: none; }
    .breadcrumbs > a:nth-last-child(3), .breadcrumbs > .sep:nth-last-child(2) { display: inline; }
    .breadcrumbs .current { font-weight: 600; }

    .tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
        padding: 0 4px env(safe-area-inset-bottom);
        background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
    }
    .tab {
        flex: 1; min-width: 0; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: 0; border: 0; background: none; font: inherit; font-size: 10.5px; font-weight: 500; color: var(--muted);
        cursor: pointer; -webkit-tap-highlight-color: transparent;
    }
    .tab.active { color: var(--text); }
    .tab.active .tab-icon::after { content: ""; position: absolute; left: 50%; top: -9px; width: 18px; height: 2px; margin-left: -9px; border-radius: 2px; background: var(--text); }
    .tab-icon { position: relative; display: grid; place-items: center; }
    .tab-icon .icon { width: 20px; height: 20px; }
    .tab-badge { position: absolute; top: -5px; left: 12px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; line-height: 1; box-shadow: 0 0 0 2px var(--surface); }
    body.has-tabbar .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

    .board-jump {
        display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
        position: sticky; top: var(--topbar-h); z-index: 15; margin: 0 -14px 10px; padding: 8px 14px; background: var(--bg);
    }
    .board-jump::-webkit-scrollbar { display: none; }
    .board-jump a { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
    .board-jump a.active { background: var(--text); border-color: var(--text); color: #fff; }
    .board-jump a.active .board-count { color: #d4d4d8; }
    .board { margin: 0 -14px; padding: 0 14px 12px; scroll-snap-type: x mandatory; scroll-padding-left: 14px; scrollbar-width: none; }
    .board::-webkit-scrollbar { display: none; }
    .board-col { flex-basis: 86vw; max-height: none; }
    .board-card-actions { display: flex; }
    .board-card .btn-icon { width: 34px; height: 30px; }
    .hide-touch { display: none; }
    .show-touch { display: inline; }
    .lead-quick { opacity: 1; }
}

/* ---------- Phones: compact layout ---------- */
@media (max-width: 700px) {
    /* 16px stops iPhones zooming into fields */
    input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=tel], input[type=number],
    input[type=date], input[type=datetime-local], input[type=time], select, textarea { font-size: 16px; }
    input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], select { height: 40px; }

    h1 { font-size: 19px; }
    .page-header { gap: 12px; margin-bottom: 16px; align-items: flex-start; }
    .page-header > div:first-child { min-width: 0; }
    .page-header p { font-size: 13px; }
    .page-actions {
        width: calc(100% + 28px); margin: 0 -14px; padding: 0 14px 2px;
        overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none;
    }
    .page-actions::-webkit-scrollbar { display: none; }
    .page-actions > * { flex: none; }
    .page-actions form { margin: 0; }

    .alert { padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
    .card { margin-bottom: 14px; }
    .card-body { padding: 16px 14px; }
    .card-head { padding: 12px 14px; flex-wrap: wrap; }
    .card-head, .card-body, .list-row, .toolbar, .card-foot, .pagination-wrap, .task-row, .bulk-bar, .filter-tabs { padding-left: 14px; padding-right: 14px; }
    th, td { padding: 10px 12px; }
    th:first-child, td:first-child { padding-left: 14px; }
    th:last-child, td:last-child { padding-right: 14px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
    .stat { padding: 12px 14px; }
    .stat-value { font-size: 22px; }
    .stat-icon { width: 28px; height: 28px; }
    .empty-state { padding: 36px 16px; }
    .section-title { margin: 24px 0 10px; }

    /* Horizontal chip rows instead of wrapping blocks */
    .origin-tabs { display: flex; overflow-x: auto; scrollbar-width: none; gap: 8px; margin: 0 -14px 10px; padding: 2px 14px 4px; scroll-snap-type: x proximity; scroll-padding: 0 14px; }
    .origin-tabs::-webkit-scrollbar, .filter-tabs::-webkit-scrollbar, .stage-path::-webkit-scrollbar { display: none; }
    .origin-tab { flex: none; padding: 8px 12px; gap: 8px; scroll-snap-align: start; }
    .filter-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-top: 8px; padding-bottom: 8px; }
    .filter-tabs a { flex: none; white-space: nowrap; }

    /* Lead filters: search + a "Filters" button that opens the dropdowns */
    .crm-filters { gap: 8px; }
    .crm-filters .search-input { flex: 1 1 0; max-width: none; min-width: 0; }
    .filter-toggle { display: inline-flex; height: 40px; }
    .crm-filters select, .crm-filters > .btn:not(.filter-toggle) { display: none; }
    .crm-filters.show-filters select { display: block; flex: 1 1 calc(50% - 4px); min-width: 0; }
    .crm-filters.show-filters > .btn:not(.filter-toggle) { display: inline-flex; flex: 1 1 calc(50% - 4px); }
    .board-filters { gap: 8px; }
    .board-filters .search-input { flex: 1 1 100%; min-width: 0; max-width: none; }
    .board-filters select { flex: 1 1 calc(33% - 6px); min-width: 0; }

    /* Lead list: one card per lead */
    .lead-table thead { display: none; }
    .lead-table, .lead-table tbody { display: block; }
    .lead-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .lead-table tbody tr:last-child { border-bottom: 0; }
    .lead-table td, .lead-table td:first-child, .lead-table td:last-child { display: block; padding: 0; border: 0; background: none !important; font-size: 12.5px; }
    .lead-table tr:has(> .check-col) { position: relative; padding-left: 44px; }
    .lead-table td.check-col, .lead-table td.check-col:first-child { position: absolute; left: 14px; top: 15px; }
    .lead-table td.lead-cell { flex: 1 1 100%; min-width: 0; max-width: none; font-size: 14px; }
    .lead-table td[data-label]::before { content: attr(data-label) " "; color: var(--muted); }
    .lead-table td[data-label=Stage]::before, .lead-table td[data-label=Rating]::before, .lead-table td[data-label=Source]::before, .lead-table td[data-label=Owner]::before { content: none; }
    .lead-table td[data-label=Source] .muted.small { display: none; }
    .lead-table .lead-answers { display: none; }
    .lead-table .lead-name { font-weight: 600; }
    .lead-contact { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .lead-quick .btn-icon { width: 34px; height: 32px; }
    .owner-chip { font-size: 12.5px; }
    .owner-dot { width: 20px; height: 20px; font-size: 10px; }
    .bulk-bar { position: sticky; top: var(--topbar-h); z-index: 10; }
    .bulk-bar select { flex: 1; min-width: 0; }

    /* Lead page */
    .lead-title { gap: 10px; }
    .lead-avatar { width: 38px; height: 38px; font-size: 15px; }
    .lead-title h1 { font-size: 18px; gap: 8px; }
    .lead-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; width: 100%; margin: 0; padding: 0; }
    .lead-actions .btn { padding: 0 6px; height: 44px; flex-direction: column; gap: 2px; font-size: 11.5px; }
    .stage-path { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px 14px; padding: 0 14px 2px; }
    .stage-path form, .stage-path-gap { flex: none; }
    .stage-step { height: 34px; }
    .crm-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .crm-main > .card + .card, .crm-side > .card + .card { margin-top: 14px; }
    .log-types { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
    .call-outcome { flex-wrap: wrap; }
    .call-outcome select { max-width: none; }

    .pipe-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
    .pipe-stat { padding: 10px 12px; }
    .pipe-stat strong { font-size: 17px; }

    .auth-main { padding: 28px 16px calc(28px + env(safe-area-inset-bottom)); place-items: start center; }
    .auth-card h1 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar, .nav-backdrop { transition: none; }
    .board-card.is-moved { animation: none; }
}

/* ---------- Chatbot builder: knowledge base and guides on the New chatbot page ---------- */
.settings-group-tabs .settings-tab-link {
    display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; margin-bottom: -1px;
    border-bottom: 2px solid transparent; font-size: 13.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.settings-group-tabs .settings-tab-link:hover { color: var(--text); background: var(--surface-2); }
.settings-tab-out { opacity: .55; width: 12px; height: 12px; }
.kb-drop {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
    padding: 28px 20px; margin: 0; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg);
    background: var(--surface-2); cursor: pointer; font-weight: 400; transition: border-color .15s, background .15s;
}
.kb-drop:hover, .kb-drop.is-over { border-color: var(--primary); background: var(--surface); }
.kb-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.kb-drop-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }
.kb-files { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.kb-files li { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.kb-files li.error { border: 0; padding: 0; }
.kb-file-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-section { margin: 28px 0 12px; }
.guide-new .card-head h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.example-pick { font: inherit; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
