/* ============================================================
   RCG Live Chat — Agent Dashboard
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
    /* ── Brand (RCG) ─────────────────────────── */
    --blue:          #2A206F;  /* RCG Navy */
    --blue-dark:     #221A5C;
    --blue-deeper:   #1A1548;
    --blue-light:    #EEEDF8;
    --blue-muted:    rgba(42,32,111,.09);
    --blue-glow:     rgba(42,32,111,.22);
    --rcg-steel:     #6498BE;  /* RCG Steel Blue */
    --rcg-mauve:     #B079AD;  /* RCG Mauve */

    /* ── Ranks ──────────────────────────────────── */
    --rank-super:    #B079AD;
    --rank-admin:    #2A206F;
    --rank-super-bg: #F5F0F5;
    --rank-admin-bg: #EEEDF8;
    --rank-sup:      #ea580c;
    --rank-sup-bg:   #fff7ed;
    --rank-senior:   #0891b2;
    --rank-senior-bg:#ecfeff;
    --rank-agent:    #059669;
    --rank-agent-bg: #ecfdf5;

    /* ── Layout ──────────────────────────────────── */
    --icon-rail:     60px;
    --folder-w:      220px;
    --list-w:        290px;
    --info-w:        280px;

    /* ── Surfaces ────────────────────────────────── */
    --sidebar:       #2A206F;  /* RCG Navy */
    --sidebar-hover: rgba(255,255,255,.08);
    --sidebar-active:rgba(100,152,190,.22);  /* Steel Blue highlight */
    --sidebar-border:rgba(255,255,255,.08);
    --bg:            #F1F5F9;
    --surface:       #FFFFFF;
    --surface-2:     #F8FAFC;
    --surface-hover: #F1F5F9;

    /* ── Text ─────────────────────────────────────── */
    --text:          #0F172A;
    --text-2:        #1E293B;
    --text-muted:    #64748B;
    --text-light:    #94A3B8;
    --text-inv:      #FFFFFF;

    /* ── Border ───────────────────────────────────── */
    --border:        #E2E8F0;
    --border-2:      #CBD5E1;

    /* ── Status ───────────────────────────────────── */
    --online:        #22C55E;
    --away:          #F59E0B;
    --offline:       #94A3B8;

    /* ── Shadows ──────────────────────────────────── */
    --shadow-xs:     0 1px 2px rgba(0,0,0,.04);
    --shadow-sm:     0 1px 4px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.03);
    --shadow-md:     0 4px 16px rgba(0,0,0,.08),0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:     0 10px 36px rgba(0,0,0,.10),0 4px 8px rgba(0,0,0,.04);
    --shadow-xl:     0 24px 64px rgba(0,0,0,.12),0 8px 16px rgba(0,0,0,.05);

    /* ── Radius ───────────────────────────────────── */
    --r-xs:  3px;
    --r-sm:  6px;
    --r-md:  8px;
    --r-lg:  12px;
    --r-xl:  16px;
    --r-pill:999px;

    /* ── Transitions ──────────────────────────────── */
    --ease:         cubic-bezier(.4,0,.2,1);
    --ease-spring:  cubic-bezier(.34,1.56,.64,1);
}

html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ════════════════════════════════════════════════════════════
   LOGIN  (Tidio-style: white card on soft blue gradient)
   ════════════════════════════════════════════════════════════ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #EEEDF8 0%, #E0DDF5 40%, #EEE5EF 100%);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-screen::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    top: -200px; right: -100px;
    background: radial-gradient(circle, rgba(42,32,111,.13), transparent 70%);
    pointer-events: none;
}
.login-screen::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    bottom: -100px; left: -100px;
    background: radial-gradient(circle, rgba(176,121,173,.12), transparent 70%);
    pointer-events: none;
}

.login-card {
    position: relative;
    z-index: 1;
    background: #fff;
    border: 1px solid rgba(42,32,111,.12);
    border-radius: 20px;
    padding: 44px 40px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 80px rgba(42,32,111,.14), 0 6px 16px rgba(0,0,0,.06);
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px; height: 72px;
    background: #fff;
    border-radius: 18px;
    margin-bottom: 14px;
    box-shadow: 0 4px 18px rgba(0,0,0,.10);
    padding: 6px;
    border: 1px solid var(--border);
}
.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.03em;
    margin-bottom: 4px;
}
.login-brand p {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: .02em;
}

.login-card .form-group { margin-bottom: 14px; }
.login-card .form-label {
    display: block;
    font-size: .73rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.login-card .form-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: .875rem;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .2s var(--ease), box-shadow .2s;
}
.login-card .form-input::placeholder { color: var(--text-light); }
.login-card .form-input:focus {
    border-color: var(--blue);
    background: #fff;
    box-shadow: 0 0 0 3px var(--blue-muted);
}
.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--r-md);
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, transform .1s, box-shadow .15s;
    box-shadow: 0 2px 10px var(--blue-glow);
    margin-top: 6px;
}
.btn-login:hover  { background: var(--blue-dark); box-shadow: 0 4px 18px var(--blue-glow); }
.btn-login:active { transform: scale(.99); }
.btn-login:disabled { opacity:.5; cursor:not-allowed; }
.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--r-sm);
    padding: 10px 14px;
    color: #dc2626;
    font-size: .8rem;
    margin-top: 12px;
}

/* ════════════════════════════════════════════════════════════
   APP LAYOUT
   ════════════════════════════════════════════════════════════ */
