:root {
  --bg: #ffffff;
  --panel: #fafafa;
  --hover: #f4f4f5;
  --active: #ededee;
  --border: #e7e7e9;
  --border-strong: #d4d4d8;
  --ink: #0a0a0a;
  --text: #27272a;
  --muted: #71717a;
  --faint: #a1a1aa;
  --primary: #0a0a0a;
  --primary-ink: #ffffff;
  --alert: #ea580c;
  --alert-bg: #fff7ed;
  --danger: #dc2626;
  --ok: #16a34a;
  --blue: #2563eb;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 8px 30px rgba(0, 0, 0, .08), 0 1px 3px rgba(0, 0, 0, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
a { color: inherit; }
h1, h2, h3 { color: var(--ink); margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; margin: 18px 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
code { background: var(--hover); padding: 1px 5px; border-radius: 5px; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: var(--ink); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt0 { margin-top: 0; }
.grow { flex: 1; }
.min0 { min-width: 0; }
.right { text-align: right; white-space: nowrap; }
.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.self-start { align-self: flex-start; }
.icon { flex: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg); color: var(--ink); font-weight: 500; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s, transform .1s; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { background: #27272a; }
.btn.ghost { box-shadow: none; border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; height: 40px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); background: transparent; border-color: transparent; box-shadow: none; padding: 0 6px; margin-top: 14px; }
.btn.danger-ghost:hover { background: #fef2f2; }
.icon-btn { width: 32px; height: 32px; flex: none; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.link-sm { font-size: 13px; color: var(--muted); text-decoration: none; }
.link-sm:hover { color: var(--ink); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label { font-weight: 500; font-size: 13px; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--muted); }
.counter { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), textarea, select { width: 100%; border: 1px solid var(--border); background: var(--bg); border-radius: var(--r); padding: 8px 11px; outline: none; transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow-sm); }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]) { height: 36px; }
input:focus, textarea:focus, select:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(10, 10, 10, .06); }
input:disabled, input[readonly] { background: var(--panel); color: var(--muted); }
textarea { resize: vertical; line-height: 1.55; min-height: 64px; }
textarea.prompt { font-size: 13.5px; min-height: 180px; }
input[type=range] { width: 100%; accent-color: var(--primary); }
.input-row { display: flex; gap: 6px; align-items: center; }
.list-row { display: flex; gap: 6px; align-items: center; }
.form-error { color: var(--danger); font-size: 13px; background: #fef2f2; border-radius: 8px; padding: 8px 10px; }
.notice { font-size: 13px; background: var(--alert-bg); color: #9a3412; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { max-width: 320px; }
.inline-action { margin: -4px 0 8px; }

.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); cursor: pointer; }
.card-head + .toggle-row { border-top: 0; padding-top: 4px; }
.toggle-row.disabled { opacity: .55; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; }
.toggle-label { font-weight: 500; color: var(--ink); }
.switch { flex: none; position: relative; width: 36px; height: 20px; border-radius: 999px; border: 0; background: var(--border-strong); cursor: pointer; transition: background .2s; margin-top: 2px; }
.switch i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.switch.on { background: var(--primary); }
.switch.on i { transform: translateX(16px); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--hover); border-radius: var(--r); width: fit-content; max-width: 100%; }
.segmented button { border: 0; background: transparent; border-radius: 7px; padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.segmented button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.03); }

.color-input { display: flex; gap: 6px; align-items: center; }
.color-input input[type=color] { width: 36px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); cursor: pointer; flex: none; }
.color-input input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type=color]::-webkit-color-swatch { border: 0; border-radius: 7px; }

/* ---------- layout ---------- */
.splash, .page-loading { display: grid; place-items: center; height: 100%; min-height: 160px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--ink); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell { display: grid; grid-template-columns: 248px 1fr; height: 100%; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px 10px; min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; color: var(--ink); padding: 2px 8px 14px; }
.brand.big { font-size: 17px; padding: 0 0 22px; }
.auth-brand { text-decoration: none; font-size: 26px !important; letter-spacing: -.8px; }
.auth-byline { margin-left: auto; font-size: 11px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.auth-footer { text-align: center; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 18px; padding-top: 16px; }
.auth-footer a { text-underline-offset: 3px; }
.auth-link { margin-top: 9px; }
.auth-success { background: #effaf3; border: 1px solid #d2ebdc; color: #28764a; border-radius: 8px; padding: 11px; font-size: 12px; line-height: 1.7; margin-bottom: 16px; }
.brand-orb { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.9), transparent 42%), conic-gradient(from 40deg, #2792dc, #9ce6e6, #2792dc); flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.role { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }
.ws-switch { position: relative; margin-bottom: 10px; }
.ws-current { width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 8px; border: 1px solid var(--border); background: var(--bg); border-radius: var(--r); cursor: pointer; text-align: left; box-shadow: var(--shadow-sm); }
.ws-current:hover { border-color: var(--border-strong); }
.ws-avatar { width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; text-transform: uppercase; }
.ws-avatar.sm { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
.ws-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ws-name { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-site { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 4px; max-height: 360px; overflow-y: auto; }
.ws-menu a { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; text-decoration: none; font-size: 13.5px; }
.ws-menu a:hover, .ws-menu a.on { background: var(--hover); }
nav { display: flex; flex-direction: column; gap: 1px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 500; font-size: 13.5px; transition: background .12s; }
nav a .icon { color: var(--muted); }
nav a:hover { background: var(--hover); }
nav a.on { background: var(--active); color: var(--ink); }
nav a.on .icon { color: var(--ink); }
.nav-label { font-size: 11.5px; color: var(--faint); padding: 14px 9px 4px; font-weight: 500; }
.count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; display: grid; place-items: center; background: var(--active); color: var(--text); font-weight: 600; }
.count.alert { background: var(--alert); color: #fff; animation: pop .3s; }
@keyframes pop { from { transform: scale(.6); } }
.me { margin-top: auto; display: flex; align-items: center; gap: 4px; padding-top: 10px; border-top: 1px solid var(--border); }
.me-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; text-decoration: none; padding: 6px; border-radius: 8px; }
.me-link:hover, .me-link.on { background: var(--hover); }
.me-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-name { font-weight: 500; font-size: 13px; color: var(--ink); }
.me-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-initial { width: 28px; height: 28px; border-radius: 50%; background: var(--active); color: var(--ink); display: inline-grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.avatar-initial.sm { width: 24px; height: 24px; font-size: 11px; margin-right: 8px; vertical-align: middle; }
.main { min-width: 0; min-height: 0; overflow-y: auto; position: relative; }
.mobile-bar, .scrim { display: none; }

.page { max-width: 880px; margin: 0 auto; padding: 28px 28px 110px; }
.page.wide { max-width: 1240px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.page-head p a { color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 11px; font-weight: 500; color: #7e22ce; background: #faf5ff; border-radius: 6px; padding: 1px 6px; flex: none; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 32px 0 12px; }
.demo-try { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.demo-try .icon { color: var(--muted); }
.demo-try input { flex: 1; }
.demo-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-lg); background: #faf5ff; border: 1px solid #e9d5ff; color: #581c87; margin-bottom: 16px; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card.danger { border-color: #fecaca; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, #eef6ff, transparent 60%), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--bg); border: 1px solid var(--border); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 6px 0 22px; }

/* ---------- overview ---------- */
.alert-card { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: var(--r-lg); background: var(--alert-bg); border: 1px solid #fed7aa; color: #9a3412; text-decoration: none; margin-bottom: 16px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--alert); box-shadow: 0 0 0 0 rgba(234,88,12,.5); animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(234,88,12,0); } 100% { box-shadow: 0 0 0 0 rgba(234,88,12,0); } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-link { text-decoration: none; transition: border-color .15s, background .15s; }
.stat-link:hover { border-color: var(--border-strong); background: var(--panel); }
.stat { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--faint); }
.grid-overview { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.grid-overview > * { min-width: 0; }
.card-head { flex-wrap: wrap; }
.grid-overview .card { margin-bottom: 16px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.lg-a { background: #d4d4d8; }
.lg-h { background: var(--alert); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar { width: 100%; min-height: 2px; background: #d4d4d8; border-radius: 4px 4px 2px 2px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; transition: height .4s cubic-bezier(.2,.8,.2,1); }
.bar-col:hover .bar { background: #a1a1aa; }
.bar-h { background: var(--alert); width: 100%; }
.bar-label { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.recent { display: flex; flex-direction: column; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; margin: 0 -6px; border-radius: 8px; text-decoration: none; }
.recent-item:hover { background: var(--hover); }
.recent-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; color: var(--ink); }
.recent-item .muted.ellipsis { display: block; }
.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checklist a { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r); text-decoration: none; transition: border-color .15s, background .15s; }
.checklist a:hover { background: var(--panel); border-color: var(--border-strong); }
.checklist a > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.checklist strong { color: var(--ink); font-weight: 500; }
.step-n { width: 24px; height: 24px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--hover); color: var(--muted); }
.pill.ai { background: #eff6ff; color: #1d4ed8; }
.pill.waiting { background: var(--alert-bg); color: #c2410c; }
.pill.human { background: #f0fdf4; color: #15803d; }
.pill.closed { background: var(--hover); color: var(--muted); }
.pill.test { background: #faf5ff; color: #7e22ce; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 340px 1fr; height: 100%; min-height: 0; }
.conv-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.conv-list-head { padding: 20px 16px 0; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--border); }
.conv-list-head h1 { font-size: 18px; }
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 10px; color: var(--faint); }
.search input { padding-left: 32px !important; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 -4px; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 8px 8px 10px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.tab-count { font-size: 11px; background: var(--hover); color: var(--muted); border-radius: 9px; padding: 0 6px; min-width: 18px; text-align: center; }
.tab-count.alert { background: var(--alert); color: #fff; }
.conv-items { flex: 1; overflow-y: auto; padding: 6px; }
.conv-item { display: flex; gap: 10px; padding: 10px; border-radius: 10px; text-decoration: none; position: relative; transition: background .12s; }
.conv-item:hover { background: var(--hover); }
.conv-item.on { background: var(--active); }
.conv-item.waiting::before { content: ''; position: absolute; left: 2px; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--alert); }
.conv-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #e4e4e7, #f4f4f5); color: var(--text); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.conv-avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--faint); white-space: nowrap; }
.conv-preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tags { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.unread { margin-left: auto; min-width: 18px; height: 18px; border-radius: 9px; background: var(--alert); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; padding: 0 5px; }

.thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.empty-thread { align-items: center; justify-content: center; background: var(--panel); }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); min-height: 64px; }
.thread-head .back { display: none; }
.thread-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); font-size: 15px; }
.thread-actions { display: flex; align-items: center; gap: 6px; }
.thread-body { flex: 1; display: flex; min-height: 0; }
.thread-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; background: var(--panel); }
.day-note { align-self: center; font-size: 12px; color: var(--faint); }
.msg { display: flex; flex-direction: column; max-width: min(620px, 78%); }
.msg.visitor { align-self: flex-start; }
.msg.ai, .msg.team { align-self: flex-end; align-items: flex-end; }
.msg time { font-size: 11px; color: var(--faint); margin-top: 3px; padding: 0 4px; }
.msg .who { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 4px; padding: 0 4px; }
.cost { font-size: 11px; color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }
.bubble { padding: 9px 13px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border); color: var(--ink); overflow-wrap: anywhere; }
.msg.visitor .bubble { border-bottom-left-radius: 5px; }
.msg.ai .bubble { background: #eef4ff; border-color: #dbe6fe; border-bottom-right-radius: 5px; }
.msg.team .bubble { background: var(--ink); border-color: var(--ink); color: #fff; border-bottom-right-radius: 5px; }
.msg.team .bubble a { color: #fff; }
.bubble.error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.bubble.md p { margin: 0 0 7px; }
.bubble.md p:last-child, .bubble.md ul:last-child { margin-bottom: 0; }
.bubble.md ul { margin: 0 0 7px; padding-left: 18px; }
.bubble a { color: var(--blue); }
.pre { white-space: pre-wrap; }
.msg-img { display: block; max-width: 260px; max-height: 220px; border-radius: 8px; margin-bottom: 6px; object-fit: cover; }
.steps-toggle { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0 4px 4px; }
.steps-toggle:hover { color: var(--ink); }
.steps { margin: 0 0 6px; padding: 8px 12px 8px 28px; font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; align-self: stretch; }
.steps li { display: flex; justify-content: space-between; gap: 12px; }
.steps li.error span:first-child { color: #b45309; }
.mini-products { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.mini-product { display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); text-decoration: none; font-size: 12px; max-width: 260px; }
.mini-product img, .mini-product .ph { width: 26px; height: 26px; object-fit: contain; border-radius: 5px; background: var(--hover); flex: none; }
.mp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-price { font-weight: 600; color: var(--ink); white-space: nowrap; }
.sys-note { align-self: stretch; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.sys-note::before, .sys-note::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.sys-note time { color: var(--faint); }
.typing { display: flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, to { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.thread-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; font-size: 13px; border-top: 1px solid var(--border); background: var(--bg); }
.thread-banner.waiting { background: var(--alert-bg); border-top-color: #fed7aa; color: #9a3412; }
.reply { padding: 10px 16px 14px; border-top: 1px solid var(--border); background: var(--bg); }
.reply textarea { min-height: 54px; max-height: 200px; resize: none; border-radius: 12px; }
.reply-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.details { width: 280px; flex: none; border-left: 1px solid var(--border); padding: 4px 18px 18px; overflow-y: auto; }
.details dl { margin: 0; display: grid; grid-template-columns: 1fr; }
.details dt { font-size: 12px; color: var(--muted); margin-top: 8px; }
.details dd { margin: 1px 0 0; overflow-wrap: anywhere; color: var(--ink); }
.details a { color: var(--blue); }

/* ---------- designer ---------- */
.designer { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 20px; align-items: start; }
.designer-preview { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 8px; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; }
.designer-preview iframe { width: 100%; height: max(520px, min(760px, calc(100vh - 150px))); border: 1px solid var(--border); border-radius: var(--r-lg); background: #f6f6f7; box-shadow: var(--shadow-sm); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.preset { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 5px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.preset:hover { border-color: var(--border-strong); background: var(--panel); }
.preset-orb { width: 22px; height: 22px; border-radius: 50%; }
.preset-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- install / team / clients ---------- */
pre.code { margin: 0; padding: 14px 16px; background: #0a0a0a; color: #e4e4e7; border-radius: var(--r); font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.howto { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.howto div { display: flex; flex-direction: column; gap: 2px; }
.howto strong { color: var(--ink); font-weight: 500; }
.chips-edit { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-edit { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 4px 0 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--panel); }
.chip-edit button { width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.chip-edit button:hover:not(:disabled) { background: var(--active); color: var(--ink); }
.chip-edit button:disabled { opacity: .35; cursor: default; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.client-card { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; }
.client-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.client-top { display: flex; align-items: center; gap: 10px; }
.client-top .grow { display: flex; flex-direction: column; }
.client-name { font-weight: 600; color: var(--ink); }
.client-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.client-stats strong { color: var(--ink); font-weight: 600; }
.alert-text { color: var(--alert) !important; }
.online { font-size: 11.5px; color: var(--ok); display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ---------- empty, modal, toasts, savebar ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 20px; gap: 6px; }
.empty-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--hover); color: var(--muted); display: grid; place-items: center; margin-bottom: 4px; }
.empty-title { font-weight: 600; color: var(--ink); }
.empty-text { color: var(--muted); font-size: 13px; max-width: 320px; }
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 10, .35); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--bg); border-radius: 16px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.2); max-height: calc(100vh - 32px); overflow-y: auto; animation: rise .2s cubic-bezier(.2,.8,.2,1); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toasts { position: fixed; z-index: 60; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; animation: rise .2s cubic-bezier(.2,.8,.2,1); max-width: min(520px, calc(100vw - 32px)); }
.toast.error { background: var(--danger); }
.toast.alert { background: var(--alert); }
.toast .btn { background: #fff; color: var(--ink); border-color: #fff; box-shadow: none; }
.savebar { position: fixed; z-index: 30; bottom: 18px; left: calc(50% + 124px); transform: translate(-50%, 140%); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .2s; opacity: 0; font-weight: 500; }
.savebar.show { transform: translate(-50%, 0); opacity: 1; }
.savebar span { margin-right: 6px; color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .details { display: none; }
  .designer { grid-template-columns: 1fr; }
  .designer-preview { position: static; order: -1; }
  .designer-preview iframe { height: 560px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 268px; transform: translateX(-100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.25); }
  .mobile-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--ink); position: sticky; top: 0; background: var(--bg); z-index: 5; }
  .main { display: flex; flex-direction: column; }
  .inbox { flex: 1; grid-template-columns: 1fr; min-height: 0; }
  .inbox.has-thread .conv-list { display: none; }
  .inbox:not(.has-thread) .thread { display: none; }
  .thread-head .back { display: inline-grid; }
  .page { padding: 20px 16px 110px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-overview, .checklist, .howto { grid-template-columns: 1fr; }
  .savebar { left: 50%; }
  .msg { max-width: 92%; }
  .thread-actions .btn span { display: none; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .thread-actions .btn { padding: 0 8px; }
  .inline-form { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- AI costs ---------- */
.cost-stats { grid-template-columns: 1.3fr repeat(5, minmax(0, 1fr)); }
.cost-stats .stat-value { font-size: 22px; }
.cost-stats .stat.hero .stat-value { font-size: 30px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.card-head.padded { padding: 16px 18px 0; margin-bottom: 12px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .strong { font-weight: 600; color: var(--ink); }
.table .nowrap { white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel); }
.table a { color: var(--ink); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.share-col { width: 180px; }
.share { display: inline-block; vertical-align: middle; width: 110px; height: 6px; border-radius: 3px; background: var(--hover); margin-right: 8px; overflow: hidden; }
.share i { display: block; height: 100%; border-radius: 3px; }
.chat-cell { max-width: 460px; }
.chat-cell a { overflow-wrap: anywhere; }
.cchart { padding: 4px 0 0 56px; }
.cchart-plot { position: relative; height: 200px; }
.cchart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.cchart-grid span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cchart-cols { position: absolute; inset: 0; display: flex; align-items: stretch; }
.cchart-slot { flex: 1; min-width: 0; position: relative; display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; outline: none; }
.cchart-slot:focus-visible { box-shadow: inset 0 0 0 2px var(--blue); border-radius: 4px; }
.cchart-col { width: 100%; max-width: 24px; min-height: 0; border-radius: 4px 4px 0 0; transition: opacity .15s; }
.cchart-tip { position: absolute; z-index: 3; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px; white-space: nowrap; pointer-events: none; color: var(--ink); }
.cchart-slot .cchart-tip { bottom: auto; top: 8px; }
.cchart-tip.left { left: auto; right: 50%; transform: none; }
.cchart-tip strong { font-weight: 600; }
.cchart-x { display: flex; margin-top: 6px; }
.cchart-x span { flex: 1; min-width: 0; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: visible; }
.cost { font-size: 11px; color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }
.conv-cost { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .cost-stats { grid-template-columns: 1fr 1fr; } .share-col { display: none; } }

/* ---------- Interested clients (super admin) ---------- */
.interest-page { max-width: 1080px; }
.interest-page .page-head > div { max-width: 650px; }
.interest-list { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); overflow: hidden; }
.interest-entry { padding: 20px 22px; }
.interest-entry + .interest-entry { border-top: 1px solid var(--border); }
.interest-entry-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.interest-contact { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.interest-contact h2 { font-size: 14px; }
.interest-email { font-size: 13px; color: var(--blue); overflow-wrap: anywhere; text-decoration: none; }
a.interest-email:hover, .interest-website a:hover { text-decoration: underline; text-underline-offset: 3px; }
.interest-meta { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; flex-shrink: 0; }
.interest-source { padding: 3px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.interest-meta time { font-variant-numeric: tabular-nums; }
.interest-website { display: flex; align-items: center; gap: 7px; color: var(--muted); margin-top: 11px; font-size: 12px; }
.interest-website a { overflow-wrap: anywhere; text-decoration: none; }
.interest-website span { overflow-wrap: anywhere; }
.interest-message { margin: 12px 0 0; padding: 11px 13px; background: var(--panel); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; line-height: 1.75; color: var(--text); }
.interest-list-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; }
.interest-error { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid #fecaca; border-radius: var(--r); color: #b91c1c; background: #fff7f7; padding: 12px 14px; margin-bottom: 18px; font-size: 13px; }
@media (max-width: 700px) {
  .interest-entry { padding: 17px; }
  .interest-entry-head { flex-direction: column; gap: 11px; }
  .interest-meta { justify-content: flex-start; flex-shrink: 1; }
  .interest-error { align-items: flex-start; }
}

/* visitor presence */
.conv-avatar { position: relative; }
.presence-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 2px var(--bg, #fff); }
.presence { display: inline-flex; align-items: center; gap: 5px; color: var(--muted, #888); }
.presence i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .5; }
.presence.on { color: #22a06b; }
.presence.on i { opacity: 1; }
