:root {
    --nav-bg: #0f172a;
    --nav-border: #1e293b;
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --accent-light: #eef2ff;
    --sky: #0ea5e9;
    --sidebar-bg: #ffffff;
    --chat-bg: #f1f5f9;
    --white: #ffffff;
    --text-1: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --note-bg: #fffbeb;
    --note-border: #fcd34d;
    --note-text: #92400e;
    --success: #10b981;
    --danger: #ef4444;
    --warn: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--chat-bg);
    color: var(--text-1);
}

/* ── NAV RAIL ───────────────────────────────── */
.nav-rail {
    width: 76px;
    background: var(--nav-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 2px;
    flex-shrink: 0;
    border-right: 1px solid var(--nav-border);
}

.nav-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
}

.nav-section-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: #334155;
    text-transform: uppercase;
    padding: 10px 0 4px;
    text-align: center;
    width: 100%;
}

.nav-btn {
    width: 56px;
    height: 52px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #475569;
    background: none;
    transition: all 0.15s ease;
    position: relative;
}

.nav-btn svg {
    flex-shrink: 0;
    transition: stroke 0.15s;
}

.nav-btn span {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
}

.nav-btn.active {
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: #6366f1;
    border-radius: 0 4px 4px 0;
}

.nav-btn .badge {
    position: absolute;
    top: 7px;
    right: 7px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ef4444;
    border-radius: 8px;
    font-size: 9px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 1.5px solid var(--nav-bg);
}

.nav-divider {
    width: 32px;
    height: 1px;
    background: #1e293b;
    margin: 6px auto;
}

.nav-spacer {
    flex: 1;
}

/* ── VIEWS ──────────────────────────────────── */
.view {
    display: none;
    flex: 1;
    overflow: hidden;
}

.view.active {
    display: flex;
}

/* ── CONVERSATIONS VIEW ─────────────────────── */
#view-conversations {
    flex-direction: row;
}

/* Sidebar */
.conv-sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-head {
    padding: 18px 18px 12px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-head h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 14px;
    letter-spacing: -0.3px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.search-box:focus-within {
    background: white;
    border-color: var(--accent);
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 13px;
    color: var(--text-1);
    font-family: inherit;
}

.search-box svg {
    color: var(--text-3);
    flex-shrink: 0;
}

/* ── Sidebar Toolbar ──────────────────────────────────── */
.sidebar-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    background: var(--sidebar-bg);
}

.agent-filter-wrap { display: flex; }

.agent-filter-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-1);
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.agent-filter-btn:hover { border-color: var(--accent); color: var(--accent); }

.tb-icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-2);
    transition: all 0.15s;
}
.tb-icon-btn:hover { background: var(--border-light); color: var(--text-1); }

/* ── Assign Tab Bar (Assigned / Unassigned / Resolved) ── */
.assign-tab-bar {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    background: var(--sidebar-bg);
}

.assign-tab {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-3);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 12px 9px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
}
.assign-tab:hover { color: var(--text-1); }
.assign-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.assign-tab-resolved {
    margin-left: auto;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-3);
    transition: all 0.15s;
    flex-shrink: 0;
}
.assign-tab-resolved:hover, .assign-tab-resolved.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* Old tab-bar kept for backward compat but hidden */
.tab-bar { display: none; }

.room-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.room-item {
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 11px;
    transition: background 0.12s;
    position: relative;
    border: 1px solid transparent;
}

.room-item:hover {
    background: var(--border-light);
}

.room-item.active {
    background: var(--accent-light);
    border-color: rgba(99,102,241,0.12);
}

.room-item.bulk-selected {
    background: rgba(99,102,241,0.06);
    border-color: rgba(99,102,241,0.2);
}

/* ── Checkbox inside room-item ── */
.room-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.room-checkbox input[type="checkbox"] {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ── Bulk Action Bar (Select All + Done) ── */
.bulk-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--sidebar-bg);
    flex-shrink: 0;
}

.bulk-select-all-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    user-select: none;
}
.bulk-select-all-wrap input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bulk-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 100px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
}

.bulk-done-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: all 0.15s;
}
.bulk-select-trigger {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 6px;
    transition: background 0.12s;
}
.bulk-select-trigger:hover { background: var(--accent-light); }

/* ── Assigned badge ── */
.assigned-badge {
    font-size: 10px;
    font-weight: 500;
    color: #6366f1;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.15);
    border-radius: 100px;
    padding: 1px 7px;
}

.room-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.room-content {
    flex: 1;
    min-width: 0;
}

.room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.room-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

.room-time {
    font-size: 11px;
    color: var(--text-3);
}