.app-layout {
    display: grid;
    height: 100vh;
    overflow: hidden;
}
.app-layout.app-inbox {
    grid-template-columns: var(--icon-rail) var(--folder-w) var(--list-w) 1fr;
}
.app-layout.app-admin {
    grid-template-columns: var(--icon-rail) 1fr;
}

/* ════════════════════════════════════════════════════════════
   ICON RAIL (left narrow sidebar)
   ════════════════════════════════════════════════════════════ */
.icon-rail {
    background: linear-gradient(175deg, #19243a 0%, #1B2537 55%, #192233 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 12px;
    gap: 2px;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 2px 0 16px rgba(0,0,0,.12);
    z-index: 10;
    position: relative;
}

.icon-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 0 12px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 6px;
    width: 100%;
    flex-shrink: 0;
}

.icon-btn {
    position: relative;
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: rgba(255,255,255,.40);
    transition: background .15s var(--ease), color .15s;
    flex-shrink: 0;
    font-family: inherit;
}
.icon-btn:hover  { background: var(--sidebar-hover); color: rgba(255,255,255,.85); }
.icon-btn.active {
    background: rgba(100,152,190,.28);
    color: #a8cbdf;
}
.icon-btn .ib-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: #EF4444;
    color: #fff;
    font-size: .52rem;
    font-weight: 800;
    min-width: 15px; height: 15px;
    border-radius: 8px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1B2537;
    line-height: 1;
}

.icon-sep {
    width: 28px;
    height: 1px;
    background: var(--sidebar-border);
    margin: 6px 0;
    flex-shrink: 0;
}

.icon-spacer { flex: 1; }

/* ════════════════════════════════════════════════════════════
   FOLDER TREE PANEL
   ════════════════════════════════════════════════════════════ */
.folder-panel {
    background: #FAFBFC;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 12px;
}
.folder-panel::-webkit-scrollbar { width: 3px; }
.folder-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.folder-panel-head {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.folder-panel-title {
    font-size: .9rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.02em;
    margin-bottom: 8px;
}
.folder-search-wrap { position: relative; }
.folder-search-icon {
    position: absolute;
    left: 9px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
    font-size: .8rem;
}
.folder-search-input {
    width: 100%;
    padding: 7px 10px 7px 28px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-pill);
    font-size: .8rem;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
}
.folder-search-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-muted);
}
.folder-search-input::placeholder { color: var(--text-light); }

.folder-wa-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    margin-top: 7px;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: var(--r-pill);
    font-size: .73rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    width: 100%;
    justify-content: center;
}
.folder-wa-btn:hover { background: #1ebe57; }

.folder-section {
    padding: 14px 10px 2px;
}
.folder-section-label {
    font-size: .58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-light);
    padding: 0 6px 6px;
}
.folder-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--text-2);
    font-size: .82rem;
    font-weight: 500;
    transition: background .1s, color .1s;
    border: none;
    background: transparent;
    width: 100%;
    font-family: inherit;
    text-align: left;
}
.folder-item:hover { background: var(--surface-hover); color: var(--text); }
.folder-item.active {
    background: var(--blue-muted);
    color: var(--blue);
    font-weight: 600;
}
.folder-item-icon { font-size: .95rem; flex-shrink: 0; width: 18px; text-align: center; }
.folder-item-label { flex: 1; }
.folder-item-count {
    font-size: .67rem;
    font-weight: 700;
    color: var(--text-light);
    background: var(--surface-hover);
    border-radius: var(--r-pill);
    padding: 1px 6px;
    flex-shrink: 0;
}
.folder-item.active .folder-item-count {
    background: rgba(42,32,111,.13);
    color: var(--blue);
}
.folder-item-new {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-light);
    padding: 0 4px;
    border-radius: 4px;
    line-height: 1.4;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s;
}
.folder-item:hover .folder-item-new { opacity: 1; }
.folder-item-new:hover { background: var(--border); color: var(--text); }

.nav-spacer { flex: 1; }

/* Agent avatar at bottom of icon-rail */
.nav-agent {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0 0;
    border-top: 1px solid var(--sidebar-border);
    margin-top: 4px;
    width: 100%;
}
.nav-agent-name { display: none; }
.nav-agent-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: border-color .2s, transform .15s;
    background-clip: padding-box;
}
.nav-agent-avatar:hover { transform: scale(1.06); }
.nav-agent-avatar.ring-online  { border-color: var(--online); }
.nav-agent-avatar.ring-away    { border-color: var(--away); }
.nav-agent-avatar.ring-offline { border-color: rgba(255,255,255,.12); }
.nav-status-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    border: 2px solid var(--sidebar);
    position: absolute;
    bottom: -1px; right: -1px;
}
.nav-status-dot.online  { background: var(--online); }
.nav-status-dot.away    { background: var(--away); }
.nav-status-dot.offline { background: var(--offline); }

/* Status dropdown */
.status-dropdown {
    position: absolute;
    bottom: 52px;
    left: 10px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 180px;
    overflow: hidden;
    z-index: 200;
    animation: popIn .15s var(--ease-spring);
}
@keyframes popIn { from { transform:scale(.92); opacity:0; } to { transform:scale(1); opacity:1; } }

.status-dropdown-header {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border);
}
.status-dropdown-name  { font-weight: 700; font-size: .84rem; }
.status-dropdown-email { font-size: .71rem; color: var(--text-muted); }

