:root {
    --bg: #0f1117;
    --surface: #18181b;
    --border: #27272a;
    --text: #e4e4e7;
    --muted: #71717a;
    --accent: #3b82f6;
    --green: #22c55e;
    --orange: #f59e0b;
    --red: #ef4444;
    --bubble-in: #1e293b;
    --bubble-out: #1e3a5f;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: inherit; text-decoration: none; }
.screen { height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; min-height: 56px; }
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar-user { font-size: 13px; color: var(--muted); }
.logo { font-size: 20px; margin-right: 4px; }
.filters { display: flex; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; }
.filter-btn { padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--bg); border: 1px solid var(--border); color: var(--muted); cursor: pointer; transition: all 0.15s; }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chat-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); transition: background 0.1s; cursor: pointer; }
.chat-item:active { background: rgba(59,130,246,0.06); }
.chat-item.unread { background: rgba(59,130,246,0.04); }
.chat-channel { font-size: 24px; flex-shrink: 0; width: 40px; text-align: center; }
.chat-body { flex: 1; min-width: 0; }
.chat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.chat-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.unread .chat-name { font-weight: 800; }
.chat-time { font-size: 12px; color: var(--muted); flex-shrink: 0; margin-left: 8px; }
.chat-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; min-width: 22px; height: 22px; border-radius: 11px; display: flex; align-items: center; justify-content: center; padding: 0 6px; flex-shrink: 0; }
.chat-screen { height: 100dvh; }
.chat-topbar { gap: 8px; }
.back-btn { font-size: 22px; padding: 4px 8px; flex-shrink: 0; color: var(--accent); }
.topbar-info { flex: 1; min-width: 0; }
.topbar-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.status-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.status-new { background: rgba(59,130,246,0.15); color: var(--accent); }
.status-active { background: rgba(245,158,11,0.15); color: var(--orange); }
.status-paused { background: rgba(239,68,68,0.15); color: var(--red); }
.status-closed { background: rgba(34,197,94,0.15); color: var(--green); }
.status-reopened { background: rgba(255,255,255,0.1); color: var(--text); }
.topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.action-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.action-btn.take { color: var(--orange); }
.action-btn.pause { color: var(--red); }
.action-btn.close-chat { color: var(--green); }
.action-btn:active { transform: scale(0.9); }
.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; }
.msg.in { justify-content: flex-start; }
.msg.out { justify-content: flex-end; }
.msg-bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45; word-break: break-word; }
.msg-bubble.in { background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg-bubble.out { background: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg-sender { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg.out .msg-sender { color: #60a5fa; }
.msg-text { white-space: pre-wrap; }
.msg-time { font-size: 10px; color: var(--muted); text-align: right; margin-top: 4px; }
.input-bar { padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.input-bar form { display: flex; gap: 8px; }
.input-bar input { flex: 1; padding: 10px 16px; border-radius: 24px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; outline: none; }
.input-bar input:focus { border-color: var(--accent); }
.input-bar button { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0; transition: transform 0.1s; }
.input-bar button:active { transform: scale(0.9); }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); padding: 40px; }
.empty-icon { font-size: 48px; }
.empty-text { font-size: 15px; }
.login-screen { height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-logo { font-size: 56px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.login-hint { font-size: 13px; color: var(--muted); margin-bottom: 24px; line-height: 1.5; }
.login-error { background: rgba(239,68,68,0.12); color: var(--red); padding: 10px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.login-card input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 15px; outline: none; margin-bottom: 12px; }
.login-card input:focus { border-color: var(--accent); }
.login-card button { width: 100%; padding: 14px; border-radius: 12px; border: none; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; transition: opacity 0.15s; }
.login-card button:active { opacity: 0.8; }
