:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --navy-3: #334155;
  --blue: #3b82f6;
  --blue-d: #2563eb;
  --blue-l: #60a5fa;
  --blue-soft: #eff6ff;
  --blue-soft-2: #dbeafe;
  --bg: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-2: #f1f5f9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --ok: #10b981;
  --bad: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--line-2); padding: 1px 5px; border-radius: 5px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .3); }
.btn-primary:hover { background: var(--blue-d); }
.btn-primary:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn-secondary { background: var(--panel); border-color: var(--line); color: var(--text-2); }
.btn-secondary:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--blue-d); }
.btn-ghost:hover { background: var(--blue-soft); }
.btn-danger { background: var(--panel); border-color: #fecaca; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 22px; line-height: 1; flex-shrink: 0; }
.icon-btn:hover { background: var(--line-2); color: var(--text); }
.icon-btn.on { background: var(--blue-soft); color: var(--blue-d); }
.icon-btn svg { width: 18px; height: 18px; }

/* avatars */
.av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase; flex-shrink: 0; background: var(--navy-3); letter-spacing: .02em; }
.av-sm { width: 28px; height: 28px; font-size: 11px; }
.av-lg { width: 40px; height: 40px; font-size: 14px; }
.av-xl { width: 64px; height: 64px; font-size: 22px; }

/* ---------- sign-in ---------- */
.login { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px 140px; overflow: hidden;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%); }
.login-glow { position: absolute; inset: 0; background: radial-gradient(60% 50% at 80% 10%, rgba(59, 130, 246, .35), transparent 70%), radial-gradient(50% 40% at 10% 90%, rgba(96, 165, 250, .18), transparent 70%); pointer-events: none; }
.login-wave { position: absolute; left: 0; bottom: -1px; width: 100%; height: 110px; display: block; }
.login-card { position: relative; width: 100%; max-width: 380px; background: var(--panel); border-radius: 18px; padding: 32px; display: grid; gap: 14px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.02em; }
.login-sub { margin: -8px 0 4px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.login-card input { font: inherit; font-weight: 400; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--bg); transition: border-color .15s, box-shadow .15s, background .15s; }
.login-card input:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); }
.error { color: var(--bad); margin: 0; min-height: 1.2em; font-size: 13px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.brand b { color: var(--blue); }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(140deg, var(--blue), #1d4ed8); color: #fff; font-weight: 800; font-size: 17px; box-shadow: 0 4px 12px rgba(37, 99, 235, .35); flex-shrink: 0; }

/* ---------- app layout ---------- */
.app { display: grid; grid-template-columns: 68px 340px minmax(0, 1fr) auto; height: 100vh; }

/* rail */
.rail { background: var(--navy); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0; }
.rail .logo { margin-bottom: 14px; }
.rail-btn { position: relative; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: #94a3b8; display: grid; place-items: center; transition: background .15s, color .15s; }
.rail-btn svg { width: 21px; height: 21px; }
.rail-btn:hover { background: rgba(255, 255, 255, .07); color: #e2e8f0; }
.rail-btn.active { background: rgba(59, 130, 246, .18); color: #fff; }
.rail-btn.active::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue-l); }
.rail-badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; border: 2px solid var(--navy); box-sizing: content-box; }
.rail-spacer { flex: 1; }
.rail-me { position: relative; }
.me-btn { position: relative; border: 0; background: none; padding: 0; border-radius: 50%; }
.me-btn .av { width: 38px; height: 38px; box-shadow: 0 0 0 2px var(--navy), 0 0 0 4px rgba(255, 255, 255, .12); }
.conn { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--bad); border: 2px solid var(--navy); }
.conn.on { background: var(--ok); }
.menu { position: absolute; left: 52px; bottom: 0; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; }
.menu-head { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu-head span { color: var(--muted); font-size: 12.5px; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; }
.menu-item:hover { background: var(--bg); }

/* inbox list */
.inbox { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px; }
.inbox-head h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.seg { display: flex; background: var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.search { position: relative; margin: 0 16px 10px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px 0 34px; font: inherit; background: var(--bg); color: var(--text); }
.search input:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(59, 130, 246, .12); }
.conv-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 11px; padding: 11px 10px; border-radius: 12px; cursor: pointer; position: relative; transition: background .12s; }
.conv:hover { background: var(--bg); }
.conv.active { background: var(--blue-soft); }
.conv.active::before { content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue); }
.conv-av { position: relative; }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { color: var(--faint); font-size: 12px; flex-shrink: 0; }
.conv-bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.conv-preview { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview .you { color: var(--faint); }
.conv.unread .conv-name { color: var(--text); font-weight: 700; }
.conv.unread .conv-preview { color: var(--text-2); font-weight: 500; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }
.online-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }
.conv-empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.conv-empty b { display: block; color: var(--text-2); margin-bottom: 4px; }

