/* ==========================================================================
   Convo — Telegram inbox UI
   ========================================================================== */
:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #12101c;
  --ink-2: #3a3747;
  --muted: #7a7688;
  --line: #ebe8e1;
  --line-2: #f1efe9;
  --side: #0f0d17;
  --side-2: #1a1726;
  --side-txt: #a9a5b8;
  --acc: #6b4eff;
  --acc-2: #a05cff;
  --acc-soft: #efeaff;
  --grad: linear-gradient(135deg, #6b4eff 0%, #a05cff 100%);
  --ok: #12a26a; --ok-soft: #e4f7ee;
  --bad: #e5484d; --bad-soft: #fdeceb;
  --warn: #c98200; --warn-soft: #fff4dc;
  --r: 16px; --r-sm: 11px;
  --sh-1: 0 1px 2px rgba(18,16,28,.04), 0 1px 1px rgba(18,16,28,.03);
  --sh-2: 0 10px 30px -12px rgba(18,16,28,.18), 0 2px 6px rgba(18,16,28,.04);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
  --side-w: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--acc); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2); padding: 2px 6px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; } .center { text-align: center; }
.block { display: block; } .grow { flex: 1; } .num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; }
.serif i, h2 i { font-style: italic; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: .05em; }
.ic { flex-shrink: 0; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); flex-shrink: 0; background: var(--side); color: var(--side-txt);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px;
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(107,78,255,.22), transparent 60%), radial-gradient(80% 40% at 100% 100%, rgba(160,92,255,.12), transparent 60%);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--grad); color: #fff; box-shadow: 0 6px 18px -4px rgba(107,78,255,.7); transform: rotate(-6deg); }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.03em; }
.brand-name em { font-style: normal; color: var(--acc-2); }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; padding: 8px 12px; color: #6d6a7e; font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--side-txt); font-weight: 600; transition: .15s; position: relative; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav a.active { color: #fff; background: linear-gradient(90deg, rgba(107,78,255,.35), rgba(107,78,255,.08)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--acc-2); }
.nav .pill { margin-left: auto; }
.side-foot { margin-top: auto; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--side-2); border: 1px solid rgba(255,255,255,.05); }
.me-txt { flex: 1; min-width: 0; line-height: 1.25; }
.me-txt strong { color: #fff; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt small { font-size: 11.5px; color: #8a879a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.me .icon-btn { color: var(--side-txt); }
.me .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px 32px 6px; }
.topbar h1 { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.topbar-actions form { margin: 0; }
.content { padding: 14px 32px 40px; flex: 1; min-height: 0; }
.only-mobile { display: none !important; }
.scrim { display: none; }

.imp-bar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px; font-size: 13px; background: #fff4dc; color: #6b4a00; border-bottom: 1px solid #f3dfae; }
.imp-bar form { margin: 0; } .imp-bar button { border: 0; background: #6b4a00; color: #fff; padding: 4px 12px; border-radius: 99px; font: 600 12px var(--font); cursor: pointer; }

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
.pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.card-head h3 { font-size: 15px; display: flex; gap: 8px; align-items: center; }
.section-title { margin: 4px 0 12px; } .section-title h3 { font-size: 15px; }
.link { font-weight: 600; font-size: 13px; }
.link-plain { color: inherit; } .link-plain:hover strong { color: var(--acc); }
.stack > * + * { margin-top: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; font: 600 13.5px var(--font); cursor: pointer; transition: .15s; white-space: nowrap; color: var(--ink); background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -8px rgba(107,78,255,.75), inset 0 1px 0 rgba(255,255,255,.2); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 26px -8px rgba(107,78,255,.85), inset 0 1px 0 rgba(255,255,255,.2); }
.btn-dark { background: var(--ink); color: #fff; } .btn-dark:hover:not(:disabled) { background: #26222f; }
.btn-ghost { background: var(--card); border-color: var(--line); } .btn-ghost:hover { border-color: #d9d5cc; background: #fbfaf8; }
.btn-ghost.danger { color: var(--bad); } .btn-ghost.danger:hover { background: var(--bad-soft); border-color: #f6c9c7; }
.btn-ghost.good { color: var(--ok); }
.btn-danger { background: var(--bad); color: #fff; } .btn-danger:hover { background: #cf3a3f; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 14.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: .15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.icon-btn.good { color: var(--ok); } .icon-btn.good:hover { background: var(--ok-soft); }
.pill { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--grad); color: #fff; font-size: 11px; font-weight: 700; }

.field { display: block; } .field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input, textarea, select { font: inherit; color: inherit; }
.field input, .field textarea, .field select, .input-ic input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fdfdfb; outline: none; transition: .15s;
}
.field textarea { height: auto; padding: 12px 14px; resize: vertical; }
.field input:focus, .field textarea:focus, .input-ic:focus-within { border-color: var(--acc); box-shadow: 0 0 0 4px rgba(107,78,255,.12); background: #fff; }
.input-ic { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fdfdfb; padding-left: 13px; color: var(--muted); transition: .15s; }
.input-ic input:-webkit-autofill, .input-ic input:-webkit-autofill:hover, .input-ic input:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px #fdfdfb inset !important; -webkit-text-fill-color: var(--ink); transition: background-color 9999s; }
.input-ic:focus-within input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px #fff inset !important; }
.input-ic input { border: 0 !important; box-shadow: none !important; padding-left: 0; background: transparent !important; color: var(--ink); }
.input-ic .icon-btn { margin-right: 4px; }
.input-ic.big input { height: 52px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.alert { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 12px; font-size: 13px; font-weight: 500; margin-bottom: 16px; }
.alert-error { background: var(--bad-soft); color: #b42a2f; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; vertical-align: middle; letter-spacing: .01em; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); } .badge-ok i { box-shadow: 0 0 0 3px rgba(18,162,106,.18); animation: pulse 2s infinite; }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--line-2); color: var(--muted); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(18,162,106,0); } }

.note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; padding: 8px 12px; border-radius: 10px; margin-top: 10px; }
.note-bad { background: var(--bad-soft); color: var(--bad); } .note-warn { background: var(--warn-soft); color: #8d5c00; }

.avatar { --h: 260; width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, hsl(var(--h) 85% 92%), hsl(calc(var(--h) + 40) 80% 86%)); color: hsl(var(--h) 45% 32%); }
.avatar.xs { width: 26px; height: 26px; font-size: 10px; } .avatar.sm { width: 34px; height: 34px; font-size: 12px; }
.avatar.lg { width: 48px; height: 48px; } .avatar.xl { width: 72px; height: 72px; font-size: 24px; }
.avatar.bot-av { border-radius: 14px; } .avatar.sm.bot-av { border-radius: 10px; }

.toast { position: fixed; right: 24px; top: 22px; z-index: 100; display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 13px 18px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 500; font-size: 13.5px; box-shadow: var(--sh-2); animation: slidein .35s cubic-bezier(.2,.9,.3,1.2); transition: .35s; }
.toast + .toast { top: 80px; }
.toast-success .ic { color: #5ee0a8; } .toast-error { background: #2a0f12; } .toast-error .ic { color: #ff8a8d; }
.toast.hide { opacity: 0; transform: translateY(-10px); pointer-events: none; }
@keyframes slidein { from { opacity: 0; transform: translateY(-14px) scale(.97); } }

/* switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #dcd8cf; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.18); transition: .2s cubic-bezier(.3,1.4,.6,1); }
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::after { transform: translateX(18px); }

/* segmented + chips */
.seg { display: inline-flex; padding: 3px; background: var(--line-2); border-radius: 11px; gap: 2px; }
.seg a, .seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font: 600 12.5px var(--font); color: var(--muted); cursor: pointer; }
.seg .active { background: #fff; color: var(--ink); box-shadow: var(--sh-1); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink-2); padding: 5px 11px; border-radius: 99px; font: 600 12px var(--font); cursor: pointer; white-space: nowrap; transition: .15s; }
.chip:hover { border-color: #cfcabe; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- dashboard ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 4px 0 24px; }
.hero h2 { font-size: 44px; line-height: 1.05; }
.hero p { margin: 6px 0 0; font-size: 14.5px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--sh-1); }
.stat::after { content: ''; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: var(--tone, var(--acc-soft)); opacity: .6; filter: blur(4px); }
.stat-ic { position: relative; z-index: 1; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--tone, var(--acc-soft)); color: var(--tone-ink, var(--acc)); margin-bottom: 16px; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat-val { font-size: 30px; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tone-violet { --tone: #efeaff; --tone-ink: #6b4eff; } .tone-sky { --tone: #e3f2ff; --tone-ink: #1f7ae0; }
.tone-rose { --tone: #ffe8ef; --tone-ink: #e0386d; } .tone-amber { --tone: #fff1d9; --tone-ink: #c27a00; }

.grid-2-1 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend span { display: flex; align-items: center; gap: 6px; } .legend i { width: 10px; height: 10px; border-radius: 3px; }
.lg-in, .b-in { background: #d9d0ff; } .lg-out, .b-out { background: var(--grad); }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 220px; padding-top: 10px; }
.bars.wide { gap: 8px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; }
.bar-col small { font-size: 11px; color: var(--muted); font-weight: 600; }
.bar-stack { width: 100%; max-width: 44px; display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; transition: .3s; min-height: 4px; }
.bar-stack span { display: block; min-height: 0; }
.bar-col:hover .bar-stack { filter: brightness(1.05) saturate(1.2); transform: scaleY(1.02); transform-origin: bottom; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li a { display: flex; align-items: center; gap: 12px; padding: 10px; margin: 0 -10px; border-radius: 12px; color: inherit; transition: .15s; }
.mini-list li a:hover { background: var(--line-2); }
.mini-txt { flex: 1; min-width: 0; line-height: 1.3; }
.mini-txt strong { display: block; font-size: 13.5px; }
.mini-txt small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.mini-meta small { font-size: 11.5px; color: var(--muted); }

/* ---------- bots ---------- */
.grid-bots { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 22px; align-items: start; }
.connect-card { padding: 26px; position: sticky; top: 20px; overflow: hidden; background: radial-gradient(100% 70% at 100% 0%, #f2edff 0%, #fff 60%); }
.connect-head { display: flex; gap: 14px; margin-bottom: 20px; }
.connect-head h3 { font-size: 18px; margin-bottom: 4px; }
.connect-head p { margin: 0; font-size: 13.5px; }
.connect-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; flex-shrink: 0; box-shadow: 0 8px 20px -6px rgba(107,78,255,.6); }
.connect-form { display: grid; gap: 10px; }
.slots { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 12px; }
.howto { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; }
.howto summary { cursor: pointer; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; list-style: none; color: var(--ink-2); }
.howto ol { margin: 12px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; } .howto li { margin: 6px 0; }

.bot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.bot-list.one { grid-template-columns: 1fr; }
.bot-card { padding: 20px; transition: .2s; }
.bot-card:hover { box-shadow: var(--sh-2); }
.bot-card.is-off { background: #fbfaf7; } .bot-card.is-off .bot-av { filter: grayscale(1); opacity: .6; }
.bot-card.row { display: flex; align-items: center; gap: 16px; } .bot-card.row form { margin: 0; }
.bot-top { display: flex; align-items: center; gap: 14px; }
.bot-id { flex: 1; min-width: 0; } .bot-id h4 { font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bot-id a { font-size: 13px; font-weight: 600; }
.bot-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; padding: 14px 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.bot-stats div { text-align: center; } .bot-stats b { display: block; font-size: 17px; letter-spacing: -.02em; } .bot-stats span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.bot-actions { display: grid; grid-template-columns: minmax(0,1fr) auto auto auto; gap: 6px; } .bot-actions .btn { padding: 0 10px; } .bot-actions form { margin: 0; }
.bot-actions .btn { height: 36px; padding: 0 12px; font-size: 13px; }
.bot-actions form .btn { width: 100%; }

.empty { padding: 50px 24px; text-align: center; }
.empty h3 { font-size: 17px; margin: 14px 0 4px; } .empty p { margin: 0; }
.empty-art { width: 76px; height: 76px; margin: 0 auto; display: grid; place-items: center; border-radius: 24px; background: var(--acc-soft); color: var(--acc); transform: rotate(-6deg); }

/* ---------- tables / admin ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input-ic { max-width: 420px; background: #fff; }
.toolbar .input-ic input { height: 42px; }
.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fcfbf9; }
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr { transition: .12s; cursor: default; }
.table tbody tr[onclick] { cursor: pointer; }
.table tbody tr:hover { background: #fcfbf8; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td small { font-size: 12px; }
.cell-user { display: flex; align-items: center; gap: 12px; } .cell-user strong { display: block; } .cell-user small { color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; } .row-actions form { margin: 0; }
.meter b { font-size: 15px; } .meter small { color: var(--muted); }

.profile-head { display: flex; align-items: center; gap: 22px; padding: 26px; margin-bottom: 22px; background: radial-gradient(120% 140% at 100% 0%, #f1ecff 0%, #fff 55%); }
.profile-head h2 { font-size: 24px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.profile-head p { margin: 4px 0 0; }
.ph-id { flex: 1; min-width: 0; }
.ph-stats { display: flex; gap: 28px; } .ph-stats div { text-align: right; }
.ph-stats b { display: block; font-size: 26px; letter-spacing: -.03em; line-height: 1.1; } .ph-stats b small { font-size: 14px; color: var(--muted); }
.ph-stats span { font-size: 12px; color: var(--muted); font-weight: 600; }
.danger-zone { margin-top: 16px; display: grid; gap: 10px; } .danger-zone h4 { font-size: 13px; color: var(--bad); text-transform: uppercase; letter-spacing: .08em; } .danger-zone form { margin: 0; }

.modal { border: 0; padding: 0; border-radius: 22px; width: min(620px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(18,16,28,.45); }
.modal::backdrop { background: rgba(18,16,28,.45); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .25s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
.modal-body { padding: 26px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; } .modal-head h3 { font-size: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- inbox ---------- */
.page-inbox .content { padding: 10px 20px 20px; display: flex; }
.page-inbox .topbar { display: none; }
.page-inbox .main { height: 100vh; }
.inbox { flex: 1; display: flex; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--sh-2); margin-top: 10px; }
.ib-list { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fdfcfa; }
.ib-list-head { padding: 18px 16px 12px; display: grid; gap: 12px; border-bottom: 1px solid var(--line-2); }
.ib-list-head .input-ic { background: #fff; } .ib-list-head .input-ic input { height: 40px; }
.ib-list-head .seg { justify-self: start; }
.ib-convs { flex: 1; overflow-y: auto; padding: 8px; }
.conv { width: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 0; background: transparent; border-radius: 14px; text-align: left; cursor: pointer; font: inherit; color: inherit; transition: .12s; position: relative; }
.conv:hover { background: var(--line-2); }
.conv.active { background: #fff; box-shadow: var(--sh-2), inset 0 0 0 1px var(--line); }
.conv.active::before { content: ''; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 3px; background: var(--grad); }
.conv-mid { flex: 1; min-width: 0; }
.conv-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.conv-row strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-row time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.conv-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv.unread .conv-last { color: var(--ink); font-weight: 600; } .conv.unread time { color: var(--acc); font-weight: 700; }
.conv-bot { font-size: 11px; color: #a19dae; margin-top: 2px; font-weight: 600; } .conv-bot em { color: var(--bad); font-style: normal; }
.convs-empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.skeleton { height: 64px; margin: 6px 4px; border-radius: 14px; background: linear-gradient(90deg, var(--line-2), #faf9f6, var(--line-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.ib-thread { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative;
  background: #faf9f6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23e7e3da'/%3E%3C/svg%3E"); }
.ib-empty { margin: auto; text-align: center; padding: 30px; max-width: 360px; }
.ib-empty h3 { font-size: 30px; margin: 18px 0 6px; } .ib-empty p { margin: 0 0 18px; }
.orb { width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: 0 20px 50px -12px rgba(107,78,255,.6), inset 0 -8px 20px rgba(0,0,0,.12); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-4deg); } }

.th-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: rgba(255,255,255,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); z-index: 2; }
.th-id { flex: 1; min-width: 0; line-height: 1.3; } .th-id strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .th-id small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-body { flex: 1; overflow-y: auto; padding: 22px 7%; display: flex; flex-direction: column; gap: 4px; }
.th-hello { margin: auto; text-align: center; color: var(--muted); } .th-hello .avatar { margin-bottom: 10px; }
.day-sep { text-align: center; margin: 14px 0 8px; } .day-sep span { font-size: 11px; font-weight: 700; color: var(--muted); background: #fff; border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; letter-spacing: .02em; }
.msg { display: flex; flex-direction: column; max-width: 72%; animation: msgin .25s ease-out; }
@keyframes msgin { from { opacity: 0; transform: translateY(6px); } }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 13px 6px; border-radius: 18px; font-size: 14px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(18,16,28,.05); position: relative; }
.msg.in .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 6px 16px -8px rgba(107,78,255,.7); }
.msg.out .bubble a { color: #fff; text-decoration: underline; }
.msg.failed .bubble { background: #fff; color: var(--ink); border: 1px dashed var(--bad); }
.msg.pending { opacity: .6; }
.meta { font-size: 10.5px; opacity: .65; text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.st.fail { color: var(--bad); font-weight: 700; opacity: 1; }
.msg .err { font-size: 11.5px; color: var(--bad); margin-top: 3px; padding: 0 6px; }
.bubble .ph { display: block; margin: -5px -9px 4px; } .bubble .ph img { display: block; max-width: 300px; max-height: 340px; width: 100%; object-fit: cover; border-radius: 14px; }
.bubble video { max-width: 300px; border-radius: 12px; display: block; margin-bottom: 4px; }
.bubble audio { width: 250px; height: 36px; display: block; margin: 2px 0 4px; }
.msg.t-sticker .bubble { background: transparent !important; border: 0 !important; box-shadow: none !important; color: var(--ink) !important; }
.stk { width: 140px; height: 140px; object-fit: contain; } .big-emoji { font-size: 54px; line-height: 1; }
.filechip { display: flex; gap: 10px; align-items: center; padding: 8px 10px; margin: 0 -4px 4px; border-radius: 12px; background: rgba(18,16,28,.04); color: inherit !important; text-decoration: none !important; }
.msg.out .filechip { background: rgba(255,255,255,.16); }
.filechip span { font-size: 22px; } .filechip b { display: block; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .filechip small { opacity: .7; font-size: 11.5px; }
.msg-loading { margin: auto; display: flex; gap: 6px; } .msg-loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); animation: dot 1s infinite; }
.msg-loading span:nth-child(2) { animation-delay: .15s; } .msg-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 50% { transform: translateY(-6px); opacity: .4; } }

.composer { padding: 12px 18px 16px; background: linear-gradient(transparent, rgba(250,249,246,.95) 30%); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 6px 6px 6px 8px; box-shadow: var(--sh-2); transition: .15s; }
.composer-row:focus-within { border-color: var(--acc); box-shadow: 0 0 0 4px rgba(107,78,255,.1), var(--sh-2); }
.composer-row label.icon-btn { margin-bottom: 2px; }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; padding: 9px 4px; max-height: 180px; background: transparent; font-size: 14px; line-height: 1.45; }
.send-btn { width: 42px; height: 42px; border-radius: 13px; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; cursor: pointer; transition: .15s; box-shadow: 0 6px 14px -6px rgba(107,78,255,.8); }
.send-btn:hover:not(:disabled) { transform: translateY(-1px) rotate(-8deg); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }
.send-btn.loading { animation: spinwob .8s infinite; }
@keyframes spinwob { 50% { transform: scale(.9); } }
.composer-note { font-size: 12px; color: var(--warn); padding: 6px 8px 0; font-weight: 600; } .composer-note:empty { display: none; }
.attach-preview { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; margin-bottom: 8px; width: max-content; max-width: 100%; }
.attach-preview img { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; } .attach-preview > span { font-size: 26px; padding: 0 6px; }
.attach-preview b { display: block; font-size: 13px; } .attach-preview small { color: var(--muted); font-size: 11.5px; }

.ib-info { width: 300px; flex-shrink: 0; border-left: 1px solid var(--line); background: #fdfcfa; padding: 30px 22px; position: relative; overflow-y: auto; }
.info-close { position: absolute; right: 12px; top: 12px; }
.info-card { text-align: center; } .info-card h3 { font-size: 18px; margin: 14px 0 2px; }
.info-card dl { text-align: left; margin: 24px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; font-size: 13px; padding-top: 20px; border-top: 1px solid var(--line); }
.info-card dt { color: var(--muted); font-weight: 600; } .info-card dd { margin: 0; text-align: right; font-weight: 600; word-break: break-all; }
.toast.floating { top: auto; bottom: 24px; }

/* ---------- auth ---------- */
/* Grid lives on a wrapper, not <body>, so elements injected by browser extensions can't add grid rows */
body.auth { height: auto; min-height: 100%; }
html:has(body.auth) { height: auto; min-height: 100%; background: var(--bg); }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(400px, 1fr); grid-template-rows: 1fr; min-height: 100vh; min-height: 100dvh; }
.auth-art { position: relative; overflow: hidden; background: var(--side); color: #fff; display: flex; align-items: center; padding: clamp(32px, 5vw, 72px);
  background-image: radial-gradient(70% 60% at 10% 10%, rgba(107,78,255,.55), transparent 60%), radial-gradient(60% 60% at 90% 90%, rgba(224,56,109,.35), transparent 60%), radial-gradient(40% 40% at 80% 20%, rgba(160,92,255,.4), transparent 70%); }
.auth-art::after { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, #000, transparent); pointer-events: none; }
.auth-art-inner { position: relative; z-index: 1; max-width: 620px; }
.brand.light { padding-left: 0; margin-bottom: clamp(32px, 6vh, 60px); }
.auth-brand { display: none; color: var(--ink); padding: 0 0 8px; }
.auth-art h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 3.6vw, 60px); line-height: 1.02; letter-spacing: -.02em; }
.auth-art h2 i { background: linear-gradient(90deg, #c7b8ff, #ff9bc0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-art p { color: #c8c4d6; font-size: 16px; max-width: 420px; margin: 18px 0 40px; }
.float-chat { display: grid; gap: 10px; max-width: 400px; }
.fc { display: flex; align-items: flex-end; gap: 8px; animation: msgin .6s both; }
.fc:nth-child(2) { animation-delay: .4s; } .fc:nth-child(3) { animation-delay: .8s; }
.fc p { margin: 0; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; background: rgba(255,255,255,.1); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.12); border-bottom-left-radius: 5px; }
.fc.out { justify-content: flex-end; } .fc.out p { background: var(--grad); border: 0; border-radius: 16px 16px 5px 16px; box-shadow: 0 10px 30px -10px rgba(107,78,255,.8); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 30px; letter-spacing: -.03em; } .auth-card > p { margin: -10px 0 8px; }
.auth-card .input-ic input { height: 48px; }
@media (max-width: 1024px) {
  .auth-shell { grid-template-columns: 1fr; } .auth-art { display: none; } .auth-brand { display: flex; }
}

body.install { display: grid; place-items: center; padding: 40px 16px; background: radial-gradient(60% 50% at 50% 0%, #efe9ff, var(--bg)); }
.install-wrap { width: 100%; max-width: 680px; } .install-wrap > .brand { color: var(--ink); justify-content: center; }
.install-wrap .card h2 { font-size: 24px; margin-bottom: 4px; } .install-wrap .card > p { margin: 0 0 18px; }
.install-wrap .sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 22px 0 10px; }
.install-wrap .btn { margin-top: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .ib-info { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: var(--sh-2); } .inbox { position: relative; } }
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-bots { grid-template-columns: 1fr; }
  .connect-card { position: static; }
  .ph-stats { display: none; }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .sidebar { position: fixed; left: 0; z-index: 60; transform: translateX(-100%); transition: .25s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(18,16,28,.4); z-index: 55; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .hero { flex-direction: column; align-items: flex-start; } .hero h2 { font-size: 34px; }
  .stats { gap: 10px; } .stat { padding: 16px; } .stat-val { font-size: 24px; }
  .grid2 { grid-template-columns: 1fr; }
  .profile-head { flex-direction: column; text-align: center; } .profile-head h2 { justify-content: center; }
  .topbar-actions .btn { padding: 0 12px; }
  .bot-card.row { flex-wrap: wrap; }

  .page-inbox .content { padding: 0; } .page-inbox .main { height: 100dvh; }
  .inbox { border-radius: 0; border: 0; margin: 0; }
  .ib-list { width: 100%; border: 0; }
  .ib-thread { display: none; }
  .show-thread .ib-list { display: none; } .show-thread .ib-thread { display: flex; }
  .ib-list-head { padding-top: 14px; }
  .page-inbox .ib-list-head::before { content: none; }
  .th-head { padding: 10px 12px; } .th-body { padding: 16px 12px; } .msg { max-width: 86%; } .composer { padding: 8px 10px 12px; }
  .ib-info { width: 100%; }
}
@media (max-width: 860px) { .page-inbox .topbar { display: flex; padding: 12px 16px 0; } .show-thread .topbar { display: none !important; } }

/* ---------- live updates ---------- */
.rt-stack { position: fixed; right: 24px; bottom: 24px; z-index: 120; display: grid; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.rt-pop { display: grid; gap: 2px; padding: 12px 16px 12px 46px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: var(--sh-2); position: relative; animation: slidein .3s ease-out; transition: .4s; }
.rt-pop::before { content: '💬'; position: absolute; left: 15px; top: 12px; font-size: 17px; }
.rt-pop b { font-size: 13.5px; } .rt-pop span { font-size: 12.5px; color: #c8c4d6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-pop:hover { background: #26222f; }
.rt-pop.hide { opacity: 0; transform: translateY(10px); }
.rt-bell { height: 34px; font-size: 12.5px; }

/* ---------- automation in inbox ---------- */
.flow-tag { display: inline-block; padding: 1px 7px; border-radius: 99px; background: var(--acc-soft); color: var(--acc); font-weight: 700; font-size: 10.5px; }
.flow-bar { display: flex; align-items: center; gap: 12px; margin: 0 18px; padding: 10px 12px 10px 14px; border-radius: 14px; background: var(--acc-soft); border: 1px solid #ddd4ff; }
.flow-bar .flow-ic { font-size: 20px; }
.flow-bar div { flex: 1; min-width: 0; line-height: 1.3; } .flow-bar b { font-size: 13px; display: block; } .flow-bar small { font-size: 12px; color: var(--ink-2); }
.flow-bar .btn { height: 34px; flex-shrink: 0; }
.msg.out.auto .bubble { background: #ece8ff; color: var(--ink); box-shadow: none; border: 1px solid #ddd4ff; }
.msg.out.auto .bubble a { color: var(--acc); }
.info-card .answers { text-align: left; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.info-card .answers h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.info-card .answers dl { margin: 12px 0 0; padding: 0; border: 0; grid-template-columns: 1fr; gap: 2px; }
.info-card .answers dt { font-size: 12px; } .info-card .answers dd { text-align: left; margin-bottom: 10px; word-break: break-word; }

/* ---------- bots: automation link ---------- */
.bot-flow { display: flex; align-items: center; gap: 8px; margin: -6px 0 14px; padding: 9px 12px; border-radius: 12px; background: var(--line-2); color: var(--ink-2); font-size: 13px; font-weight: 600; }
.bot-flow span { flex: 1; } .bot-flow b { font-size: 12px; color: var(--muted); } .bot-flow b.on { color: var(--ok); }
.bot-flow:hover { background: var(--acc-soft); color: var(--acc); }

/* ---------- workflow editor ---------- */
.wf-bots { margin-bottom: 18px; }
.wf-bots .chip { display: inline-flex; align-items: center; gap: 6px; }
.dot-on { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; }
.wf-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.wf-main { display: grid; gap: 14px; }
.wf-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.wf-head-txt { flex: 1; min-width: 240px; } .wf-head h3 { font-size: 17px; margin-bottom: 4px; } .wf-head p { margin: 0; }
.wf-toggle { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13px; cursor: pointer; }
.note-info { background: var(--acc-soft); color: var(--acc); margin-top: 0; }
.wf-main .sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 12px; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.wf-steps { display: grid; gap: 14px; position: relative; }
.wf-step { display: grid; gap: 12px; position: relative; }
.wf-step + .wf-step::before { content: ''; position: absolute; left: 35px; top: -15px; height: 14px; border-left: 2px dashed #d6cffa; }
.wf-step-head { display: flex; align-items: center; gap: 10px; }
.wf-step-head strong { font-size: 14px; }
.wf-num { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.wf-num.hand { background: var(--ink); }
.wf-step-tools { margin-left: auto; display: flex; gap: 2px; } .wf-step-tools .icon-btn { width: 32px; height: 32px; font-weight: 700; }
.wf-step-tools .icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.field > span em { font-style: normal; font-weight: 500; }
.wf-step-foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.wf-check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 44px; }
.wf-check input { width: 17px; height: 17px; accent-color: var(--acc); }
.wf-saveas { flex: 1; min-width: 200px; }
.wf-add { justify-self: start; border-style: dashed; }
.wf-handoff { display: grid; gap: 12px; }
.wf-save { position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 35%); }
.wf-preview { position: sticky; top: 20px; overflow: hidden; }
.wf-phone-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.wf-phone-head div { line-height: 1.25; } .wf-phone-head strong { display: block; font-size: 13.5px; } .wf-phone-head small { font-size: 11.5px; color: var(--muted); }
.wf-phone { display: flex; flex-direction: column; gap: 6px; padding: 16px; max-height: calc(100vh - 160px); overflow-y: auto; background: #f4f1fb; min-height: 300px; }
.pv { max-width: 85%; padding: 8px 12px; border-radius: 16px; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.pv.out { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.pv.out b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-right: 6px; border-radius: 6px; background: var(--acc-soft); color: var(--acc); font-size: 10.5px; vertical-align: 1px; }
.pv.in { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.pv.in.ghost { opacity: .55; font-style: italic; } .pv.in small { display: block; font-size: 10.5px; font-style: normal; opacity: .85; }
.pv-btns { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 5px; max-width: 90%; }
.pv-btns span { padding: 5px 10px; border-radius: 9px; background: #fff; border: 1px solid #ddd4ff; color: var(--acc); font-size: 12px; font-weight: 600; }
.pv-hand { align-self: center; margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); background: #fff; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); }
@media (max-width: 1100px) { .wf-grid { grid-template-columns: 1fr; } .wf-preview { position: static; } }
@media (max-width: 860px) { .flow-bar { margin: 0 10px; } .flow-bar small { display: none; } .rt-bell { display: none; } }