.status-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .84rem;
    font-weight: 500;
    transition: background .1s;
    color: var(--text-2);
}
.status-item:hover { background: var(--surface-hover); }
.status-item.divider { border-top: 1px solid var(--border); color: var(--text-muted); }
.status-item.divider:hover { color: #EF4444; }
.sdot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sdot.online  { background: var(--online); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.sdot.away    { background: var(--away);   box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.sdot.offline { background: var(--offline); }

/* ════════════════════════════════════════════════════════════
   CONVERSATION LIST
   ════════════════════════════════════════════════════════════ */
.conv-list-panel {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 1px 0 6px rgba(0,0,0,.04);
    z-index: 4;
}

.conv-list-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.conv-list-title { display: none; }
.conv-list-title-text { font-size: .84rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }

.btn-wa-new {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    margin-top: 6px;
    background: #25d366;
    color: #fff;
    border: none;
    border-radius: var(--r-pill);
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-wa-new:hover { background: #1ebe57; }

.search-wrap { position: relative; }
.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
    font-size: .85rem;
}
.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--r-pill);
    font-size: .82rem;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .2s, background .2s, box-shadow .2s;
}
.search-input:focus {
    border-color: var(--blue);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--blue-muted);
}
.search-input::placeholder { color: var(--text-light); }

/* Filter tabs */
.filter-scroll {
    padding: 8px 12px 0;
    overflow-x: auto;
    display: flex;
    gap: 4px;
    scrollbar-width: none;
    flex-shrink: 0;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-tab {
    padding: 4px 11px;
    border-radius: var(--r-pill);
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all .15s var(--ease);
    flex-shrink: 0;
}
.filter-tab:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-muted); }
.filter-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 6px var(--blue-glow); }

/* List */
.conv-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.conv-list::-webkit-scrollbar { width: 3px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.conv-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.conv-empty-icon { font-size: 2.2rem; margin-bottom: 10px; opacity: .35; }
.conv-empty-text { font-size: .84rem; }

.conv-item {
    padding: 11px 14px;
    cursor: pointer;
    transition: background .1s;
    border-left: 3px solid transparent;
    position: relative;
}
.conv-item:hover { background: var(--surface-hover); }
.conv-item.active {
    background: var(--blue-light);
    border-left-color: var(--blue);
}

.conv-item-row1 {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 4px;
}
.conv-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .78rem;
    color: #fff;
    position: relative;
}
.conv-avatar-wa::after {
    content: '📱';
    position: absolute;
    bottom: -3px; right: -3px;
    font-size: .6rem;
    background: #fff;
    border-radius: 50%;
    line-height: 1;
    padding: 1px;
}

.conv-meta { flex: 1; min-width: 0; }
.conv-name-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 2px;
}
.conv-name {
    font-size: .83rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-time { font-size: .68rem; color: var(--text-light); flex-shrink: 0; }

.conv-preview-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.conv-preview {
    font-size: .77rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.conv-item.unread .conv-name { font-weight: 700; }
.conv-item.unread .conv-preview { color: var(--text-2); font-weight: 500; }

.unread-badge {
    min-width: 17px; height: 17px;
    background: var(--blue);
    color: #fff;
    border-radius: 9px;
    font-size: .62rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    flex-shrink: 0;
}

.dept-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: var(--r-pill);
    font-size: .65rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   CHAT PANEL
   ════════════════════════════════════════════════════════════ */
.chat-panel {
    display: flex;
    overflow: hidden;
    background: var(--bg);
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 48px 32px 32px;
    gap: 0;
    color: var(--text-muted);
    user-select: none;
    overflow-y: auto;
}
.chat-empty-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(42,32,111,.25);
}
.chat-empty h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    text-align: center;
}
.chat-empty p  {
    font-size: .82rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 280px;
    line-height: 1.5;
    margin-bottom: 28px;
}