.room-preview {
    font-size: 12px;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.room-site-tag {
    font-size: 10px;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.tag-chip .tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 13px;
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    display: inline-flex;
    align-items: center;
}

.tag-chip .tag-remove:hover {
    opacity: 1;
}

.tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    min-height: 22px;
}

.tag-input-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tag-input-wrap input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    outline: none;
    font-family: inherit;
    background: var(--bg, #fff);
    transition: border-color 0.15s;
}

.tag-input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}

.tag-input-wrap button {
    background: var(--accent);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.tag-input-wrap button:hover {
    background: var(--accent-d, #4f46e5);
}

.unread-badge {
    min-width: 18px;
    height: 18px;
    background: var(--accent);
    color: white;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    flex-shrink: 0;
}

.empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
}

.empty-state svg {
    margin-bottom: 8px;
    opacity: 0.4;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 14px 20px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-size: 14px;
    font-weight: 700;
}

.chat-header-sub {
    font-size: 12px;
    color: var(--text-2);
    margin-top: 1px;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bulk-select-trigger {
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-2);
}

.bulk-select-trigger.active {
    color: var(--accent);
    font-weight: 600;
}

.assign-select {
    font-size: 12px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    color: var(--text-2);
    cursor: pointer;
    outline: none;
    background: white;
}

.assign-select:hover {
    border-color: var(--accent);
}

.header-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-2);
    transition: all 0.15s;
}

.header-icon-btn:hover {
    background: var(--border-light);
    color: var(--text-1);
}

.header-icon-btn.danger:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: #fca5a5;
}

/* Messages */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chat-bg);
}

.day-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}

.day-divider::before,
.day-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.day-divider span {
    font-size: 11px;
    color: var(--text-3);
    font-weight: 600;
    white-space: nowrap;
}

.bubble-wrap {
    display: flex;
    flex-direction: column;
    max-width: 68%;
    animation: fadeSlideIn 0.2s ease-out forwards;
}

.bubble-wrap.visitor {
    align-self: flex-start;
    align-items: flex-start;
}

.bubble-wrap.admin {
    align-self: flex-end;
    align-items: flex-end;
}

.bubble-wrap.note {
    align-self: flex-end;
    align-items: flex-end;
    max-width: 80%;
}

.bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble.visitor {
    background: white;
    color: var(--text-1);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.bubble.admin {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.bubble.note {
    background: var(--note-bg);
    color: var(--note-text);
    border: 1px dashed var(--note-border);
    border-radius: 10px;
    font-size: 13px;
}

/* ── Ghost Bubble (Live Typing Preview) ── */
#typing-ghost-bubble {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 4px 12px 8px 12px;
    animation: ghostFadeIn 0.18s ease;
}

@keyframes ghostFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ghost-bubble-inner {
    max-width: 72%;
    background: #ffffff;
    border: 1.5px dashed #cbd5e1;
    border-radius: 14px 14px 14px 2px;
    padding: 8px 12px 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Row: 3 dots */
.ghost-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}
.ghost-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: ghostBounce 1.3s ease-in-out infinite;
    flex-shrink: 0;
}
.ghost-dots span:nth-child(2) { animation-delay: 0.2s; }
.ghost-dots span:nth-child(3) { animation-delay: 0.4s; }

/* When stopped typing, pause dots */
.ghost-bubble-inner.idle .ghost-dots span {
    animation-play-state: paused;
    opacity: 0.4;
}

@keyframes ghostBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-4px); opacity: 1; }
}

/* Text row */
.ghost-text {
    font-size: 13px;
    color: #475569;
    font-style: italic;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Tiny label */
.ghost-label {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 1px;
}

.bubble-meta {
    font-size: 10.5px;
    color: var(--text-3);
    margin-top: 4px;
    padding: 0 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.note-label {
    font-size: 10px;
    background: var(--note-border);
    color: var(--note-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.msg-img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    display: block;
    margin-top: 4px;
    object-fit: cover;
}

.msg-file-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    font-weight: 600;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 4px;
}

.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    gap: 8px;
}

.empty-chat svg {
    opacity: 0.3;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    animation: fadeSlideIn 0.2s ease;
}

.typing-bubble-wrap {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
}

.typing-bubble-inner {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.t-dot {
    width: 7px;
    height: 7px;
    background: var(--text-3);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.t-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.t-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 4px;
    padding-left: 2px;
}

.system-event {
    text-align: center;
    font-size: 11px;
    color: var(--text-3);
    padding: 4px 0;
    font-style: italic;
}

/* Footer */
.chat-footer {
    padding: 14px 20px;
    background: white;
    border-top: 1px solid var(--border);
    position: relative;
}

.canned-panel {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 20px;
    right: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
}

.canned-panel.open {
    display: flex;
}

.canned-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border-light);
}