/* thread */
.thread { min-width: 0; min-height: 0; display: flex; background: var(--bg); }
.empty { flex: 1; display: grid; place-items: center; padding: 24px; }
.empty-card { max-width: 520px; text-align: center; }
.empty-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; margin: 0 auto 16px; }
.empty-icon svg { width: 30px; height: 30px; }
.empty h3 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.01em; }
.empty p { color: var(--muted); margin: 0 0 16px; }
.snippet { position: relative; text-align: left; background: var(--navy); border-radius: 12px; padding: 14px 70px 14px 14px; margin-bottom: 16px; }
.snippet pre { margin: 0; color: #bfdbfe; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.snippet .btn { position: absolute; top: 10px; right: 10px; color: #bfdbfe; }
.snippet .btn:hover { background: rgba(255, 255, 255, .08); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 68px; }
.who-av { position: relative; }
.chat-who { flex: 1; min-width: 0; }
.chat-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { color: var(--muted); font-size: 12.5px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.chat-sub .sub-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip { flex-shrink: 0; }
.av svg { width: 55%; height: 55%; }
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--muted); }
.chip.open { background: #dcfce7; color: #15803d; }
.chip.closed { background: var(--line-2); color: var(--muted); }
.back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 8px 24px 16px; }
.day { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; font-weight: 600; margin: 18px 0 6px; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.group { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; }
.group.op { flex-direction: row-reverse; }
.group .av { margin-bottom: 20px; }
.stack { display: flex; flex-direction: column; gap: 3px; max-width: min(620px, 72%); min-width: 0; }
.group.op .stack { align-items: flex-end; }
.who { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 4px 2px; }
.bubble { padding: 9px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.group.visitor .bubble { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.group.visitor .bubble:has(+ .bubble) { border-bottom-left-radius: 6px; }
.group.visitor .bubble + .bubble { border-top-left-radius: 6px; }
.group.op .bubble { background: var(--blue); color: #fff; }
.group.op .bubble:has(+ .bubble) { border-bottom-right-radius: 6px; }
.group.op .bubble + .bubble { border-top-right-radius: 6px; }
.meta { font-size: 11.5px; color: var(--faint); margin: 3px 6px 0; }
.typing-dots { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.sys { text-align: center; color: var(--muted); font-size: 12.5px; margin: 16px 0 4px; }

.composer { padding: 0 20px 18px; background: var(--bg); }
.composer-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(59, 130, 246, .12); }
.composer textarea { display: block; width: 100%; resize: none; border: 0; background: none; font: inherit; color: var(--text); padding: 12px 14px 4px; max-height: 200px; outline: none; }
.composer textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 8px 14px; }
.hint { color: var(--faint); font-size: 12px; }
#send { margin-left: auto; }

/* visitor details */
.info { width: 300px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 24px 20px; }
.info-top { text-align: center; padding-bottom: 18px; border-bottom: 1px solid var(--line-2); }
.info-top .who-av { display: inline-block; margin-bottom: 10px; }
.info-top .online-dot { width: 16px; height: 16px; border-width: 3px; }
.info-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.info-status { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.info-status.on { color: #059669; font-weight: 600; }
.info h4 { margin: 18px 0 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.kv { display: grid; gap: 10px; margin: 0; }
.kv div { display: grid; gap: 1px; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; color: var(--text-2); }
.kv a { color: var(--blue-d); text-decoration: none; }
.kv a:hover { text-decoration: underline; }
.kv .none { color: var(--faint); }

/* dialog */
.dialog { border: 0; border-radius: 16px; padding: 0; width: min(460px, calc(100vw - 32px)); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 0; margin: 0; }
.dialog-head h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 17px; }
.dialog-head h3 svg { width: 22px; height: 22px; color: #229ed9; }
.dialog-body { padding: 14px 20px 22px; }
.dialog-body p { margin: 0 0 12px; color: var(--text-2); }
.steps { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 10px; color: var(--text-2); }
.steps li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-d); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex-shrink: 0; }
.status-ok { display: flex; align-items: center; gap: 8px; color: #047857; font-weight: 600; background: #ecfdf5; border-radius: 10px; padding: 10px 12px; }
.code { font: 700 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; background: var(--bg); border: 1px dashed #cbd5e1; border-radius: 12px; padding: 16px; text-align: center; margin: 0 0 14px; color: var(--navy); }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 360px; animation: rise .2s ease; }
.toast.err { background: #b91c1c; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* inbox filters */
.filters { display: flex; gap: 6px; padding: 0 16px 10px; }
.filters button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.filters button span { color: var(--faint); font-weight: 500; margin-left: 2px; }
.filters button.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filters button.active span { color: #94a3b8; }
.conv-site { font-size: 11px; font-weight: 600; color: var(--blue-d); background: var(--blue-soft); border-radius: 6px; padding: 1px 6px; flex-shrink: 0; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-assignee { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--line-2); border-radius: 6px; padding: 1px 6px; flex-shrink: 0; }

/* chat header: assignment */
.assign { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--panel); }
.assign svg { width: 15px; height: 15px; flex-shrink: 0; }
.assign select { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0 4px; max-width: 150px; cursor: pointer; outline: none; }

/* notes and attachments */
.group.note .bubble { background: #fef9c3; color: #713f12; border: 1px solid #fde68a; }
.group.note .who::after { content: " · internal note"; font-weight: 500; color: #a16207; }
.bubble.att { padding: 4px; background: transparent !important; border: 0 !important; box-shadow: none !important; }
.att-img { display: block; max-width: 280px; max-height: 260px; border-radius: 14px; border: 1px solid var(--line); background: var(--line-2); object-fit: cover; cursor: zoom-in; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; min-width: 200px; max-width: 300px; }
.att-file:hover { border-color: #cbd5e1; }
.att-file .fi { width: 36px; height: 36px; border-radius: 9px; background: var(--blue-soft); color: var(--blue-d); display: grid; place-items: center; flex-shrink: 0; }
.att-file .fi svg { width: 18px; height: 18px; }
.att-file b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file small { color: var(--muted); font-size: 12px; }
.att-file > span:last-child { min-width: 0; }
.group.op .bubble.att + .bubble, .group.visitor .bubble.att + .bubble { border-radius: 18px; }
.pending { opacity: .6; }

/* composer: reply / note, attach, saved replies */
.composer { position: relative; }
.composer-tabs { display: flex; gap: 2px; padding: 6px 8px 0; }
.composer-tabs button { border: 0; background: none; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.composer-tabs button.active { background: var(--blue-soft); color: var(--blue-d); }
.composer-tabs button[data-mode="note"].active { background: #fef9c3; color: #a16207; }
.composer-box.note { background: #fffbeb; border-color: #fde68a; }
.composer-box.note:focus-within { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .14); }
.composer-bar .icon-btn { width: 32px; height: 32px; }
.composer-bar .hint { margin-right: auto; }
.canned-pop { position: absolute; left: 20px; right: 20px; bottom: calc(100% - 10px); max-height: 260px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 10; }
.canned-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; }
.canned-item.sel, .canned-item:hover { background: var(--blue-soft); }
.canned-item b { font-size: 13px; }
.canned-item code { margin-right: 8px; color: var(--blue-d); background: none; padding: 0; }
.canned-item span { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canned-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.drop { position: absolute; inset: 68px 0 0; background: rgba(59, 130, 246, .08); border: 2px dashed var(--blue); border-radius: 12px; margin: 8px; display: grid; place-items: center; color: var(--blue-d); font-weight: 700; z-index: 5; pointer-events: none; }
.chat { position: relative; }

/* visitor details extras */
.verified { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 11px; font-weight: 700; color: #047857; background: #d1fae5; border-radius: 6px; padding: 1px 6px; vertical-align: 1px; }
.wh-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.wh-card .row { justify-content: space-between; }
.wh-name { font-weight: 700; }
.wh-sub { color: var(--muted); font-size: 12.5px; }
.wh-item { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.wh-item:first-child { border-top: 0; }
.wh-item a { color: var(--text-2); text-decoration: none; font-weight: 600; }
.wh-item a:hover { color: var(--blue-d); }
.wh-item small { display: block; color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.st { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; white-space: nowrap; align-self: flex-start; background: var(--line-2); color: var(--muted); }
.st.Active, .st.Paid { background: #dcfce7; color: #15803d; }
.st.Suspended, .st.Unpaid, .st.Overdue { background: #fee2e2; color: #b91c1c; }
.st.Pending { background: #fef3c7; color: #a16207; }
.info .btn-block { margin-top: 6px; }

/* settings */
.settings { grid-column: 2 / -1; display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 0; background: var(--bg); }
.app.view-settings .inbox, .app.view-settings .thread, .app.view-settings .info { display: none !important; }
.settings-nav { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.settings-nav h2 { margin: 0 8px 12px; font-size: 18px; letter-spacing: -.02em; }
.settings-nav button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-weight: 600; color: var(--text-2); }
.settings-nav button:hover { background: var(--bg); }
.settings-nav button.active { background: var(--blue-soft); color: var(--blue-d); }
.settings-group { margin: 16px 10px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; }
.admin-only { display: contents; }
.settings-page { overflow-y: auto; padding: 28px 32px 60px; }
.page { max-width: 760px; }
.page h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.page > p.lead { margin: 0 0 22px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card h4 { margin: 0 0 4px; font-size: 15px; }
.card > p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.form { display: grid; gap: 14px; }
.field label, .field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.input, .form input[type=text], .form input[type=email], .form input[type=password], .form input[type=url], .form select, .form textarea {
  width: 100%; font: inherit; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s; }
.form textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus, .input:focus { outline: none; border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(59, 130, 246, .12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 4px; }
.radio-row { display: flex; gap: 8px; }
.radio-row label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 500; margin: 0; background: var(--panel); }
.radio-row label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--panel); cursor: pointer; }
.color-row input[type=text] { width: 130px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.toggle input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: #cbd5e1; position: relative; cursor: pointer; transition: background .15s; margin: 0; flex-shrink: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.toggle input:checked { background: var(--blue); }
.toggle input:checked::after { transform: translateX(16px); }
.hours { display: grid; gap: 8px; margin-top: 12px; }
.hours-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 12px; }
.hours-row .times { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.hours-row input[type=time] { width: 120px; height: 36px; }
.hours-row .closed { color: var(--faint); font-size: 13px; }
.preview-box { border: 1px solid var(--line); border-radius: 14px; background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 10px, #f1f5f9 10px, #f1f5f9 20px); height: 220px; position: relative; overflow: hidden; }
.pv-bubble { position: absolute; bottom: 82px; max-width: 230px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 10px 13px; font-size: 13px; box-shadow: var(--shadow); }
.pv-launcher { position: absolute; bottom: 18px; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; box-shadow: 0 8px 20px rgba(15, 23, 42, .25); }
.pv-launcher svg { width: 24px; height: 24px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 700; padding: 0 10px 8px; }
.table td { padding: 10px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table td.actions { text-align: right; white-space: nowrap; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { display: block; }
.person small { color: var(--muted); }
.role { font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 7px; background: var(--line-2); color: var(--muted); text-transform: capitalize; }
.role.admin { background: var(--blue-soft); color: var(--blue-d); }
tr.disabled td { opacity: .55; }
.secret { display: flex; gap: 8px; }
.secret input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.codeblock { background: var(--navy); color: #bfdbfe; border-radius: 12px; padding: 14px; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; margin: 0 0 10px; position: relative; }
.list-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.list-item:first-child { border-top: 0; padding-top: 0; }
.list-item p { margin: 3px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list-item code { color: var(--blue-d); }
.notice { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.notice.ok { background: #ecfdf5; color: #047857; }
.notice.err { background: #fef2f2; color: #b91c1c; }
.notice.tip { background: var(--blue-soft); color: #1e40af; }
.once { display: flex; gap: 8px; align-items: center; }
.once input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* photos, quotes, edits, drafts, message menu */
.av { overflow: hidden; position: relative; }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.me-btn .av img { border-radius: 50%; }
.photo-row { display: flex; gap: 16px; align-items: center; }
.photo-row small { display: block; margin-top: 6px; }
.quote { display: flex; flex-direction: column; gap: 1px; max-width: 100%; padding: 6px 10px; border-left: 3px solid var(--blue); background: var(--line-2); border-radius: 8px; font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.group.op .quote { border-left-color: var(--blue-l); }
.group.note .quote { border-left-color: #f59e0b; background: #fef3c7; }
.quote b { font-size: 11.5px; color: var(--muted); }
.quote span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-wrap; }
.bubble.deleted { background: transparent !important; color: var(--faint) !important; border: 1px dashed var(--line) !important; font-style: italic; box-shadow: none !important; }
.bubble.draft { background: transparent !important; border: 1px dashed #cbd5e1 !important; color: var(--muted); font-style: italic; box-shadow: none !important; }
.drafting { color: #059669; font-weight: 600; }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(59, 130, 246, .35); } 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); } }
.ctx-menu { position: fixed; z-index: 60; min-width: 170px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; }
.ctx-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; font-size: 13.5px; }
.ctx-item:hover { background: var(--bg); }
.ctx-item.danger { color: #b91c1c; }
.ctx-item.danger:hover { background: #fef2f2; }
.composer-mode { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 6px 6px 6px 12px; margin: 0 8px; font-size: 13px; border-left: 3px solid var(--blue); }
.composer-mode > div { min-width: 0; display: flex; gap: 8px; }
.composer-mode b { flex-shrink: 0; }
.composer-mode span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-mode .icon-btn { width: 26px; height: 26px; font-size: 18px; }

/* responsive */
@media (max-width: 1279px) {
  .app { grid-template-columns: 68px 320px minmax(0, 1fr); }
  .info { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow-lg); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; }
  .chat-head { padding: 10px 10px 10px 6px; gap: 8px; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 6px 16px calc(6px + env(safe-area-inset-bottom)); }
  .rail .logo, .rail-spacer { display: none; }
  .rail-btn.active::before { display: none; }
  .menu { left: auto; right: 0; bottom: 52px; }
  .app.has-chat .rail { display: none; }
  .thread { display: none; }
  .app.has-chat .inbox { display: none; }
  .app.has-chat .thread { display: flex; }
  .back { display: grid; }
  .messages { padding: 8px 14px 14px; }
  .composer { padding: 0 10px 10px; }
  .hint { display: none; }
  .stack { max-width: 85%; }
  .info { width: 100%; }
  #toggle-status { padding: 0 10px; }
  .assign { display: none; }
  .settings { grid-column: 1; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .settings-nav h2, .settings-group { display: none; }
  .settings-nav button { white-space: nowrap; }
  .settings-page { padding: 18px 14px 40px; }
  .form-row { grid-template-columns: 1fr; }
  .hours-row { grid-template-columns: 1fr; gap: 4px; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
