/* Kivorsa design system: violet brand, dark sidebar, soft light surfaces (dark mode follows the OS). */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('./inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('./inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('./inter-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
:root {
  --brand: #7c5cff;
  --brand-600: #6a46f2;
  --brand-50: #f3efff;
  --brand-100: #e7defe;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #a855f7 55%, #e879f9 100%);
  --side-bg: #15112a;
  --side-bg-2: #211a3d;
  --side-text: #b8b2d6;
  --side-active: rgba(139, 92, 246, 0.22);
  --bg: #f4f3f9;
  --panel: #ffffff;
  --panel-2: #faf9fd;
  --line: #ecebf4;
  --line-2: #dfdcec;
  --text: #1c1830;
  --muted: #7c7894;
  --in: #f2f1f8;
  --out: #efe9ff;
  --note: #fff7d9;
  --note-line: #f2dea0;
  --green: #15803d;
  --green-bg: #e3f6ea;
  --red: #dc2626;
  --red-bg: #fdecec;
  --blue: #2563eb;
  --blue-bg: #e8effe;
  --amber: #a16207;
  --amber-bg: #fef3c7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 17, 48, 0.04), 0 8px 28px rgba(23, 17, 48, 0.06);
  --shadow-lg: 0 24px 60px rgba(23, 17, 48, 0.22);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #9b84ff;
    --brand-600: #8a70ff;
    --brand-50: #241d42;
    --brand-100: #2f2657;
    --side-bg: #0d0a1c;
    --side-bg-2: #1a1533;
    --bg: #110e20;
    --panel: #19152c;
    --panel-2: #1e1934;
    --line: #2a2445;
    --line-2: #362e58;
    --text: #eceaf6;
    --muted: #9d97bb;
    --in: #241e3c;
    --out: #2f2559;
    --note: #352c18;
    --note-line: #5c4b1d;
    --green: #4ade80;
    --green-bg: #12301f;
    --red: #f87171;
    --red-bg: #3a1717;
    --blue: #7aa2ff;
    --blue-bg: #18244a;
    --amber: #fbbf24;
    --amber-bg: #3a2e10;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
/* Phones: the visible height (address bar included), no font inflation in landscape, no grey tap flash. */
@supports (height: 100dvh) { #app { height: 100dvh; } }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-600); text-decoration: none; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 0; }
h4 { font-size: 13px; margin: 0 0 10px; color: var(--text); font-weight: 650; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 18px; }
.pad-x { padding: 0 16px; }
.grow { flex: 1; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.error { color: var(--red); }
.warn { color: var(--amber); }
.splash { display: grid; place-items: center; height: 100%; color: var(--muted); }
.icon { flex: none; display: block; }

/* inputs */
input, select, textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--radius-sm);
  padding: 8px 11px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
input[type='checkbox'], input[type='radio'] { width: auto; accent-color: var(--brand); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0; font-weight: 550; }
label > input, label > select, label > textarea { margin-top: 5px; color: var(--text); font-size: 14px; font-weight: 400; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; color: var(--text); white-space: nowrap; transition: 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-600); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(124, 92, 255, 0.28); }
.btn.primary:hover:not(:disabled) { background: var(--brand-600); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red-bg); background: var(--red-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand-600); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.btn.more { display: flex; margin: 12px auto; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; flex: none; transition: 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--brand-50); color: var(--brand-600); }
.icon-btn.on { background: var(--brand-50); color: var(--brand-600); }
.icon-btn:disabled { opacity: 0.4; }
button.link { border: 0; background: none; color: var(--brand-600); padding: 0; cursor: pointer; font-weight: 600; }

/* pills & chips */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--brand-50); color: var(--brand-600); vertical-align: middle; text-transform: none; }
.pill.purple { background: var(--brand-50); color: var(--brand-600); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.soft { background: var(--in); color: var(--muted); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--brand-50); color: var(--brand-600); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.add { border: 1px dashed var(--line-2); background: transparent; color: var(--muted); padding: 3px 7px; cursor: pointer; }
.chip-x { border: 0; background: none; color: inherit; padding: 0 0 0 2px; cursor: pointer; font-size: 14px; line-height: 1; opacity: 0.6; }
.chip-x:hover { opacity: 1; }
.delta { font-size: 12px; font-weight: 700; margin-left: 6px; }
.delta.good { color: var(--green); }
.delta.bad { color: var(--red); }

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.banner { display: flex; align-items: center; gap: 8px; background: var(--brand-50); color: var(--brand-600); padding: 9px 16px; font-size: 13px; font-weight: 550; }
.banner.warn { background: var(--amber-bg); color: var(--amber); border-radius: var(--radius-sm); }
.empty-state { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 48px 20px; color: var(--text); }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.empty-art { width: 168px; height: 168px; object-fit: contain; margin-bottom: 4px; animation: float 6s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .empty-art { animation: none; } }
.empty-title { font-weight: 700; font-size: 15px; }

/* avatar */
.avatar {
  position: relative; flex: none; display: inline-grid; place-items: center; border-radius: 50%; font-weight: 650; letter-spacing: 0.01em;
  background: linear-gradient(145deg, hsl(var(--h) 85% 93%), hsl(calc(var(--h) + 25) 75% 86%)); color: hsl(var(--h) 45% 32%);
  box-shadow: inset 0 0 0 1px hsl(var(--h) 60% 80% / 0.6);
}
.chan-badge { position: absolute; right: -3px; bottom: -3px; border-radius: 50%; display: grid; place-items: center; background: #fff; box-shadow: 0 0 0 2px var(--panel), 0 1px 3px rgba(0, 0, 0, 0.18); }
@media (prefers-color-scheme: dark) {
  .avatar { background: linear-gradient(145deg, hsl(var(--h) 40% 30%), hsl(calc(var(--h) + 25) 45% 24%)); color: hsl(var(--h) 80% 86%); box-shadow: inset 0 0 0 1px hsl(var(--h) 40% 40% / 0.6); }
}
.logo { display: block; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(124, 92, 255, 0.35)); }

/* modal & menus */
.modal-bg { position: fixed; inset: 0; background: rgba(17, 12, 38, 0.45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 20px; padding: 20px 22px; width: min(440px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(660px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pop-wrap { position: relative; }
.menu { position: absolute; z-index: 30; min-width: 190px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; display: grid; }
.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; cursor: pointer; color: var(--text); }
.menu button:hover { background: var(--brand-50); color: var(--brand-600); }
.menu.right { right: 0; top: 42px; }

/* ---------- login ---------- */
.login-page { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #3b2a86 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #6d28d9 0%, transparent 55%), #120e26; }
.login { width: min(380px, 100%); background: var(--panel); padding: 30px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.login .btn { margin-top: 16px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.sidebar { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; padding: 20px 14px 14px; gap: 16px; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; padding: 0 6px; }
.workspace { display: flex; align-items: center; gap: 10px; background: var(--side-bg-2); border-radius: 14px; padding: 10px; }
.ws-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; }
.ws-text { display: grid; line-height: 1.2; }
.ws-text strong { color: #fff; font-size: 13.5px; }
.ws-text small { color: var(--side-text); font-size: 11.5px; }
.side-nav { display: grid; gap: 3px; }
.side-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--side-text); font-weight: 550; }
.side-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.side-item.active { background: var(--side-active); color: #fff; }
.side-item span:first-of-type { flex: 1; }
.nav-count { min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.side-foot { margin-top: auto; display: grid; gap: 8px; position: relative; }
.side-badge { font-size: 11.5px; font-weight: 650; padding: 5px 10px; border-radius: 9px; background: rgba(255, 255, 255, 0.07); }
.side-badge.warn { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.me { display: flex; align-items: center; gap: 10px; border: 0; background: var(--side-bg-2); color: var(--side-text); border-radius: 14px; padding: 8px 10px; cursor: pointer; text-align: left; }
.me-text { flex: 1; display: grid; line-height: 1.2; min-width: 0; }
.me-text strong { color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: 11.5px; }
.side-foot .menu { bottom: 58px; left: 0; right: 0; }
.main { min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.bottom-nav { display: none; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 344px minmax(0, 1fr); height: 100%; }
.conv-list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { display: flex; align-items: center; gap: 8px; padding: 20px 16px 10px 20px; }
.list-tool { padding: 0 16px 8px; }
.push-banner { display: flex; align-items: center; gap: 10px; margin: 0 12px 10px; padding: 10px 8px 10px 12px; border-radius: 14px; background: var(--brand-50); color: var(--text); font-size: 13px; line-height: 1.35; }
.push-banner > .icon { color: var(--brand-600); }
.push-banner .btn { flex: none; }
.tabs { display: flex; gap: 0; padding: 4px 6px 12px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; color: var(--muted); padding: 5px 5px; border-radius: 999px; font-weight: 600; font-size: 12px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 4px; align-items: center; letter-spacing: -0.01em; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--brand-50); color: var(--brand-600); }
.tab-count { font-size: 10.5px; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 5px; line-height: 17px; }
.list-scroll { overflow-y: auto; flex: 1; padding: 8px; }
.conv { display: flex; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 11px 12px; border-radius: 14px; cursor: pointer; color: var(--text); }
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--brand-50); }
.conv-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-name { font-weight: 750; }
.conv-time { color: var(--muted); font-size: 12px; flex: none; }
.conv-preview { flex: 1; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-preview { color: var(--text); }
.conv-flag { color: var(--muted); }
.unread-dot { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.thread-empty { display: grid; place-items: center; height: 100%; }

.thread { display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; min-height: 0; }
.thread.with-panel { grid-template-columns: minmax(0, 1fr) 320px; }
.thread-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.thread-head .back { display: none; }
.who { flex: 1; min-width: 90px; display: grid; grid-template-columns: minmax(0, 1fr); border: 0; background: none; padding: 0; margin: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.who-name { font-weight: 700; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online { color: var(--green); display: inline-flex; align-items: center; gap: 5px; }
.online .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.assign { display: flex; align-items: center; gap: 6px; margin: 0; padding: 0 4px 0 10px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--muted); }
.assign select { border: 0; margin: 0; padding: 6px 4px; box-shadow: none; background: transparent; width: auto; max-width: 130px; font-weight: 600; color: var(--text); text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; padding: 18px 24px; display: flex; flex-direction: column; gap: 6px; background: var(--panel-2); }
.day { text-align: center; margin: 12px 0 6px; }
.day span { background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 3px 12px; border-radius: 999px; }
.bubble-row { display: flex; align-items: flex-end; gap: 8px; }
.bubble-row.out { justify-content: flex-end; }
.bubble-row.note { justify-content: center; }
.bubble { max-width: min(560px, 76%); border-radius: 18px; padding: 9px 13px 6px; overflow-wrap: anywhere; position: relative; }
.bubble.in { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.out { background: var(--out); border-bottom-right-radius: 6px; }
.bubble.note { background: var(--note); border: 1px dashed var(--note-line); max-width: 70%; border-radius: 14px; }
.bubble-label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--brand-600); margin-bottom: 3px; }
.bubble.note .bubble-label { color: var(--amber); }
.bubble .text { white-space: pre-wrap; }
.tpl-gap { display: inline-block; min-width: 1.9em; padding: 0 4px; margin: 0 1px; border: 1px dashed var(--line-2); border-radius: 5px; color: var(--muted); line-height: 1.25; text-align: center; cursor: help; }
.tpl-note { margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.bubble img.image { max-width: 100%; max-height: 320px; border-radius: 12px; display: block; }
.bubble img.sticker { max-width: 140px; }
.bubble video { max-width: 100%; max-height: 320px; border-radius: 12px; }
.bubble audio { width: 260px; max-width: 100%; }
.file { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; padding: 4px 0; }
.quote { border-left: 3px solid var(--brand); padding: 2px 8px; margin-bottom: 5px; color: var(--muted); font-size: 12.5px; max-height: 3.4em; overflow: hidden; }
.meta { display: flex; gap: 8px; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); margin-top: 3px; }
.st-read { color: var(--brand); }
.st-failed { color: var(--red); }
.fail { color: var(--red); font-size: 12px; margin-top: 3px; }

.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px 12px; }
.composer-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.composer-tabs > button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; cursor: pointer; }
.composer-tabs > button.active { background: var(--brand-50); color: var(--brand-600); }
.composer.note-mode .composer-tabs > button.active { background: var(--amber-bg); color: var(--amber); }
.channel-select { width: auto; padding: 4px 8px; font-size: 12.5px; border-radius: 999px; }
.window { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.window.ok { color: var(--green); background: var(--green-bg); }
.window.closed { color: var(--amber); background: var(--amber-bg); }
.composer textarea { resize: none; min-height: 52px; max-height: 220px; border-radius: 14px; background: var(--panel-2); field-sizing: content; }
.composer.note-mode textarea { background: var(--note); border-color: var(--note-line); }
.composer-hint { padding: 12px 14px; background: var(--panel-2); border-radius: 14px; color: var(--muted); font-size: 13px; }
.composer-actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.send-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 16px rgba(124, 92, 255, 0.35); }
.send-btn:disabled { opacity: 0.45; box-shadow: none; cursor: default; }

.tpl-list { display: grid; gap: 8px; margin-top: 10px; }
.tpl { display: grid; gap: 4px; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px; cursor: pointer; color: var(--text); }
.tpl:hover { border-color: var(--brand); }
.tpl-name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tpl-text { color: var(--muted); white-space: pre-wrap; max-height: 4.4em; overflow: hidden; font-size: 13px; }
.tpl-preview { background: var(--out); border-radius: 14px; padding: 12px 14px; white-space: pre-wrap; margin: 12px 0; display: grid; gap: 6px; }

/* customer panel */
.panel { border-left: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.panel-tabs { display: flex; gap: 4px; padding: 14px 14px 10px; }
.panel-tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 999px; font-weight: 650; color: var(--muted); cursor: pointer; }
.panel-tabs button.active { background: var(--panel); color: var(--brand-600); box-shadow: var(--shadow); }
.panel-body { overflow-y: auto; padding: 0 14px 16px; display: grid; gap: 12px; align-content: start; }
.customer-head { display: flex; align-items: center; gap: 12px; }
.customer-name { font-weight: 750; font-size: 15.5px; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 14px 0 4px; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; text-align: right; }
.customer-card .stats { border-top: 1px solid var(--line); padding-top: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.tag-form input { padding: 3px 9px; border-radius: 999px; font-size: 12px; width: 120px; }
.about { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 13.5px; overflow-wrap: anywhere; }
.about .icon { color: var(--muted); }
.field-row { margin: 8px 0; }
.card-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); }
.card-toggle h4 { margin: 0; }
.note-form { display: grid; gap: 8px; justify-items: end; }
.note-card { background: var(--note); border-color: var(--note-line); padding: 12px; }
.note-card .text { white-space: pre-wrap; margin-bottom: 6px; }

/* ---------- pages ---------- */
/* Rows as tall as their content: otherwise a card that scrolls sideways (tables, the settings tabs)
   shrinks to nothing or scrolls on its own once the page is taller than the screen. */
.page { height: 100%; overflow-y: auto; padding: 28px 32px 40px; display: grid; gap: 16px; align-content: start; grid-auto-rows: max-content; }
.page.narrow { max-width: 860px; margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; display: flex; align-items: baseline; flex-wrap: wrap; }
.period { display: flex; align-items: center; gap: 8px; margin: 0; background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 6px 0 12px; color: var(--muted); }
.period select { border: 0; margin: 0; box-shadow: none; width: auto; background: transparent; font-weight: 600; color: var(--text); }
.chart { position: relative; }
.chart svg { width: 100%; height: 280px; display: block; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 11px; }
.chart-line { stroke: var(--brand); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.hover-line { stroke: var(--brand); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.hover-dot { fill: var(--panel); stroke: var(--brand); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 12px; padding: 8px 12px; display: grid; font-size: 12.5px; pointer-events: none; white-space: nowrap; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar select { width: auto; border-radius: 999px; }
.search-box { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 14px; color: var(--muted); }
.search-box input { border: 0; box-shadow: none; padding: 9px 0; background: transparent; }
.table-card { padding: 6px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.hover tbody tr { cursor: pointer; }
.table.hover tbody tr:hover { background: var(--panel-2); }
.cell-name { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.cell-tags { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

.bc-list { display: grid; gap: 10px; }
.bc-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; color: var(--text); }
.bc-row:hover { border-color: var(--brand-100); }
.bc-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.bc-nums { display: flex; gap: 22px; }
.bc-nums div { display: grid; text-align: right; }
.bc-nums strong { font-size: 16px; }
.bc-nums small { color: var(--muted); font-size: 11.5px; }
.progress { grid-column: 1 / -1; position: relative; height: 6px; background: var(--in); border-radius: 999px; overflow: hidden; }
.progress span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--brand-100); border-radius: 999px; }
.progress span.read { background: var(--brand); }
.form-card { display: grid; gap: 4px; }
.form-card h4 { font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 550; margin-top: 8px; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; font-weight: 500; margin: 6px 0; }
.cond-row { display: grid; grid-template-columns: 1.3fr 1.2fr 1fr auto; gap: 8px; align-items: center; margin: 4px 0; }
.binding { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px; align-items: center; margin: 6px 0; }
.binding-label { font-weight: 700; color: var(--brand-600); font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 1440px) {
  .thread-head .btn.small { padding: 5px 10px; }
}
@media (max-width: 1200px) {
  .thread.with-panel { grid-template-columns: minmax(0, 1fr); }
  .thread.with-panel .panel { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 40; box-shadow: var(--shadow-lg); }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 76px 1fr; }
  .brand span, .workspace, .side-item span, .me-text, .side-badge { display: none; }
  .side-item { justify-content: center; position: relative; }
  .nav-count { position: absolute; top: 2px; right: 6px; min-width: 18px; height: 16px; font-size: 10px; padding: 0 4px; }
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
}
.panel-close { display: none; }
@media (max-width: 1200px) {
  .panel-close { display: inline-grid; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar { display: none; }
  .bottom-nav { display: flex; justify-content: space-around; background: var(--panel); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-item { display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 12px; position: relative; }
  .bottom-item.active { color: var(--brand-600); }
  .bottom-item .nav-count { position: absolute; top: 0; right: 4px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox.has-thread .conv-list { display: none; }
  .inbox:not(.has-thread) .thread-empty { display: none; }
  .thread-head .back { display: inline-grid; }
  .messages { padding: 12px; }
  .page { padding: 18px 16px 28px; }
  .grid2, .cond-row, .binding { grid-template-columns: 1fr; }
  .bc-row { grid-template-columns: 1fr; }
  .bc-nums { justify-content: space-between; }
  /* An open conversation gets the whole screen, like a phone messenger: no tab bar under the composer. */
  .app.in-thread { grid-template-rows: minmax(0, 1fr); }
  .app.in-thread .bottom-nav { display: none; }
  .app.in-thread .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .thread.with-panel .panel { width: 100%; padding-top: env(safe-area-inset-top); }
  /* iPhone zooms into any field with text under 16px and stays zoomed: keep fields at 16px. */
  input:not([type='checkbox']):not([type='radio']):not(.title-input), select, textarea { font-size: 16px !important; }
  .composer-tabs { row-gap: 6px; }
  .chart svg { height: 220px; }
  .channel-select { flex: 0 1 auto; min-width: 0; max-width: 62%; text-overflow: ellipsis; }
  .window.email { max-width: 100%; }
}
/* The thread header follows its own width, not the window's: the column is narrow on a laptop with
   the customer panel open, and on a phone. Above the messages, so the snooze menu stays on top. */
.thread-head { container-type: inline-size; position: relative; z-index: 5; background: var(--panel); }
@container (max-width: 620px) {
  .thread-head .btn-text { display: none; }
  .thread-head .btn.small { padding: 7px; border-radius: 10px; }
  .thread-head .assign select { max-width: 100px; }
}
/* Narrower still: the assignee becomes a round button (initials, or a person icon when unassigned). */
@container (max-width: 500px) {
  .thread-head .who { min-width: 60px; }
  .thread-head .assign { position: relative; flex: none; width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: 50%; }
  .thread-head .assign select { position: absolute; inset: 0; width: 100%; max-width: none; height: 100%; opacity: 0; cursor: pointer; }
}
/* Phone thread header: back, contact (tap opens the details), assignee, actions. */
@media (max-width: 760px) {
  .thread-head { gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px 4px; }
  .thread-head > .avatar { width: 34px !important; height: 34px !important; font-size: 13px !important; }
  .thread-head .who { margin-left: 4px; }
  .thread-head .icon-btn { width: 34px; height: 34px; }
}

/* ---------- feedback: toasts, skeletons, motion ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 8px; background: var(--side-bg); color: #fff; padding: 11px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-weight: 550; max-width: 380px; animation: toast-in 0.18s ease-out; }
.toast.error { background: #3b1220; color: #ffd5dd; }
.toast .icon { color: #a7f3d0; }
.toast.error .icon { color: #fda4af; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px) {
  .toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  /* In a conversation the composer sits at the bottom: notices go on top. */
  .app.in-thread .toasts { bottom: auto; top: calc(64px + env(safe-area-inset-top)); }
}

.skeleton { display: grid; gap: 4px; padding: 8px; }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; }
.sk-lines { flex: 1; display: grid; gap: 8px; }
.sk { display: block; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--in) 25%, var(--line) 37%, var(--in) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.sk-circle { width: 40px; height: 40px; border-radius: 50%; flex: none; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.thread-loading { padding: 24px; background: var(--panel); }

.btn, .icon-btn, .conv, .side-item, .tab, .menu button { transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s; }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled), .send-btn:active:not(:disabled) { transform: scale(0.97); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.bubble { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bubble, .toast { animation: none; } }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* login: brand hero + form, like the Kivorsa presentation */
.login-page { gap: 64px; grid-template-columns: minmax(0, 520px) minmax(0, 380px); justify-content: center; align-items: center; }
.login-hero { color: #fff; display: grid; gap: 14px; }
.login-hero h1 { font-size: 40px; line-height: 1.12; letter-spacing: -0.03em; font-weight: 750; }
.login-hero p { color: #c9c3e8; font-size: 16px; margin: 0; max-width: 420px; }
.hero-brand { display: flex; align-items: center; gap: 14px; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 18px; }
.grad-text { background: linear-gradient(90deg, #a78bfa, #e879f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-art { width: 220px; height: 220px; object-fit: contain; margin-top: 10px; animation: float 6s ease-in-out infinite; }
.login-brand { font-size: 22px; }
@media (max-width: 900px) {
  .login-page { grid-template-columns: minmax(0, 400px); gap: 24px; align-content: center; }
  .login-hero { text-align: center; justify-items: center; }
  .login-hero h1 { font-size: 28px; }
  .hero-brand { margin-bottom: 4px; }
  .hero-art { display: none; }
}

/* ---------- shared bits for settings, integrations, automations ---------- */
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; background: var(--line-2); cursor: pointer; flex: none; padding: 0; transition: background-color 0.15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch.on { background: var(--brand); }
.switch.on span { transform: translateX(16px); }
.switch:disabled { opacity: 0.5; cursor: default; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; }
.nowrap { white-space: nowrap; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
code { background: var(--in); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
kbd { font-family: inherit; font-size: 11.5px; font-weight: 700; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 0 5px; background: var(--panel); }
.inline-icon { display: inline-block; vertical-align: -2px; }
.link-strong { font-weight: 700; margin-left: auto; white-space: nowrap; }
.pad-sm { padding: 10px 12px; }
.danger-text, .btn.ghost.danger-text { color: var(--red); }
.table tr.dim td { opacity: 0.55; }
.table-card.flat { padding: 0; box-shadow: none; border: 0; }
.cell-stack { display: grid; line-height: 1.25; }
.cell-stack small { font-weight: 400; }
.inline-select { width: auto; padding: 4px 8px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.card-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 6px 12px; }
.card-bar h4 { margin: 0; }
.card-bar > div:not(.search-box) { flex: 1; min-width: 200px; }
.card-bar p { margin: 2px 0 0; }
.table-card .card-bar { padding: 10px 10px 12px; }
.secret-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--brand-50); border: 1px dashed var(--brand); border-radius: 12px; padding: 12px; margin: 10px 0; }
.secret-box code { flex: 1; min-width: 0; background: none; font-size: 14px; font-weight: 600; color: var(--text); user-select: all; }
.secret-box p { flex-basis: 100%; margin: 0; }
.code-block { background: var(--side-bg); color: #d8d3f5; border-radius: 12px; padding: 12px 14px; font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; }
.check-result { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 13px; margin: 8px 0; }
.check-result.ok { background: var(--green-bg); color: var(--green); }
.check-result.bad { background: var(--red-bg); color: var(--red); overflow-wrap: anywhere; }
.check-result.warn { background: var(--amber-bg); color: var(--amber); }
.check-result .icon { margin-top: 1px; }
.info-card { display: grid; gap: 2px; padding: 8px 16px; }
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.info-row:last-child { border-bottom: 0; }
.card > .info-row:first-of-type { border-top: 1px solid var(--line); }
.info-card > .info-row:first-child { border-top: 0; }
.prefix-input { display: flex; align-items: center; margin-top: 5px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); padding-left: 11px; color: var(--muted); font-size: 14px; }
.prefix-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.prefix-input input { border: 0; box-shadow: none !important; padding-left: 2px; margin: 0; color: var(--text); }
.paused { opacity: 0.62; }
.paused:hover { opacity: 0.9; }

/* sidebar: lower group like the mockups (Integrations, Settings) */
.side-nav-lower { margin-top: 6px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.07); }

/* mobile "More" sheet */
.bottom-nav button.bottom-item { border: 0; background: none; cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; }
.sheet-bg { position: fixed; inset: 0; z-index: 45; background: rgba(17, 12, 38, 0.45); display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--panel); border-radius: 22px 22px 0 0; padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 2px; box-shadow: var(--shadow-lg); animation: sheet-in 0.18s ease-out; }
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sheet .banner { border-radius: 10px; margin: 4px 0 6px; }
.sheet-item { display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-radius: 12px; border: 0; background: none; color: var(--text); font-weight: 600; font-size: 15px; text-align: left; cursor: pointer; }
.sheet-item.active { background: var(--brand-50); color: var(--brand-600); }
.sheet-item .icon { color: var(--muted); }

/* ---------- settings ---------- */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; }
.subnav-item { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; background: var(--panel); border: 1px solid var(--line); }
.subnav-item:hover { color: var(--text); border-color: var(--line-2); }
.subnav-item.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(124, 92, 255, 0.25); }
.subnav-item.active .brand-mark { background: #fff; border-radius: 50%; padding: 1px; }
.settings { max-width: 1060px; margin: 0 auto; width: 100%; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.num-card { display: grid; gap: 6px; align-content: start; }
.num-head { display: flex; align-items: center; gap: 12px; }
.num-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #e7f9ee; }
.num-name { font-weight: 750; font-size: 15px; }
.num-card .stats { margin: 8px 0; }
.num-card .stats dd { font-weight: 600; overflow-wrap: anywhere; }
.snippet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.snippet-card { display: grid; gap: 8px; align-content: start; }
.snippet-head { display: flex; align-items: center; gap: 4px; }
.shortcut { background: var(--brand-50); color: var(--brand-600); font-weight: 700; font-size: 13px; padding: 3px 9px; }
.snippet-text { white-space: pre-wrap; font-size: 13.5px; max-height: 9em; overflow: hidden; }
.hours-card { max-width: 640px; }
.hours-grid { display: grid; gap: 4px; margin: 6px 0; }
.hours-row { display: grid; grid-template-columns: 44px 110px 1fr auto 1fr; align-items: center; gap: 10px; padding: 6px 0; min-height: 50px; }
.hours-row input[type='time'] { padding: 6px 10px; }
.hours-day { font-weight: 600; }
.hours-row.off .hours-day { color: var(--muted); }
.hours-closed { grid-column: 3 / -1; }

/* ---------- integrations ---------- */
.int-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; }
.hook-list { display: grid; gap: 10px; }
.hook { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; background: var(--panel-2); }
.hook-head { display: flex; align-items: center; gap: 12px; }
.hook-url { display: grid; gap: 3px; min-width: 0; }
.hook-url code { background: none; padding: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hook-stats { display: flex; gap: 16px; flex-wrap: wrap; }

/* website widgets */
.wd-face { display: grid; place-items: center; border-radius: 50%; flex: none; overflow: hidden; box-shadow: 0 2px 6px rgba(20, 16, 40, 0.18); line-height: 1; }
.wd-face img { width: 100%; height: 100%; object-fit: cover; }
.modal:has(.wd-editor) { width: min(1000px, 100%); }
.wd-editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.wd-form > label:first-child { margin-top: 0; }
.wd-icons { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 8px; }
.wd-icon-choice { border: 2px solid transparent; background: none; border-radius: 50%; padding: 2px; cursor: pointer; display: grid; }
.wd-icon-choice.active { border-color: var(--brand); }
.wd-custom { margin-bottom: 4px; }
.wd-colors { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.wd-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; padding: 0; }
.wd-swatch.active { box-shadow: 0 0 0 2px var(--brand); }
.wd-colors input[type='color'] { width: 36px; height: 30px; padding: 2px; border-radius: 8px; cursor: pointer; }
.wd-button { display: grid; gap: 8px; }
.wd-button .grid2 { gap: 8px; }
.wd-side { position: sticky; top: 0; display: grid; gap: 8px; }
.wd-side .field-label { margin-top: 0; }
.wd-preview { position: relative; height: 430px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line);
  background: linear-gradient(var(--panel-2), var(--panel-2)) 18px 22px / 55% 12px no-repeat, linear-gradient(var(--panel-2), var(--panel-2)) 18px 46px / 80% 8px no-repeat,
    linear-gradient(var(--panel-2), var(--panel-2)) 18px 62px / 70% 8px no-repeat, linear-gradient(var(--panel-2), var(--panel-2)) 18px 78px / 74% 8px no-repeat, var(--panel); }
.wd-code { margin: 0; font-size: 12px; word-break: break-all; }
@media (max-width: 860px) {
  .wd-editor { grid-template-columns: minmax(0, 1fr); }
  .wd-side { position: static; }
}
@media (max-width: 760px) {
  /* all seven icons in one row on a phone */
  .wd-icons { gap: 2px; }
  .wd-icon-choice .wd-face { width: 30px !important; height: 30px !important; }
}
.event-grid { display: grid; gap: 2px; }
.event-grid .check { align-items: flex-start; }

/* ---------- automations ---------- */
.auto-list { display: grid; gap: 10px; }
.auto-card { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; transition: border-color 0.15s, opacity 0.15s; }
.auto-card:hover { border-color: var(--brand-100); }
.auto-order { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--in); color: var(--muted); font-weight: 700; font-size: 12.5px; }
.auto-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; cursor: pointer; min-width: 0; }
.auto-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.auto-flow { display: flex; flex-wrap: wrap; gap: 6px; }
.flow-chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-chip .icon { display: inline-block; vertical-align: -2px; margin-right: 4px; }
.flow-chip.when { background: var(--green-bg); color: var(--green); }
.flow-chip.if { background: var(--blue-bg); color: var(--blue); }
.flow-chip.then { background: var(--brand-50); color: var(--brand-600); }
.auto-side { display: grid; justify-items: end; gap: 8px; }
.auto-side .row { gap: 0; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 8px; }
.preset { display: flex; gap: 12px; align-items: flex-start; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px; cursor: pointer; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.preset:hover { border-color: var(--brand); transform: translateY(-1px); }
.preset strong { display: block; font-size: 13.5px; }
.preset small { color: var(--muted); font-size: 12.5px; }
.preset-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600); flex: none; }
.presets-more summary { cursor: pointer; font-weight: 650; color: var(--brand-600); }
.title-input { flex: 1; min-width: 220px; font-size: 22px; font-weight: 750; letter-spacing: -0.01em; border-color: transparent; background: transparent; padding: 4px 8px; margin-left: -8px; }
.title-input:hover:not(:disabled) { border-color: var(--line-2); }
.title-input:disabled { color: var(--text); opacity: 1; }
.flow { display: grid; }
.flow-step { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.flow-step + .flow-step { margin-top: 30px; }
.flow-step + .flow-step::before { content: ''; position: absolute; left: 32px; top: -31px; height: 30px; border-left: 2px dashed var(--line-2); }
.flow-step + .flow-step::after { content: ''; position: absolute; left: 28px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--bg); }
.flow-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.flow-badge { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.flow-badge.when { background: var(--green-bg); color: var(--green); }
.flow-badge.if { background: var(--blue-bg); color: var(--blue); }
.flow-badge.then { background: var(--grad); color: #fff; }
.flow-kicker { font-size: 11px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.flow-title { font-weight: 700; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: grid; gap: 3px; text-align: left; border: 1px solid var(--line-2); background: var(--panel); border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--text); }
.choice small { color: var(--muted); font-size: 12px; }
.choice.active { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px var(--brand-100); }
.choice:disabled { cursor: default; }
.flow-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel-2); display: grid; gap: 8px; margin: 8px 0; }
.flow-item-head { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.flow-item .checks { gap: 4px 16px; }
.flow-item .check { margin: 2px 0; }
.flow-item textarea { resize: vertical; }
.step-no { width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.flow-step .pop-wrap { margin-top: 4px; }
.flow-step .menu { left: 0; top: 38px; }
.num-input { width: 80px; text-align: center; }
.auto-select { width: auto; min-width: 220px; }

/* ---------- composer: snippets and emoji ---------- */
.composer { position: relative; }
.pop { position: absolute; z-index: 30; left: 16px; bottom: calc(100% - 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); }
.snippet-pop { width: min(460px, calc(100% - 32px)); padding: 6px; display: grid; gap: 2px; max-height: 340px; overflow-y: auto; }
.snippet-search { display: flex; align-items: center; gap: 8px; padding: 2px 8px 6px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.snippet-search input { border: 0; box-shadow: none; padding: 6px 0; background: transparent; }
.snippet-opt { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--text); }
.snippet-opt code { background: var(--brand-50); color: var(--brand-600); font-weight: 700; }
.snippet-opt span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snippet-opt.active { background: var(--brand-50); }
.snippet-opt.active span { color: var(--text); }
.emoji-pop { display: grid; grid-template-columns: repeat(8, 36px); gap: 2px; padding: 8px; }
.emoji-pop button { width: 36px; height: 36px; border: 0; background: none; border-radius: 9px; font-size: 20px; cursor: pointer; }
.emoji-pop button:hover { background: var(--brand-50); }

@media (max-width: 760px) {
  .hide-sm { display: none; }
  .choice-row { grid-template-columns: 1fr; }
  .auto-card { grid-template-columns: 1fr; }
  .auto-order { display: none; }
  .auto-side { grid-auto-flow: column; justify-content: space-between; justify-items: start; align-items: center; }
  .hours-row { grid-template-columns: 44px 1fr 1fr; gap: 6px 10px; }
  .hours-day { grid-column: 2 / -1; }
  .hours-row input[type='time'] { grid-row: 2; }
  .hours-row input[type='time']:first-of-type { grid-column: 2; }
  .hours-row input[type='time']:last-of-type { grid-column: 3; }
  .hours-row > span.muted:not(.hours-closed) { display: none; }
  .hours-closed { grid-column: 2 / -1; }
  .subnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .subnav-item { white-space: nowrap; }
  .emoji-pop { grid-template-columns: repeat(6, 36px); }
  .table-card .card-bar { padding: 8px 6px 10px; }
  /* teammates: one block per person instead of a wide table */
  .team-table thead { display: none; }
  .team-table tr { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
  .team-table tr:last-child { border-bottom: 0; }
  .team-table td { display: block; border: 0; padding: 0; }
  .team-table td.hide-sm { display: none; }
  .team-table td.right { text-align: left; white-space: normal; }
  .team-table td.right .btn { padding-left: 0; }
  /* contacts: name and time, then phone, email, stage and tags under the name */
  .contacts-table thead { display: none; }
  .contacts-table, .contacts-table tbody { display: block; }
  .contacts-table tr { display: grid; grid-template-columns: 30px auto minmax(0, 1fr) auto; column-gap: 10px; row-gap: 2px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--line); }
  .contacts-table tr:last-child { border-bottom: 0; }
  .contacts-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .contacts-table .c-name { grid-area: 1 / 1 / 2 / 4; min-width: 0; }
  .contacts-table .c-name .cell-name { max-width: 100%; }
  .contacts-table .c-last { grid-area: 1 / 4; color: var(--muted); font-size: 12px; white-space: nowrap; }
  .contacts-table .c-phone { grid-area: 2 / 2 / 3 / 5; }
  .contacts-table .c-email { grid-area: 3 / 2 / 4 / 5; }
  .contacts-table .c-phone, .contacts-table .c-email { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .contacts-table .c-stage { grid-area: 4 / 2; margin-top: 4px; }
  .contacts-table .c-tags { grid-area: 4 / 3 / 5 / 5; margin-top: 4px; }
  .contacts-table .empty, .contacts-table .c-added { display: none; }
}

/* ---------- import from respond.io ---------- */
.import-prep { margin: 0 0 6px; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; }
.radio-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 6px 0; min-width: 0; }
.radio-group legend { font-size: 12px; font-weight: 650; color: var(--muted); padding: 0 4px; }
.radio-group:disabled { opacity: 0.6; }
.radio { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0; color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer; }
.radio input { width: auto; margin-top: 3px; accent-color: var(--brand); }
.radio span { display: grid; }
.radio small { color: var(--muted); font-size: 12px; font-weight: 400; }
.inline-label { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--text); font-size: 13.5px; font-weight: 500; }
.inline-label input { margin: 0; }
.import-steps { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 8px; }
.import-steps li { display: grid; grid-template-columns: 20px auto auto 1fr; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.import-steps li.done { color: var(--green); }
.import-steps li.now { color: var(--text); font-weight: 650; }
.import-steps li.now .icon { color: var(--brand); }
.import-steps li.stopped { color: var(--amber); font-weight: 650; }
.progress.mini { height: 6px; max-width: 220px; }
.progress.mini span { background: var(--brand); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.import-summary { display: grid; gap: 10px; }
.import-summary h4 { margin: 6px 0 0; }
.kpi-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel-2); }
.kpi-box .kpi-value { font-size: 20px; }
.import-notes { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (max-width: 760px) {
  .import-steps li { grid-template-columns: 20px 1fr auto; }
  .import-steps li .progress { grid-column: 2 / -1; }
}

/* ---------- email ---------- */
.section-gap { margin-top: 12px; }
.num-logo.mail { background: #fdeceb; color: #c5221f; }
.num-logo.chat { background: var(--brand-50, #f0ecff); color: var(--brand-600); }
@media (prefers-color-scheme: dark) {
  .num-logo { background: #12301f; }
  .num-logo.mail { background: #3a1717; }
  .num-logo.chat { background: #241c45; }
}
/* website chat: the assistant settings */
.assistant-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; display: grid; gap: 10px; background: var(--panel); }
.assistant-box textarea { font-family: inherit; }
.assistant-status { align-items: center; gap: 10px; }
.try-box { display: grid; gap: 6px; }
.try-reply { display: block; white-space: pre-wrap; color: var(--text); margin-bottom: 2px; }
/* website chat: where the visitor wrote from */
.chat-page { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-page a { color: inherit; }
.sync-line { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; color: var(--muted); overflow-wrap: anywhere; }
.sync-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }
.sync-line.ok { color: var(--green); }
.sync-line.ok .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.sync-line.bad { color: var(--red); }
.sync-line.bad .dot { background: var(--red); }
.sync-line.wait .dot { background: var(--amber); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.help-box { background: var(--blue-bg); color: var(--text); border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.help-box ol { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.choice-row.three { grid-template-columns: repeat(3, 1fr); }
.window.email { display: inline-flex; align-items: center; gap: 5px; color: var(--blue); background: var(--blue-bg); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-input { margin-bottom: 8px; border-radius: 12px; font-weight: 600; background: var(--panel-2); }
.email-subject { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.email-subject .icon { color: var(--muted); }
.bubble.out .email-subject .icon { color: var(--brand-600); }
.email-atts { display: grid; gap: 4px; margin-top: 6px; justify-items: start; }
.email-atts img.image { max-height: 220px; }
.quoted-toggle { border: 0; background: var(--in); color: var(--muted); border-radius: 6px; padding: 0 8px; line-height: 16px; font-weight: 800; cursor: pointer; margin-top: 6px; }
.quoted-toggle:hover { color: var(--text); }
.email-quoted { white-space: pre-wrap; color: var(--muted); font-size: 12.5px; border-left: 3px solid var(--line-2); padding: 4px 0 4px 10px; margin-top: 6px; max-height: 360px; overflow: auto; }
.bubble.type-email { max-width: min(640px, 80%); }
@media (max-width: 760px) {
  .choice-row.three { grid-template-columns: 1fr; }
}

/* ---------- go-live checklist ---------- */
.golive-head { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; align-items: center; }
.golive-head h4 { margin: 0; font-size: 15px; }
.golive-head p { margin: 4px 0 0; }
.golive-score { display: flex; align-items: baseline; gap: 6px; }
.golive-score strong { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.golive-score span { color: var(--muted); font-weight: 600; }
.golive-bar { grid-column: 1 / -1; height: 8px; }
.golive-stage { padding: 14px 16px 6px; }
.golive-stage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.golive-stage-head h4 { margin: 0; flex: 1; font-size: 14.5px; }
.stage-no { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-600); font-weight: 800; font-size: 12.5px; flex: none; }
.stage-no.done { background: var(--green); color: #fff; }
.golive-items { list-style: none; margin: 0; padding: 0; }
.gl-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.gl-item:first-child { border-top: 0; }
.gl-icon { display: grid; place-items: center; height: 22px; color: var(--muted); }
.gl-item.done .gl-icon { color: var(--green); }
.gl-item.warn .gl-icon { color: var(--amber); }
.gl-item.info .gl-icon { color: var(--blue); }
.gl-check { width: 18px; height: 18px; margin: 2px 0 0 2px; cursor: pointer; }
.gl-title { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gl-item.done .gl-title { color: var(--muted); }
.gl-detail { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.gl-item.warn .gl-detail { color: var(--amber); }
.gl-side { display: grid; justify-items: end; gap: 6px; }
@media (max-width: 760px) {
  .gl-item { grid-template-columns: 26px minmax(0, 1fr); }
  .gl-side { grid-column: 2; justify-items: start; grid-auto-flow: column; justify-content: start; align-items: center; }
}

/* ---------- switching channels: standby / live ---------- */
.mode-line { display: flex; align-items: center; gap: 8px 10px; padding: 8px 10px; border-radius: 12px; font-size: 13px; flex-wrap: wrap; }
.mode-line > .grow { flex: 1 1 170px; min-width: 0; }
.mode-line.standby { background: var(--amber-bg); }
.mode-line.live { background: var(--green-bg); }
.mode-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--amber); }
.live .mode-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.18); }
.mode-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; margin: 4px 0 12px; }
.mode-banner.standby { background: var(--amber-bg); color: var(--text); }
.mode-banner.live { background: var(--green-bg); color: var(--text); }
.switch-steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 4px; font-size: 13.5px; }
.pf-list { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--line); border-radius: 12px; }
.pf { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line); }
.pf:first-child { border-top: 0; }
.pf-icon { display: grid; place-items: center; height: 20px; }
.pf.ok .pf-icon { color: var(--green); }
.pf.warn .pf-icon { color: var(--amber); }
.pf.fail .pf-icon { color: var(--red); }
.pf.info .pf-icon { color: var(--blue); }
.pf-title { font-weight: 650; font-size: 13.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pf-detail { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.pf.fail .pf-detail { color: var(--red); }
.confirm-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; }
.confirm-box .check { align-items: flex-start; }
.confirm-box .check input { margin-top: 3px; }
.confirm-box .override { color: var(--red); }
.rollback { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.rollback h4 { margin-bottom: 2px; }
.switch-history { margin-top: 12px; font-size: 13px; }
.switch-history summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.switch-history ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; }
.monitor .kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.kpi-box.bad { border-color: var(--red); background: var(--red-bg); }

/* ---------- status page ---------- */
.status-head { display: flex; align-items: flex-start; gap: 12px; }
.status-head.ok > .icon { color: var(--green); }
.status-head.bad { border-color: var(--red); }
.status-head.bad > .icon { color: var(--red); }
.status-head h4 { margin: 2px 0 4px; }
.status-head ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.status-grid .stats { margin: 6px 0 10px; }
.err-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.api-log .api-path code { background: none; padding: 0; white-space: nowrap; }
.api-log td { font-size: 12.5px; }
@media (max-width: 760px) {
  /* the problems get the full width; Refresh goes under them */
  .status-head { flex-wrap: wrap; }
  .status-head > .grow { flex: 1 1 calc(100% - 40px); min-width: 0; }
  .status-head > .btn { margin-left: 34px; }
}