.canned-item:last-child {
    border-bottom: none;
}

.canned-item:hover {
    background: var(--accent-light);
}

.canned-item .canned-shortcut {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
}

.canned-item .canned-msg {
    font-size: 13px;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.footer-mode-toggle {
    display: flex;
    margin-bottom: 10px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-2);
    transition: all 0.15s;
}

.mode-btn.active-reply {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.mode-btn.active-note {
    background: var(--note-bg);
    color: var(--note-text);
    border-color: var(--note-border);
}

.input-wrapper-adm {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--border-light);
    border: 1.5px solid transparent;
    border-radius: 24px;
    padding: 5px 6px 5px 14px;
    transition: all 0.2s;
}

.input-wrapper-adm:focus-within {
    background: white;
    border-color: var(--accent);
}

.input-wrapper-adm.note-mode {
    border-color: var(--note-border);
    background: var(--note-bg);
}

.input-wrapper-adm textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    height: 22px;
    max-height: 100px;
    line-height: 22px;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    color: var(--text-1);
}

.adm-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.adm-action-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.send-adm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    transition: all 0.15s;
}

.send-adm:hover {
    background: var(--accent-dark);
    transform: scale(1.05);
}

.send-adm.note-send {
    background: var(--warn);
}

.emoji-panel-adm {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: none;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    min-width: 260px;
}

.emoji-panel-adm.open {
    display: grid;
}

.emoji-item {
    font-size: 20px;
    cursor: pointer;
    text-align: center;
    padding: 4px;
    border-radius: 6px;
}

.emoji-item:hover {
    background: var(--border-light);
}

/* Info Panel */
.info-panel {
    width: 280px;
    background: white;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.info-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
}

.info-section:last-child {
    border-bottom: none;
}

.info-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-visitor-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.info-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.info-name {
    font-size: 14px;
    font-weight: 700;
}

.info-site-badge {
    font-size: 10px;
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-bottom: 8px;
}

.info-label {
    font-size: 10px;
    color: var(--text-3);
    font-weight: 500;
}

.info-value {
    font-size: 12.5px;
    color: var(--text-1);
    font-weight: 500;
    word-break: break-all;
}

.info-value a {
    color: var(--accent);
    text-decoration: none;
}

.info-value a:hover {
    text-decoration: underline;
}

.info-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.stat-card {
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 6px;
    text-align: center;
}

.stat-card .stat-val {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
}

.stat-card .stat-lbl {
    font-size: 9px;
    color: var(--text-3);
    font-weight: 500;
}

.info-empty {
    color: var(--text-3);
    font-size: 13px;
    text-align: center;
    padding: 16px 0;
}

/* ── SITES VIEW ──────────────────────────────── */
#view-sites {
    flex-direction: column;
    background: var(--white);
}

#view-kb,
#view-canned,
#view-settings {
    flex-direction: column;
    background: var(--white);
}

.content-header {
    padding: 24px 32px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.content-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.content-header p {
    font-size: 13px;
    color: var(--text-2);
    margin-top: 4px;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--border-light);
    color: var(--text-1);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fca5a5;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* Sites table */
.sites-grid {
    display: grid;
    gap: 12px;
}

.site-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.15s;
    box-shadow: var(--shadow);
}

.site-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.site-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.site-info {
    flex: 1;
    min-width: 0;
}

.site-name {
    font-size: 14px;
    font-weight: 700;
}

.site-domain {
    font-size: 12px;
    color: var(--text-2);
    margin-top: 2px;
}

.api-key-block {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    margin-top: 8px;
}

.api-key-text {
    font-size: 12px;
    font-family: 'Courier New', monospace;
    color: var(--text-2);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.key-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.key-action-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.site-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.badge-active {
    background: #dcfce7;
    color: #166534;
}

.badge-inactive {
    background: #f1f5f9;
    color: var(--text-3);
}

.site-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.site-date {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 6px;
}

/* KB & Canned */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
    vertical-align: top;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--border-light);
}

.category-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 6px;
    display: inline-flex;
}

.shortcut-tag {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    background: #f0fdf4;
    color: #166534;
    border-radius: 6px;
    display: inline-flex;
    font-family: monospace;
}

.form-card {
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.form-card h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 160px;
}

.form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-1);
    background: white;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Stats Cards */
.stats-bar {
    display: flex;
    gap: 12px;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: white;
    flex-shrink: 0;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    flex: 1;
}

.stat-chip-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-chip-val {
    font-size: 18px;
    font-weight: 600;
}

.stat-chip-lbl {
    font-size: 11px;
    color: var(--text-2);
}

/* Script Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 0.2s ease;
    overflow: hidden;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--border-light);
    color: var(--text-1);
}

.modal-body {
    padding: 24px;
}

.script-block {
    background: #0f172a;
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12.5px;
    color: #94a3b8;
    line-height: 1.7;
    white-space: pre;
    overflow-x: auto;
}

.script-block .kw {
    color: #c084fc;
}

.script-block .str {
    color: #86efac;
}

.script-block .tag {
    color: #67e8f9;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Custom Resolve Modal ─────────────────────────────── */
.resolve-modal-box {
    max-width: 360px;
    text-align: center;
    padding: 36px 32px 28px;
}

.resolve-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.30);
}

.resolve-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 10px;
    letter-spacing: -0.2px;
}

.resolve-modal-desc {
    font-size: 13.5px;
    color: var(--text-2);
    line-height: 1.65;
    margin-bottom: 28px;
}

.resolve-modal-desc strong {
    color: #10b981;
    font-weight: 600;
}

.resolve-modal-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.resolve-btn-confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.resolve-btn-confirm:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}
.resolve-btn-confirm:active { transform: translateY(0); }

.resolve-btn-cancel {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 13px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: color 0.15s;
}
.resolve-btn-cancel:hover { color: var(--text-1); }

/* Bulk resolve — shows count in modal */
.resolve-bulk-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16,185,129,0.08);
    border: 1px solid rgba(16,185,129,0.2);
    color: #065f46;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 100px;
    margin-bottom: 12px;
}

.copy-success {
    color: var(--success);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Add site form in modal */
.add-site-modal .modal-box {
    max-width: 440px;
}

/* Settings */
.settings-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.settings-card h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 14px;
}

/* Misc */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text-1);
    color: white;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 320px;
    animation: fadeSlideIn 0.25s ease;
}

.toast.success {
    background: #059669;
}

.toast.warning {
    background: #d97706;
}

.toast.error {
    background: #dc2626;
}

.toast.info {
    background: #6366f1;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Inline validation */
.field-error {
    color: #ef4444;
    font-size: 11px;
    margin-top: 2px;
    display: none;
    font-weight: 500;
}

.field-error.show {
    display: block;
}

.form-input.has-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Canned keyboard nav */
.canned-item.selected {
    background: var(--accent-light);
}

/* Canned header */
.canned-header {
    padding: 7px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
}

/* Visitor tags */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-light);
    color: var(--accent);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.tag-chip .tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 10px;
}

.tag-chip .tag-remove:hover {
    opacity: 1;
}

.tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tag-input-wrap {
    display: flex;
    gap: 6px;
}

.tag-input-wrap input {
    flex: 1;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    font-family: inherit;
}

.tag-input-wrap input:focus {
    border-color: var(--accent);
}

.tag-input-wrap button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}

/* Visited pages list */
.page-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}

.page-item:last-child {
    border-bottom: none;
}

.page-url {
    font-size: 11.5px;
    color: var(--accent);
    word-break: break-all;
}

.page-title {
    font-size: 11px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-time {
    font-size: 10px;
    color: var(--text-3);
    margin-top: 1px;
}

/* Info row inline */
.info-row-inline {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    gap: 8px;
}

.info-row-inline .info-label {
    font-size: 11.5px;
    color: var(--text-3);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 72px;
}

.info-row-inline .info-value {
    font-size: 12px;
    color: var(--text-1);
    font-weight: 500;
    text-align: right;
    word-break: break-all;
    flex: 1;
}

/* Duration badge */
.duration-live {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #dcfce7;
    color: #166534;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

.duration-live::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .4
    }
}

/* Form fields builder */
.ff-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
}

.ff-row .ff-label {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}

.ff-row .ff-key {
    font-size: 11px;
    color: var(--text-3);
    font-family: monospace;
}

.ff-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
}

.ff-toggle input[type=checkbox] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ── Analytics Stats Cards ─────────────────────────────── */
.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.2s, transform 0.2s;
}

.stats-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.stats-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.stats-value {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-1);
    letter-spacing: -1px;
    line-height: 1;
}

.stats-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.stats-sub {
    font-size: 11px;
    color: var(--text-3);
}

/* ── Assign Filter Buttons ──────────────────────────────── */
.assign-filter-btn.active {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
}

/* ── Agent Status Pulse ─────────────────────────────────── */
@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