/* Integration prompt cards */
.integration-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 340px;
}
.integration-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s;
}
.integration-card:hover { box-shadow: var(--shadow-sm); }
.integration-card-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}
.integration-card-text { flex: 1; }
.integration-card-title {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1px;
}
.integration-card-sub {
    font-size: .73rem;
    color: var(--text-muted);
}
.integration-card-badge {
    font-size: .65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    flex-shrink: 0;
}
.badge-integrated { background: #dcfce7; color: #15803d; }
.badge-installed   { background: #E0DDF5; color: #2A206F; }

/* Chat inner */
.chat-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Chat header */
.chat-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    box-shadow: 0 1px 8px rgba(0,0,0,.05);
    z-index: 5;
}
.chat-contact-ava {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}
.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.wa-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #dcfce7;
    color: #16a34a;
    font-size: .63rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--r-pill);
}
.chat-contact-sub { font-size: .73rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-header-actions { display: flex; gap: 5px; align-items: center; }
.hdr-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: var(--r-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
    white-space: nowrap;
}
.hdr-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-muted); }
.hdr-btn.success { background: #ecfdf5; border-color: #6ee7b7; color: #059669; }
.hdr-btn.success:hover { background: #d1fae5; border-color: #34d399; }
.hdr-btn.danger { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }
.hdr-btn.danger:hover { background: #fee2e2; border-color: #f87171; }
.hdr-btn.take-btn { background: #EEEDF8; border-color: #6498BE; color: #2A206F; font-weight: 700; }
.hdr-btn.take-btn:hover { background: #E0DDF5; border-color: #6498BE; }

.wa-window-banner {
    padding: 10px 18px;
    background: #fff7ed;
    border-top: 1px solid #fed7aa;
    color: #9a3412;
    font-size: .78rem;
    font-weight: 500;
    flex-shrink: 0;
    line-height: 1.4;
}

.take-banner {
    padding: 12px 18px;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    color: #92400e;
    font-size: .82rem;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.status-chip {
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
}
.chip-open   { background: #E0DDF5; color: #2A206F; }
.chip-closed { background: #f1f5f9; color: #64748b; }
.chip-pending{ background: #fef3c7; color: #d97706; }

/* Messages */
.messages-pane {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #F0F4F8;
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23e2e8f0' fill-opacity='0.5'%3E%3Ccircle cx='1' cy='1' r='1'/%3E%3C/g%3E%3C/svg%3E");
}
.messages-pane::-webkit-scrollbar { width: 4px; }
.messages-pane::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* Date separator */
.date-sep {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 8px;
    color: var(--text-light);
    font-size: .68rem;
    font-weight: 600;
    user-select: none;
}
.date-sep::before, .date-sep::after { content:''; flex:1; height:1px; background:var(--border); }

/* Message rows */
.msg-row { display: flex; flex-direction: column; margin-bottom: 2px; }
.msg-row.agent     { align-items: flex-end; }
.msg-row.visitor   { align-items: flex-start; }
.msg-row.bot       { align-items: flex-start; }
.msg-row.system    { align-items: center; margin: 8px 0; }
.msg-row.note      { align-items: flex-end; }
.msg-row.group-start { margin-top: 10px; }

.msg-from {
    font-size: .66rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 3px;
    padding: 0 3px;
    letter-spacing: .02em;
}
.msg-row.agent .msg-from { text-align: right; }

.msg-bubble {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: .875rem;
    line-height: 1.57;
    word-break: break-word;
    position: relative;
}
.msg-row.agent .msg-bubble {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 10px var(--blue-glow);
}
.msg-row.visitor .msg-bubble {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.msg-row.bot .msg-bubble {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #bbf7d0;
    color: #15803d;
    border-bottom-left-radius: 4px;
}
.msg-row.system .msg-bubble {
    background: rgba(255,255,255,.7);
    color: var(--text-light);
    font-size: .71rem;
    font-style: italic;
    padding: 4px 14px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    backdrop-filter: blur(4px);
}
.msg-row.note .msg-bubble {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1.5px dashed #fcd34d;
    color: #92400e;
    border-bottom-right-radius: 4px;
}

.msg-foot {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    padding: 0 3px;
}
.msg-row.agent .msg-foot { justify-content: flex-end; }
.msg-time-txt { font-size: .64rem; color: var(--text-light); }
.msg-read     { font-size: .66rem; color: #93C5FD; }

/* Media */
.msg-img { max-width: 220px; border-radius: var(--r-md); cursor: zoom-in; display: block; box-shadow: var(--shadow-sm); }
.msg-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px;
    text-decoration: none;
    color: inherit;
    font-size: .82rem;
    font-weight: 500;
}
.msg-file:hover { text-decoration: underline; }
.msg-file-icon { font-size: 1.1rem; }

/* Typing */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 3px;
    padding: 10px 14px;
    width: fit-content;
    margin-top: 8px;
    box-shadow: var(--shadow-xs);
}
.t-dot { width: 7px; height: 7px; background: var(--text-light); border-radius: 50%; animation: tdot 1.3s ease-in-out infinite; }
.t-dot:nth-child(2) { animation-delay: .2s; }
.t-dot:nth-child(3) { animation-delay: .4s; }
@keyframes tdot {
    0%,80%,100% { transform:translateY(0); opacity:.4; }
    40%         { transform:translateY(-5px); opacity:1; }
}

/* Input area */
.input-area {
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,.04);
}

.canned-pop {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.canned-pop-item {
    padding: 9px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.canned-pop-item:hover { background: var(--blue-muted); }
.canned-pop-item:last-child { border-bottom: none; }
.canned-sc  { font-size: .68rem; font-weight: 800; color: var(--blue); text-transform: uppercase; letter-spacing: .04em; }
.canned-ttl { font-size: .82rem; font-weight: 600; color: var(--text); margin: 1px 0; }
.canned-prv { font-size: .74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.input-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px 4px;
    border-bottom: 1px solid var(--border);
}
.tb-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: var(--r-sm);
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: .71rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}
.tb-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-muted); }
.tb-btn.on    { background: #fef3c7; border-color: #fcd34d; color: #92400e; }

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px 12px;
}
.agent-input {
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px 13px;
    font-size: .875rem;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface-2);
    transition: border-color .2s, background .2s, box-shadow .2s;
}
.agent-input:focus {
    border-color: var(--blue);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--blue-muted);
}
.agent-input::placeholder { color: var(--text-light); }
.agent-input.note-mode {
    background: #fffbeb;
    border-color: #fcd34d;
}
.agent-input.note-mode:focus { box-shadow: 0 0 0 3px rgba(252,211,77,.2); border-color: #f59e0b; }

.send-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .15s var(--ease-spring), box-shadow .15s, opacity .2s;
    box-shadow: 0 3px 10px var(--blue-glow);
}
.send-btn:hover  { background: linear-gradient(135deg, var(--blue-dark), var(--blue-deeper)); transform: scale(1.08); box-shadow: 0 4px 16px var(--blue-glow); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }

.closed-notice {
    padding: 12px 16px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    font-size: .82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   INFO SIDEBAR
   ════════════════════════════════════════════════════════════ */
.info-sidebar {
    width: var(--info-w);
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.info-sidebar::-webkit-scrollbar { width: 3px; }
.info-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.info-contact-card {
    padding: 22px 16px 18px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    background: linear-gradient(160deg, #EEEDF8 0%, #E0DDF5 40%, var(--surface) 80%);
}
.info-ava {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
    margin: 0 auto 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,.10);
}
.info-name  { font-size: .9rem; font-weight: 700; color: var(--text); }
.info-email { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }

.info-section { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.info-section:last-child { border-bottom: none; }
.info-section-hd {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-light);
    margin-bottom: 10px;
}
.info-kv { margin-bottom: 8px; }
.info-k { font-size: .69rem; color: var(--text-muted); margin-bottom: 2px; font-weight: 500; }
.info-v { font-size: .82rem; color: var(--text-2); word-break: break-word; }
.info-v a { color: var(--blue); text-decoration: none; }
.info-v a:hover { text-decoration: underline; }
.contact-fields { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.contact-field { display: flex; flex-direction: column; gap: 3px; }
.contact-field-label {
    font-size: .67rem; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--text-3);
}
.contact-save-btn {
    width: 100%; margin-top: 4px; font-size: .78rem;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.contact-save-spinner {
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
    animation: spin .6s linear infinite; flex-shrink: 0;
}

.info-edit-input {
    width: 100%; box-sizing: border-box;
    border: 1.5px solid var(--border); border-radius: 6px;
    padding: 6px 9px; font-size: .8rem; color: var(--text-1);
    background: var(--bg-1); outline: none;
    transition: border-color .15s;
}
.info-edit-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 15%, transparent); }

.info-select {
    width: 100%;
    padding: 8px 11px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .82rem;
    color: var(--text);
    background: var(--surface-2);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    margin-top: 5px;
    transition: border-color .2s;
}
.info-select:focus { border-color: var(--blue); }

.tags-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag-chip {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: var(--blue-muted);
    color: var(--blue);
    border-radius: var(--r-pill);
    font-size: .68rem;
    font-weight: 700;
}
.tag-rm { cursor: pointer; opacity: .6; font-size: .6rem; transition: opacity .1s; }
.tag-rm:hover { opacity: 1; }
.tag-add-input {
    border: 1.5px dashed var(--border);
    border-radius: var(--r-pill);
    padding: 3px 9px;
    font-size: .71rem;
    outline: none;
    color: var(--text-2);
    background: transparent;
    font-family: inherit;
    width: 80px;
    transition: border-color .2s;
}
.tag-add-input:focus { border-color: var(--blue); }

/* History */
.hist-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: padding-left .15s;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { padding-left: 4px; color: var(--blue); }
.hist-date { font-size: .67rem; color: var(--text-muted); margin-bottom: 2px; }
.hist-prev { font-size: .77rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ════════════════════════════════════════════════════════════
   ADMIN / SETTINGS PANELS
   ════════════════════════════════════════════════════════════ */
.admin-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 28px 36px;
    grid-column: 2 / -1;
    background: var(--bg);
}
.admin-wrap::-webkit-scrollbar { width: 4px; }
.admin-wrap::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
}
.page-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.04em;
}
.page-sub { font-size: .79rem; color: var(--text-muted); margin-top: 3px; font-weight: 400; }

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
    overflow: hidden;
    margin-bottom: 18px;
}
.card-hd {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    background: linear-gradient(to bottom, var(--surface), var(--surface-2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    letter-spacing: -.01em;
    box-shadow: inset 3px 0 0 var(--blue);
}

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 10px 18px;
    text-align: left;
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
.data-table td {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    font-size: .84rem;
    vertical-align: middle;
    transition: background .1s;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) td { background: rgba(241,245,249,.5); }
.data-table tbody tr:hover td { background: var(--blue-light) !important; }

/* Rank badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}
.rank-super_admin { background: #F5F0F5; color: #B079AD; border: 1px solid #DFC4DC; }
.rank-admin       { background: var(--blue-light); color: var(--blue-dark); border: 1px solid #C5C0E0; }
.rank-supervisor  { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.rank-senior_agent{ background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }
.rank-agent       { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

.rank-icon { font-size: .74rem; }

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: .71rem;
    font-weight: 700;
}
.status-online  { background: #dcfce7; color: #166534; }
.status-away    { background: #fef9c3; color: #854d0e; }
.status-offline { background: #f1f5f9; color: #475569; }
.status-open    { background: #E0DDF5; color: #2A206F; }
.status-closed  { background: #f1f5f9; color: #475569; }
.status-pending { background: #fef3c7; color: #92400e; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 20px 18px 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
    position: relative;
    overflow: hidden;
    transition: transform .15s var(--ease), box-shadow .15s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.08);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--blue), var(--blue-dark));
}
/* Individual stat card accent colors */
.stats-grid .stat-card:nth-child(1)::before { background: linear-gradient(90deg, #6498BE, #2A206F); }
.stats-grid .stat-card:nth-child(2)::before { background: linear-gradient(90deg, #4ADE80, #22C55E); }
.stats-grid .stat-card:nth-child(3)::before { background: linear-gradient(90deg, #94A3B8, #64748B); }
.stats-grid .stat-card:nth-child(4)::before { background: linear-gradient(90deg, #FBBF24, #F59E0B); }
.stats-grid .stat-card:nth-child(5)::before { background: linear-gradient(90deg, #C084FC, #8B5CF6); }
.stats-grid .stat-card:nth-child(6)::before { background: linear-gradient(90deg, #4ADE80, #25D366); }
.stat-icon {
    font-size: 1.3rem;
    margin-bottom: 10px;
    display: block;
    opacity: .85;
}
.stat-val  { font-size: 2.1rem; font-weight: 900; color: var(--text); line-height: 1; letter-spacing: -.05em; }
.stat-lbl  { font-size: .71rem; color: var(--text-muted); margin-top: 5px; font-weight: 500; letter-spacing: .01em; }

/* Form elements */
.f-group { margin-bottom: 18px; }
.f-group:last-child { margin-bottom: 0; }
.f-label {
    display: block;
    font-size: .71rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: .01em;
    text-transform: uppercase;
}
.f-hint { font-size: .7rem; color: var(--text-light); margin-top: 5px; line-height: 1.5; }
.f-input, .f-select, .f-textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: .875rem;
    color: var(--text);
    font-family: inherit;
    outline: none;
    background: var(--surface-2);
    transition: border-color .2s, background .2s, box-shadow .2s;
}
.f-input:focus, .f-select:focus, .f-textarea:focus {
    border-color: var(--blue);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--blue-muted);
}
.f-input::placeholder, .f-textarea::placeholder { color: var(--text-light); }
.f-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.f-color { width: 44px; height: 40px; padding: 3px; cursor: pointer; border-radius: var(--r-sm); border: 1.5px solid var(--border); }
.f-color-row { display: flex; gap: 10px; align-items: center; }
/* Override uppercase in modals — too aggressive for label+hint combos */
.modal-body .f-label, .canned-pop .f-label {
    text-transform: none;
    font-size: .74rem;
    letter-spacing: 0;
    font-weight: 600;
    color: var(--text-2);
}

/* Toggle */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.toggle-wrap:has(input:checked) {
    border-color: rgba(42,32,111,.2);
    background: var(--blue-light);
}
.toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute; inset: 0;
    background: var(--border-2);
    border-radius: 11px;
    cursor: pointer;
    transition: background .2s;
}
.toggle-track::after {
    content: '';
    position: absolute;
    left: 3px; top: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s var(--ease-spring);
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.toggle input:checked + .toggle-track { background: var(--blue); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-lbl { font-size: .875rem; color: var(--text-2); font-weight: 500; }

/* Section divider */
.settings-section { margin-bottom: 20px; }
.settings-hd {
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 0 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Settings grid for form rows */
.settings-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--r-md);
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    border: none;
    transition: all .15s var(--ease);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -.01em;
}
.btn-primary {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px var(--blue-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-deeper) 100%);
    box-shadow: 0 4px 16px var(--blue-glow);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
    background: var(--surface);
    color: var(--text-2);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-muted); }
.btn-danger-ghost {
    background: transparent;
    color: #dc2626;
    border: 1.5px solid #fca5a5;
}
.btn-danger-ghost:hover { background: #fef2f2; border-color: #f87171; }
.btn-sm { padding: 5px 12px; font-size: .75rem; }

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-lbl { width: 130px; font-size: .74rem; color: var(--text-2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 6px; height: 20px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill  { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue), var(--blue-dark)); transition: width .6s var(--ease); box-shadow: 0 0 8px var(--blue-glow); }
.bar-num   { font-size: .73rem; color: var(--text-muted); min-width: 32px; font-weight: 700; }

/* ════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity:0; } }

.modal {
    background: var(--surface);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: 0 24px 80px rgba(15,23,42,.18), 0 8px 20px rgba(0,0,0,.06);
    overflow: hidden;
    animation: slideUp .2s var(--ease-spring);
    border: 1px solid var(--border);
}
@keyframes slideUp { from { transform:translateY(20px);opacity:0; } }

.modal-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, var(--surface), var(--surface-2));
    box-shadow: inset 3px 0 0 var(--blue);
}
.modal-title { font-size: .92rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.modal-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    transition: background .15s, color .15s, transform .1s;
}
.modal-close:hover { background: #fee2e2; color: #dc2626; transform: scale(1.1); }
.modal-body { padding: 22px 20px; }
.modal-ft {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* ════════════════════════════════════════════════════════════
   TOASTS
   ════════════════════════════════════════════════════════════ */
.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #1a2740 0%, #1B2537 100%);
    border: 1px solid rgba(255,255,255,.08);
    color: #fff;
    border-radius: var(--r-lg);
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
    font-size: .82rem;
    font-weight: 500;
    max-width: 320px;
    pointer-events: all;
    animation: toastIn .22s var(--ease-spring);
    backdrop-filter: blur(10px);
}
@keyframes toastIn { from { transform:translateX(24px);opacity:0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--online); }
.toast.error   .toast-dot { background: #F87171; }
.toast.info    .toast-dot { background: #60A5FA; }

/* ════════════════════════════════════════════════════════════
   SCROLLBARS & UTILITIES
   ════════════════════════════════════════════════════════════ */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Embed code block */
.embed-code-block {
    background: linear-gradient(135deg, #151e2e 0%, #1B2537 100%);
    color: #93C5FD;
    border-radius: var(--r-lg);
    padding: 18px 18px 18px 20px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: .78rem;
    line-height: 1.7;
    white-space: pre;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,.06);
    margin: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.text-rose  { color: var(--blue); }
.text-muted { color: var(--text-muted); }
.fw-800     { font-weight: 800; }

/* ── Department Manager (Tidio-style two-panel) ───────────── */
.dept-manager {
    display: grid;
    grid-template-columns: 240px 1fr;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    min-height: 500px;
}
.dept-list-panel {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--surface-2);
}
.dept-list-scroll { flex: 1; overflow-y: auto; }
.dept-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
    border-left: 3px solid transparent;
}
.dept-list-item:hover { background: rgba(42,32,111,.04); }
.dept-list-item.active {
    background: var(--blue-light);
    border-left-color: var(--blue);
}
.dept-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dept-list-info { flex: 1; min-width: 0; }
.dept-list-name { font-size: .85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dept-list-count { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.dept-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.dept-status-dot.active { background: #22c55e; }
.dept-edit-panel { display: flex; flex-direction: column; min-width: 0; }
.dept-edit-empty { align-items: center; justify-content: center; text-align: center; padding: 48px; }
.dept-edit-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.dept-edit-title { font-weight: 700; font-size: .95rem; color: var(--text); }
.dept-edit-body { padding: 20px; overflow-y: auto; flex: 1; }
.dept-section { margin-bottom: 28px; }
.dept-section:last-child { margin-bottom: 0; }
.dept-section-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.dept-section-sub { font-size: .78rem; color: var(--text-muted); margin-bottom: 12px; margin-top: -8px; }
.agent-toggle-list {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.agent-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.agent-toggle-row:last-child { border-bottom: none; }
.agent-toggle-row:hover { background: var(--surface-2); }
.agent-toggle-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .7rem;
    flex-shrink: 0;
}
.agent-toggle-info { flex: 1; min-width: 0; }
.agent-toggle-name { font-size: .84rem; font-weight: 600; color: var(--text); }
.agent-toggle-role { font-size: .7rem; color: var(--text-muted); }

/* Responsive */
@media (max-width: 1300px) { :root { --info-w: 0px; } .info-sidebar { display:none; } }
@media (max-width: 1050px) { :root { --list-w: 260px; --folder-w: 200px; } }
@media (max-width: 860px)  { .folder-panel { display:none; } .app-layout.app-inbox { grid-template-columns: var(--icon-rail) var(--list-w) 1fr; } }

/* ============================================================
   SMS Page
   ============================================================ */

.sms-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}

/* ── Sidebar ── */
.sms-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sms-sidebar-hd {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sms-sidebar-title {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
    letter-spacing: -.01em;
}

.sms-conv-count {
    font-size: .67rem;
    font-weight: 700;
    background: var(--blue-muted);
    color: var(--blue);
    border-radius: 99px;
    padding: 2px 8px;
}

.sms-new-btn {
    font-size: .72rem !important;
    padding: 4px 10px !important;
    background: var(--blue) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background .15s;
}
.sms-new-btn:hover { background: var(--blue-dark) !important; }

.sms-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sms-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: .82rem;
    color: var(--text);
}
.sms-search-input::placeholder { color: #94a3b8; }

.sms-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.sms-conv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: #94a3b8;
    font-size: .82rem;
    text-align: center;
}

.sms-conv-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
    margin-bottom: 2px;
}
.sms-conv-item:hover { background: var(--surface-hover); }
.sms-conv-item.active { background: var(--blue-light); }
.sms-conv-item.unread .sms-conv-name { font-weight: 700; }
.sms-conv-item.unread .sms-conv-preview { color: var(--text); font-weight: 500; }

.sms-conv-ava {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    margin-top: 1px;
}

.sms-conv-meta { flex: 1; min-width: 0; }

.sms-conv-row1 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 2px;
}

.sms-conv-name {
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-conv-time {
    font-size: .68rem;
    color: #94a3b8;
    flex-shrink: 0;
    margin-left: 6px;
}

.sms-conv-row2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.sms-conv-preview {
    font-size: .75rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-unread-badge {
    background: var(--blue);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    border-radius: 99px;
    padding: 1px 6px;
    flex-shrink: 0;
    margin-left: 6px;
}

.sms-conv-tags {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sms-sender-pill {
    font-size: .62rem;
    font-weight: 600;
    background: #f3e8ff;
    color: #7c3aed;
    border-radius: 99px;
    padding: 1px 7px;
}

.sms-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sms-status-open   { background: #22c55e; }
.sms-status-closed { background: #94a3b8; }
.sms-status-pending { background: #f59e0b; }

/* ── Main / Compose ── */
.sms-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

.sms-compose-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    overflow-y: auto;
    background: var(--bg);
}

.sms-compose-card {
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(42,32,111,.10), 0 2px 8px rgba(0,0,0,.04);
    width: 100%;
    max-width: 620px;
    overflow: hidden;
    border: 1px solid var(--border);
}

/* Header */
.sms-compose-card-hd {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    padding: 24px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}
.sms-compose-hd-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.sms-compose-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,.15);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(4px);
}
.sms-compose-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -.025em;
    margin-bottom: 2px;
}
.sms-compose-card-sub {
    font-size: .78rem;
    opacity: .7;
}
.sms-compose-hd-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    backdrop-filter: blur(4px);
}

/* Body */
.sms-compose-card-body {
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.sms-field-group { display: flex; flex-direction: column; }

.sms-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-2);
    margin-bottom: 8px;
}
.sms-label-opt {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #b0bec5;
    font-size: .7rem;
    margin-left: 4px;
}

/* From tabs */
.sms-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.sms-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-2);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
    white-space: nowrap;
}
.sms-tab:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.sms-tab.active { border-color: var(--blue); background: var(--blue-light); color: var(--blue); font-weight: 600; }
.sms-tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background .15s;
}
.sms-tab-dot.active { background: var(--blue); }

/* Two-col grid */
.sms-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* Input fields */
.sms-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid var(--border);
    border-radius: 11px;
    padding: 10px 14px;
    background: var(--bg);
    transition: border-color .15s, box-shadow .15s;
}
.sms-input-wrap:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-muted);
    background: var(--surface);
}
.sms-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: .875rem;
    color: var(--text);
    background: transparent;
    font-family: inherit;
}
.sms-input::placeholder { color: #b0bec5; }

.sms-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid var(--border);
    border-radius: 11px;
    padding: 13px 14px;
    font-size: .875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    resize: none;
    line-height: 1.6;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.sms-textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-muted);
    background: var(--surface);
}
.sms-textarea::placeholder { color: #b0bec5; }

/* Character bar */
.sms-char-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}
.sms-char-bar-track {
    flex: 1;
    height: 3px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}
.sms-char-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--blue);
    transition: width .1s, background .15s;
}
.sms-char-bar-fill.warn { background: #f59e0b; }
.sms-char-bar-fill.over { background: #ef4444; }

.sms-char-count {
    font-size: .7rem;
    color: #94a3b8;
    font-weight: 500;
    transition: color .15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.sms-char-count.warn { color: #f59e0b; }
.sms-char-count.over { color: #ef4444; font-weight: 700; }

/* Actions row */
.sms-compose-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 2px;
}
.sms-compose-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    color: #b0bec5;
}
.sms-send-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: #fff;
    border: none;
    border-radius: 11px;
    padding: 11px 26px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: -.01em;
    transition: opacity .15s, transform .1s, box-shadow .15s;
    box-shadow: 0 4px 16px rgba(37,99,235,.35);
}
.sms-send-btn:hover:not(:disabled) { opacity: .92; transform: translateY(-1px); box-shadow: 0 6px 22px rgba(37,99,235,.4); }
.sms-send-btn:active:not(:disabled) { transform: translateY(0); }
.sms-send-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── SMS Log ─────────────────────────────────────────────────── */
.smslog-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}
.smslog-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.smslog-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .83rem;
}
.smslog-table thead tr {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.smslog-table th {
    padding: 11px 16px;
    text-align: left;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-2);
    white-space: nowrap;
}
.smslog-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}
.smslog-table tbody tr:last-child td { border-bottom: none; }
.smslog-table tbody tr:hover { background: var(--surface-hover); }

.smslog-time {
    white-space: nowrap;
    color: var(--text-2) !important;
    font-size: .78rem !important;
}
.smslog-agent {
    display: flex;
    align-items: center;
    gap: 10px;
}
.smslog-ava {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.smslog-agent-name { font-weight: 600; font-size: .83rem; }
.smslog-agent-email { font-size: .72rem; color: var(--text-2); }

.smslog-pill {
    display: inline-block;
    background: #ede9fe;
    color: #6d28d9;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.smslog-contact-name { font-weight: 500; }
.smslog-contact-num  { font-size: .75rem; color: var(--text-2); }

.smslog-msg {
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-2) !important;
}
.smslog-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 0 4px;
}

/* ============================================================
   Contacts Page
   ============================================================ */

.contacts-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}

/* ── List panel ── */
.contacts-list-panel {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

.contacts-list-hd {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.contacts-list-title {
    font-size: .84rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.contacts-count {
    background: var(--blue-muted);
    color: var(--blue);
    font-size: .65rem;
    font-weight: 700;
    border-radius: 20px;
    padding: 2px 7px;
}

.contacts-search-wrap {
    position: relative;
}

.contacts-search {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px 7px 28px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: .82rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}

.contacts-search:focus { border-color: var(--blue); }

.contacts-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.contacts-list-body::-webkit-scrollbar { width: 3px; }
.contacts-list-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.contacts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--text-muted);
    font-size: .82rem;
    gap: 4px;
}

.contact-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}

.contact-row:last-child { border-bottom: none; }
.contact-row:hover { background: rgba(42,32,111,.04); }
.contact-row.active { background: var(--blue-muted); }

.contact-row-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: .74rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.contact-row-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-row-meta {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.contact-row-channels {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.ch-badge {
    font-size: .62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.6;
}

.ch-widget { background: #e0f2fe; color: #0369a1; }
.ch-wa     { background: #dcfce7; color: #15803d; }
.ch-sms    { background: #fef3c7; color: #92400e; }

.contact-row-time {
    font-size: .7rem;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 4px;
}

.contacts-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ── Detail panel ── */
.contacts-detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.contacts-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: .9rem;
}

.contacts-detail-hd {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.contacts-detail-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contacts-detail-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
}

.contacts-detail-sub {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.contacts-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
}

.contacts-detail-body::-webkit-scrollbar { width: 4px; }
.contacts-detail-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.cd-section {
    margin-bottom: 28px;
}

.cd-section-title {
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.cd-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.cd-field {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 9px 12px;
}

.cd-field-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 3px;
}

.cd-field-value {
    font-size: .83rem;
    color: var(--text);
    font-weight: 500;
    word-break: break-all;
}

/* History list */
.cd-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cd-history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 13px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.cd-history-item:hover {
    border-color: var(--blue);
    background: var(--blue-muted);
}

.cd-history-top {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}

.cd-ch-badge {
    font-size: .68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
}

.cd-ch-widget    { background: #e0f2fe; color: #0369a1; }
.cd-ch-whatsapp  { background: #dcfce7; color: #15803d; }
.cd-ch-sms       { background: #fef3c7; color: #92400e; }

.cd-history-msg {
    font-size: .8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.cd-history-meta {
    display: flex;
    gap: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }
