/* ============================================
   מס ישיר CRM - Design System
   ============================================ */

:root {
    --brand-teal: #1B4D3E;
    --brand-teal-dark: #123A2E;
    --brand-teal-light: #E3EFEA;
    --accent-orange: #EB6025;
    --brand-turquoise: #224F55;
    --accent-orange-dark: #c44d18;
    --accent-orange-light: #fde3d4;

    --bg-app: #f5f6f8;
    --bg-card: #ffffff;
    --bg-hover: #f8f9fb;
    --bg-active: #eff5f8;
    --bg-active-strong: #d8e7ec;

    --text-primary: #1a1f2e;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-on-dark: #ffffff;

    --border: #e8eaed;
    --border-strong: #d1d5db;

    --success: #1B4D3E;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #1B4D3E;
    --purple: #8b5cf6;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.04);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --topbar-h: 64px;
    --sidebar-w: 240px;
    --conv-list-w: 360px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Heebo', system-ui, -apple-system, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    direction: rtl;
    height: 100%;
    overflow: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    color: inherit;
}

/* ============================================
   TOPBAR
   ============================================ */
.app-topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr auto;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1.5rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: contain;
}

.topbar-logo-fallback {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
}

.topbar-title-main {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--brand-teal);
    line-height: 1.1;
}

.topbar-title-sub {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
}

.topbar-search {
    position: relative;
    max-width: 480px;
    display: flex;
    align-items: center;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 .75rem;
    transition: all .15s;
}

.topbar-search:focus-within {
    background: white;
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.topbar-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.topbar-search input {
    flex: 1;
    border: none;
    background: transparent;
    padding: .65rem .5rem;
    font-size: .9rem;
    outline: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.btn-primary-lg {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--accent-orange);
    color: white;
    padding: .625rem 1.125rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: .9rem;
    transition: all .15s;
    box-shadow: 0 2px 8px rgba(232,122,61,.25);
}

.btn-primary-lg:hover {
    background: var(--accent-orange-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232,122,61,.35);
}

.btn-secondary {
    padding: .625rem 1.125rem;
    border-radius: 10px;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .9rem;
    transition: all .15s;
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

.topbar-user {
    position: relative;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .35rem .65rem .35rem .85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
    border: 1px solid var(--border);
    background: white;
}

.user-chip:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.user-info {
    line-height: 1.15;
}

.user-name {
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-primary);
}

.user-role {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.user-chev {
    font-size: .55rem;
    color: var(--text-muted);
    margin-right: .35rem;
}

.user-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 50;
}

.user-menu.show {
    display: block;
}

.user-menu-item {
    display: block;
    padding: .65rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    transition: background .12s;
}

.user-menu-item:hover {
    background: var(--bg-hover);
}

/* ============================================
   LAYOUT
   ============================================ */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) var(--conv-list-w) 1fr;
    height: calc(100vh - var(--topbar-h));
    overflow: hidden;
}

/* 4.2: מזעור פאנלים (אדמין) — רשימת השיחות האמצעית + פאנל פרטי הלקוח, כל אחד בנפרד */
body.collapsed-convlist .app-layout { grid-template-columns: var(--sidebar-w) 0 1fr; }
body.collapsed-convlist .app-conv-list { display: none; }
body.collapsed-custpanel .conv-view-body { grid-template-columns: 1fr 0 !important; }
body.collapsed-custpanel .customer-panel { display: none; }
.panel-toggle-btn { padding: .5rem .7rem; border-radius: 8px; background: var(--bg-app); color: var(--text-secondary); font-size: 1rem; transition: all .15s; }
.panel-toggle-btn:hover { background: var(--border); color: var(--text-primary); }
.panel-toggle-btn.active { background: var(--brand-teal-light); color: var(--brand-teal); }

/* ============================================
   SIDEBAR
   ============================================ */
.app-sidebar {
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    padding: 1rem .75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 0 .75rem;
    margin-bottom: .5rem;
}

.sidebar-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    padding: .55rem .75rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s;
    border-radius: 6px;
}

.sidebar-section-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.section-chev {
    font-size: .65rem;
    color: var(--text-muted);
    transition: transform .18s ease;
}

.sidebar-section.collapsed .section-chev {
    transform: rotate(-90deg);
}

.sidebar-section.collapsed .sidebar-section-body {
    display: none;
}

.sidebar-section-body {
    animation: sectionExpand .2s ease-out;
}

@keyframes sectionExpand {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sidebar-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all .12s;
    margin-bottom: 2px;
    text-decoration: none;
    text-align: right;
}

.sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: var(--bg-active);
    color: var(--brand-teal);
    font-weight: 600;
}

.sidebar-item.active .sidebar-icon {
    transform: scale(1.05);
}

.sidebar-icon {
    font-size: 1.1rem;
    line-height: 1;
    transition: transform .12s;
    flex-shrink: 0;
}

.sidebar-label {
    flex: 1;
    font-size: .9rem;
}

.sidebar-count {
    background: var(--border);
    color: var(--text-secondary);
    padding: .1rem .5rem;
    border-radius: 10px;
    font-size: .7rem;
    font-weight: 700;
    min-width: 22px;
    text-align: center;
}

.sidebar-item.active .sidebar-count {
    background: var(--brand-teal);
    color: white;
}

.badge-warning {
    background: var(--warning) !important;
    color: white !important;
}

.dept-item, .agent-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    border-radius: 8px;
    transition: all .12s;
    cursor: pointer;
    text-align: right;
}

.dept-item:hover, .agent-item:hover {
    background: var(--bg-hover);
}

.dept-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dept-name, .agent-name {
    flex: 1;
    font-size: .85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.dept-count, .agent-count {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.agent-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-link {
    display: block;
    padding: .5rem .75rem;
    color: var(--text-muted);
    font-size: .8rem;
    text-decoration: none;
    border-radius: 6px;
    transition: all .12s;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.admin-shortcut {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem .85rem;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    color: white;
    border-radius: 10px;
    text-decoration: none;
    font-size: .9rem;
    transition: all .15s;
    box-shadow: 0 2px 6px rgba(29,72,85,.25);
}

.admin-shortcut:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(29,72,85,.35);
}

.admin-shortcut-arrow { margin-right: auto; font-weight: 700; }

/* ============================================
   CONVERSATIONS LIST
   ============================================ */
.app-conv-list {
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conv-list-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.conv-list-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.conv-count-badge {
    background: var(--bg-app);
    color: var(--text-secondary);
    padding: .15rem .6rem;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 700;
}

.conv-list-body {
    flex: 1;
    overflow-y: auto;
}

.conv-card {
    display: flex;
    gap: .75rem;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .1s;
    position: relative;
}

.conv-card:hover {
    background: var(--bg-hover);
}

.conv-card.selected {
    background: var(--bg-active);
}

.conv-card.selected::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--brand-teal);
}

.conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-teal-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .95rem;
    flex-shrink: 0;
    position: relative;
}

.conv-avatar.avatar-orange {
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-dark));
}

.conv-avatar.avatar-purple {
    background: linear-gradient(135deg, var(--purple), #6d28d9);
}

.conv-status-dot {
    position: absolute;
    bottom: -2px;
    left: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-bot { background: var(--info); }
.status-queue { background: var(--warning); animation: pulse 1.8s infinite; }
.status-human { background: var(--success); }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: .7; }
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-row1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
}

.conv-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.conv-row2 {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .25rem;
    font-size: .8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

/* חלק 3: chip אחיד לכל התגיות והשמות בשורת השיחה — גודל זהה, שורה אחת */
.conv-row2 > span {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    white-space: nowrap;
    font-size: .72rem;
    line-height: 1.5;
    border-radius: 10px;
    padding: 1px 8px;
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-phone {
    font-family: 'Heebo', monospace;
    direction: ltr;
    background: var(--bg-app);
    color: var(--text-muted);
}

.conv-dept-tag {
    background: var(--bg-app) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border);
    font-weight: 600;
}

.conv-agent-tag {
    background: var(--bg-app) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border);
    font-weight: 500;
}

.conv-stage-tag {
    font-weight: 600;
    border: none;
}

.conv-preview {
    margin-top: .3rem;
    font-size: .82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: .35rem;
}

.preview-sender {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .75rem;
}

.unread-badge {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-orange);
    color: white;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: .68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   CONVERSATION VIEW (right pane)
   ============================================ */
.app-conv-view {
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    overflow: hidden;
}

.conv-view-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.conv-view-header .conv-avatar {
    width: 40px;
    height: 40px;
    font-size: .85rem;
}

.conv-view-info {
    flex: 1;
    min-width: 0;
}

.conv-view-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.conv-view-meta {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.conv-view-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all .15s;
    background: transparent;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon.btn-icon-primary {
    background: var(--brand-teal);
    color: white;
}

.btn-icon.btn-icon-primary:hover {
    background: var(--brand-teal-dark);
}

.btn-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: .82rem;
    transition: all .15s;
}

.btn-pill-take {
    background: var(--brand-teal);
    color: white;
}

.btn-pill-take:hover {
    background: var(--brand-teal-dark);
}

.btn-pill-release {
    background: var(--bg-app);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-pill-release:hover {
    background: var(--border);
}

.conv-view-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 280px;
    overflow: hidden;
}

.chat-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-app);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

.msg-row {
    display: flex;
    margin-bottom: 1rem;
    gap: .65rem;
}

.msg-row.msg-out {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-top: 18px;
}

.msg-avatar-bot { background: var(--info); }
.msg-avatar-customer { background: var(--brand-teal); }
.msg-avatar-agent { background: var(--accent-orange); }

.msg-content-wrap {
    max-width: 65%;
    display: flex;
    flex-direction: column;
}

.msg-out .msg-content-wrap {
    align-items: flex-end;
}

.msg-meta {
    font-size: .7rem;
    color: var(--text-muted);
    margin-bottom: .2rem;
    padding: 0 .25rem;
    font-weight: 500;
}

.msg-bubble {
    background: white;
    padding: .65rem .85rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: .92rem;
    line-height: 1.45;
}

.msg-row.msg-sender-customer .msg-bubble {
    background: white;
    border-radius: 12px 12px 12px 4px;
}

.msg-row.msg-sender-bot .msg-bubble {
    background: var(--brand-teal-light);
    border-color: #c8d9de;
    border-radius: 4px 12px 12px 12px;
}

.msg-row.msg-out:not(.msg-sender-bot) .msg-bubble {
    background: var(--accent-orange);
    color: white;
    border-color: var(--accent-orange);
    border-radius: 4px 12px 12px 12px;
}

.msg-time-inline {
    font-size: .68rem;
    color: var(--text-muted);
    margin-top: .2rem;
    padding: 0 .25rem;
}

.chat-input-area {
    background: white;
    border-top: 1px solid var(--border);
    padding: .75rem 1rem;
    flex-shrink: 0;
    position: relative;
}

.quick-replies-bar {
    display: flex;
    align-items: center;
    margin-bottom: .5rem;
    position: relative;
}

.qr-toggle {
    background: var(--brand-teal-light);
    color: var(--brand-teal);
    padding: .35rem .75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: .8rem;
    transition: all .15s;
    border: 1px solid transparent;
}

.qr-toggle:hover {
    background: var(--brand-teal);
    color: white;
}

.qr-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    left: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 30;
}

.qr-menu.show {
    display: block;
}

.qr-item {
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
}

.qr-item:last-child { border-bottom: none; }
.qr-item:hover { background: var(--bg-hover); }

.qr-item-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .15rem;
}

.qr-shortcut {
    background: var(--accent-orange);
    color: white;
    padding: .1rem .45rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
    font-family: monospace;
}

.qr-title {
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-primary);
    flex: 1;
}

.qr-cat {
    font-size: .7rem;
    color: var(--text-muted);
    background: var(--bg-app);
    padding: .1rem .5rem;
    border-radius: 4px;
}

.qr-preview {
    font-size: .78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-right: 0;
}

/* Emoji Picker */
.emoji-picker {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    width: 320px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 30;
}

.emoji-picker.show { display: block; }

.emoji-tabs {
    display: flex;
    gap: 2px;
    padding: .35rem;
    background: var(--bg-app);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.emoji-tab {
    background: transparent;
    border: none;
    padding: .35rem .65rem;
    border-radius: 6px;
    font-size: .8rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all .12s;
}

.emoji-tab:hover { background: var(--bg-hover); }
.emoji-tab.active { background: var(--brand-teal); color: white; }

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: .5rem;
    max-height: 240px;
    overflow-y: auto;
}

.emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    padding: .4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all .1s;
    line-height: 1;
}

.emoji-btn:hover {
    background: var(--brand-teal-light);
    transform: scale(1.15);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.04);
    padding: .85rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    width: 340px;
    pointer-events: auto;
    cursor: pointer;
    transition: all .2s;
    border-right: 4px solid var(--accent-orange);
}

.toast:hover {
    transform: translateX(-4px);
    box-shadow: 0 15px 40px rgba(0,0,0,.22);
}

.toast-in {
    animation: toastSlideIn .35s cubic-bezier(.34,1.56,.64,1);
}

.toast-out {
    animation: toastSlideOut .3s ease-in forwards;
}

@keyframes toastSlideIn {
    from { transform: translateX(-120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
    to { transform: translateX(-120%); opacity: 0; }
}

.toast-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}

.toast-avatar.avatar-orange { background: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-dark)); }
.toast-avatar.avatar-purple { background: linear-gradient(135deg, var(--purple), #6d28d9); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; font-size: .9rem; color: var(--text-primary); }
.toast-meta { font-size: .72rem; color: var(--text-muted); margin: 1px 0 .3rem; direction: ltr; text-align: right; }
.toast-preview { font-size: .85rem; color: var(--text-secondary); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.toast-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    transition: all .15s;
}

.toast-close:hover { background: var(--bg-app); color: var(--text-primary); }

/* ============================================
   LEGAL CASE - Red border + popup
   ============================================ */
.conv-view-legal .conv-view-header {
    background: linear-gradient(90deg, #fef2f2 0%, white 60%);
    border-bottom: 2px solid var(--danger);
}

.conv-view-legal .chat-area {
    border: 3px solid var(--danger);
    border-top: none;
}

.legal-banner-mini {
    display: inline-block;
    background: #fee2e2;
    color: #991b1b;
    padding: .25rem .65rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: .75rem;
    margin-right: .5rem;
}

.legal-popup {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: legalPopupIn .2s ease-out;
}

@keyframes legalPopupIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.legal-popup-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(220,38,38,.3);
    border: 3px solid var(--danger);
    animation: legalPopupZoom .3s cubic-bezier(.34,1.56,.64,1);
}

@keyframes legalPopupZoom {
    from { transform: scale(.85); }
    to { transform: scale(1); }
}

.legal-popup-icon {
    font-size: 3.5rem;
    margin-bottom: .75rem;
    animation: legalShake .5s ease-out;
}

@keyframes legalShake {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

.legal-popup-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--danger);
    margin-bottom: .75rem;
}

.legal-popup-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ============================================
   Slash dropdown for quick replies
   ============================================ */
.slash-dropdown {
    display: none;
    position: fixed;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1500;
}

.slash-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    cursor: pointer;
    transition: background .12s;
    border-bottom: 1px solid var(--border);
}

.slash-item:last-child { border-bottom: none; }

.slash-item:hover, .slash-item.active {
    background: var(--brand-teal-light);
}

.slash-item-info { flex: 1; min-width: 0; }

.slash-item-title {
    font-weight: 700;
    font-size: .82rem;
    color: var(--text-primary);
}

.slash-item-preview {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* Templates button - distinguished from shortcuts */
.qr-toggle-template {
    background: var(--accent-orange-light) !important;
    color: var(--accent-orange-dark) !important;
}

.qr-toggle-template:hover {
    background: var(--accent-orange) !important;
    color: white !important;
}

/* ============================================
   Team Chat (internal team chats per dept/role)
   ============================================ */
.team-chat-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: right;
    transition: all .12s;
    margin-bottom: 2px;
    position: relative;
}

.team-chat-item:hover {
    background: var(--bg-hover);
}

.team-chat-item.active {
    background: var(--bg-active);
    color: var(--brand-teal);
    font-weight: 700;
}

.team-chat-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.team-chat-name {
    flex: 1;
    font-size: .88rem;
    color: var(--text-primary);
}

.team-chat-unread {
    background: var(--accent-orange);
    color: white;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: .68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Team chat view */
.team-chat-header {
    background: linear-gradient(90deg, var(--brand-teal-light), white 70%) !important;
}

.team-chat-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: var(--shadow-sm);
}

.team-chat-messages {
    background: #f5f7fa;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='1' fill='%23e0e5ed'/%3E%3C/svg%3E");
}

.team-msg {
    display: flex;
    gap: .65rem;
    margin-bottom: 1rem;
}

.team-msg-me {
    flex-direction: row-reverse;
}

.team-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.team-msg-body {
    max-width: 65%;
    background: white;
    border-radius: 12px;
    padding: .6rem .85rem;
    box-shadow: var(--shadow-sm);
}

.team-msg-me .team-msg-body {
    background: var(--brand-teal);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

.team-msg-me .team-msg-name {
    color: rgba(255,255,255,.8) !important;
}

.team-msg-me .team-msg-time {
    color: rgba(255,255,255,.7) !important;
}

.team-msg-head {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .15rem;
}

.team-msg-name {
    font-weight: 700;
    font-size: .8rem;
    color: var(--text-primary);
}

.team-msg-time {
    font-size: .7rem;
    color: var(--text-muted);
}

.team-msg-content {
    font-size: .92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chat-input-row {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .65rem .85rem;
    font-size: .92rem;
    resize: none;
    min-height: 42px;
    max-height: 150px;
    outline: none;
    transition: border-color .15s;
    line-height: 1.4;
}

.chat-input:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.btn-send {
    background: var(--accent-orange);
    color: white;
    padding: 0 1.25rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: .92rem;
    height: 42px;
    transition: all .15s;
}

.btn-send:hover {
    background: var(--accent-orange-dark);
}

.btn-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.bot-mode-banner {
    background: var(--brand-teal-light);
    color: var(--brand-teal);
    padding: .5rem .85rem;
    border-radius: 8px;
    font-size: .82rem;
    margin-bottom: .5rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    font-weight: 600;
}

/* ============================================
   CUSTOMER INFO PANEL (right of chat)
   ============================================ */
.customer-panel {
    background: white;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.25rem;
}

.panel-section {
    margin-bottom: 1.5rem;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .6rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}

.panel-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .35rem 0;
    font-size: .85rem;
    gap: .5rem;
}

.panel-row dt {
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.panel-row dd {
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    word-break: break-word;
}

.panel-row.panel-row-stacked {
    flex-direction: column;
    align-items: stretch;
    gap: .15rem;
}

.panel-row-stacked dd {
    text-align: right;
}

.zebra-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    color: var(--accent-orange);
    font-weight: 700;
    font-size: .85rem;
    text-decoration: none;
    margin-top: .5rem;
}

.zebra-link:hover {
    color: var(--accent-orange-dark);
}

.zebra-card-badge {
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    padding: .15rem .55rem;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
    display: inline-block;
}

.collected-tag {
    display: inline-block;
    background: var(--brand-teal-light);
    color: var(--brand-teal);
    padding: .2rem .55rem;
    border-radius: 6px;
    font-size: .72rem;
    margin: .15rem .15rem 0 0;
    font-weight: 600;
}

.btn-export-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 100%;
    background: var(--text-primary);
    color: white;
    padding: .55rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .82rem;
    margin-top: .5rem;
    text-decoration: none;
    transition: background .15s;
}

.btn-export-panel:hover {
    background: black;
}

.assignees-list { display: flex; flex-direction: column; gap: .5rem; }

.assignee-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .65rem;
    background: var(--bg-app);
    border-radius: 8px;
    border-right: 3px solid var(--brand-teal);
    transition: all .15s;
}

.assignee-chip:hover { background: var(--bg-hover); }

.assignee-info { flex: 1; min-width: 0; }

.assignee-name {
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-primary);
}

.assignee-source {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.assignee-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid transparent;
}

.assignee-remove:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ============================================
   CONTEXT MENU (right-click)
   ============================================ */
.context-menu {
    display: none;
    position: fixed;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.04);
    min-width: 220px;
    z-index: 1000;
    overflow: hidden;
    animation: cmFadeIn .12s ease-out;
}

@keyframes cmFadeIn {
    from { opacity: 0; transform: scale(.97); }
    to { opacity: 1; transform: scale(1); }
}

.cm-header {
    padding: .65rem .9rem;
    background: var(--bg-app);
    font-size: .85rem;
}

.cm-divider {
    height: 1px;
    background: var(--border);
    margin: .25rem 0;
}

.cm-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .9rem;
    cursor: pointer;
    font-size: .88rem;
    color: var(--text-primary);
    transition: background .1s;
}

.cm-item:hover { background: var(--bg-hover); }

.cm-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
}

.cm-danger { color: var(--danger); }
.cm-danger:hover { background: #fef2f2; }

/* ============================================
   ASSIGN AGENT MODAL
   ============================================ */
.assign-search {
    margin-bottom: 1rem;
}

.assign-search input {
    width: 100%;
    padding: .7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .95rem;
    font-family: inherit;
    outline: none;
    transition: all .15s;
}

.assign-search input:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.assign-by-dept {
    max-height: 60vh;
    overflow-y: auto;
}

.assign-dept-group {
    margin-bottom: 1.25rem;
}

.assign-dept-group:last-child {
    margin-bottom: 0;
}

.assign-dept-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: .88rem;
    color: var(--text-secondary);
    padding: 0 .25rem .5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.assign-dept-count {
    margin-right: auto;
    background: var(--bg-app);
    color: var(--text-muted);
    padding: .1rem .5rem;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 700;
}

.assign-agents-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}

.assign-agent-card {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .75rem;
    background: var(--bg-app);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    text-align: right;
    font-family: inherit;
}

.assign-agent-card:hover {
    background: var(--brand-teal-light);
    border-color: var(--brand-teal);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.assign-agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}

.assign-agent-info {
    flex: 1;
    min-width: 0;
}

.assign-agent-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: .9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assign-agent-meta {
    font-size: .73rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Conversation flags */
.conv-card-urgent { background: linear-gradient(90deg, rgba(239,68,68,.04), transparent); border-right: 3px solid var(--danger); }
.conv-card-pinned { background: linear-gradient(90deg, rgba(232,122,61,.06), transparent); }
.conv-card-pinned::after {
    content: '📌';
    position: absolute;
    top: .5rem;
    left: .5rem;
    font-size: .8rem;
    opacity: .7;
}

.conv-urgent, .conv-pin {
    display: inline-block;
    margin-left: .3rem;
}

.conv-tag {
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    padding: .05rem .4rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
    margin-right: .25rem;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state-large {
    padding: 5rem 2rem;
    margin: auto;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .5;
}

.empty-state-large .empty-icon {
    font-size: 4.5rem;
}

.empty-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: .35rem;
}

.empty-sub {
    font-size: .9rem;
    color: var(--text-muted);
}

/* ============================================
   MODAL
   ============================================ */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s ease-out;
}

@keyframes modalIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-app);
    color: var(--text-secondary);
    font-size: 1.4rem;
    line-height: 1;
    transition: all .15s;
}

.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: .35rem;
    font-size: .88rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .8rem;
    font-size: .92rem;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px rgba(29,72,85,.08);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-start;
    gap: .5rem;
    margin-top: 1.25rem;
    flex-direction: row-reverse;
}

/* ============================================
   ADMIN DASHBOARD
   ============================================ */
.admin-topbar {
    grid-template-columns: 320px 1fr auto;
    background: linear-gradient(90deg, var(--brand-teal), var(--brand-teal-dark));
    height: 80px;
}

.admin-topbar .topbar-title-main { color: white; font-size: 1.4rem; }
.admin-topbar .topbar-title-sub { color: rgba(255,255,255,.7); }
.admin-topbar .topbar-logo { background: white; padding: 3px; width: 56px; height: 56px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }

.admin-badge {
    background: var(--accent-orange);
    color: white;
    padding: .2rem .55rem;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 700;
    margin-top: 2px;
    display: inline-block;
}

.admin-nav {
    display: flex;
    gap: .35rem;
    justify-self: start;
}

.admin-nav-item {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: .55rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: .88rem;
    transition: all .15s;
}

.admin-nav-item:hover {
    background: rgba(255,255,255,.12);
    color: white;
}

.admin-nav-item.active {
    background: rgba(255,255,255,.18);
    color: white;
}

.admin-main {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    height: calc(100vh - var(--topbar-h));
    background: var(--bg-app);
}

.admin-section {
    background: white;
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.admin-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.admin-section-grid .admin-section {
    margin-bottom: 0;
}

.admin-h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--brand-teal-light);
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.big-stat {
    background: var(--bg-app);
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    border-top: 4px solid var(--brand-teal);
}

.big-stat-blue { border-top-color: #1B4D3E; }
.big-stat-orange { border-top-color: var(--accent-orange); }
.big-stat-green { border-top-color: var(--success); }

.big-stat-num {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.big-stat-label {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: .35rem;
    font-weight: 600;
}

.admin-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.alert-card {
    padding: 1.25rem;
    border-radius: 12px;
    border-right: 4px solid;
    background: var(--bg-app);
}

.alert-card-red { border-right-color: var(--danger); background: #fef2f2; }
.alert-card-orange { border-right-color: var(--warning); background: #fffbeb; }
.alert-card-blue { border-right-color: var(--info); background: #eff6ff; }

.alert-num {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
}

.alert-card-red .alert-num { color: var(--danger); }
.alert-card-orange .alert-num { color: var(--warning); }
.alert-card-blue .alert-num { color: var(--info); }

.alert-label {
    font-weight: 700;
    margin: .35rem 0;
    color: var(--text-primary);
}

.alert-sub {
    font-size: .8rem;
    color: var(--text-secondary);
}

.alert-link {
    display: inline-block;
    margin-top: .65rem;
    color: var(--brand-teal);
    font-weight: 700;
    text-decoration: none;
    font-size: .85rem;
}

.alert-link:hover { color: var(--brand-teal-dark); }

.dept-bar {
    margin-bottom: 1rem;
}

.dept-bar-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
}

.dept-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    font-size: .9rem;
}

.dept-count-big {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.dept-bar-track {
    background: var(--bg-app);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.dept-bar-fill {
    height: 100%;
    transition: width .4s ease;
    border-radius: 5px;
}

.template-summary { display: flex; flex-direction: column; gap: .5rem; }

.tmpl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .65rem .85rem;
    background: var(--bg-app);
    border-radius: 8px;
}

.tmpl-status {
    font-weight: 600;
    font-size: .9rem;
}

.tmpl-approved { color: var(--success); }
.tmpl-pending { color: var(--warning); }
.tmpl-draft { color: var(--text-muted); }
.tmpl-rejected { color: var(--danger); }

.tmpl-num { font-weight: 800; font-size: 1.2rem; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: right;
    padding: .65rem .85rem;
    background: var(--bg-app);
    font-weight: 700;
    font-size: .85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: .75rem .85rem;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.admin-table tr:hover td { background: var(--bg-hover); }

.agent-avatar-mini {
    display: inline-flex;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-teal);
    color: white;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .7rem;
    margin-left: .4rem;
    vertical-align: middle;
}

.badge-active, .badge-success {
    background: #d1fae5;
    color: #065f46;
    padding: .15rem .55rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
    padding: .15rem .55rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
}

/* Templates page */
.meta-info-box {
    background: var(--brand-teal-light);
    border-right: 4px solid var(--brand-teal);
    padding: 1rem 1.25rem;
    border-radius: 8px;
}
.meta-info-box h3 { margin-bottom: .5rem; color: var(--brand-teal); }
.meta-info-box ol { margin-right: 1.5rem; margin-top: .5rem; }
.meta-info-box li { margin-bottom: .25rem; font-size: .9rem; }
.meta-info-box p { line-height: 1.6; }

.template-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: box-shadow .15s;
}
.template-card:hover { box-shadow: var(--shadow); }

.template-card-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.template-card h3 { font-size: 1.05rem; color: var(--text-primary); margin: .25rem 0; }
.template-meta { font-size: .8rem; color: var(--text-muted); text-align: left; }

.template-body {
    background: var(--bg-app);
    padding: .85rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    border-right: 3px solid var(--brand-teal);
}

.template-vars { margin-top: .75rem; font-size: .85rem; }

.var-chip {
    display: inline-block;
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    padding: .15rem .55rem;
    border-radius: 4px;
    margin: 0 .25rem;
    font-size: .8rem;
    font-weight: 600;
}

.template-actions { margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============================================
   SIMULATOR (kept simple)
   ============================================ */
.simulator-page {
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.sim-info {
    background: white;
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.phone-mockup {
    background: var(--brand-teal);
    border-radius: 28px;
    padding: 10px;
    box-shadow: var(--shadow-lg);
    height: 620px;
    display: flex;
    flex-direction: column;
}

.phone-header {
    background: var(--brand-teal);
    color: white;
    padding: .85rem 1rem;
    border-radius: 18px 18px 0 0;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 3px;
}

.phone-chat {
    flex: 1;
    background: #ece5dd;
    padding: 1rem;
    overflow-y: auto;
}

.bubble {
    max-width: 80%;
    padding: .55rem .85rem;
    border-radius: 8px;
    margin-bottom: .5rem;
    font-size: .9rem;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
    white-space: pre-wrap;
}

.bubble-bot {
    background: white;
}

.bubble-customer {
    background: var(--accent-orange-light);
    border-right: 3px solid var(--accent-orange);
    margin-right: auto;
}

.phone-input {
    display: flex;
    gap: .5rem;
    padding: .75rem;
    background: #f0f2f5;
    border-radius: 0 0 18px 18px;
}

.phone-input input {
    flex: 1;
    padding: .6rem 1rem;
    border: none;
    border-radius: 22px;
    outline: none;
}

.phone-input button {
    width: 44px;
    height: 44px;
    background: var(--accent-orange);
    color: white;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    border: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .conv-view-body { grid-template-columns: 1fr; }
    .customer-panel { display: none; }
}

@media (max-width: 900px) {
    :root { --sidebar-w: 200px; --conv-list-w: 280px; }
    .topbar-search { display: none; }
}

/* סבב 2: כפתור תפריט (עיצוב conv-agent-tag עבר לבלוק chip האחיד של חלק 3) */
.conv-menu-btn:hover { color:var(--brand-teal) !important; }

/* 5.1: וי/וי-וי — סימוני מסירה/קריאה */
.msg-tick { margin-right: .25rem; opacity: .75; font-size: .8em; letter-spacing: -2px; }
.msg-tick-read { color: #34b7f1; opacity: 1; }

/* 5.2: באנר חלון 24 שעות */
.window-banner {
    margin: .4rem .6rem 0;
    padding: .55rem .8rem;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.4;
}
.window-warn {
    background: var(--accent-orange-light);
    color: var(--accent-orange-dark);
    border: 1px solid var(--accent-orange);
}
.window-closed {
    background: #fde8e8;
    color: #b91c1c;
    border: 1px solid #f5a9a9;
}

/* חלק 5: פאנל "פרטי הלקוח" מאוחד */
.cust-exist {
    display: inline-block;
    padding: .3rem .7rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 700;
    margin: .2rem 0 .6rem;
}
.cust-exist-yes { background: #dcfce7; color: #16a34a; }
.cust-exist-no { background: #fee2e2; color: #dc2626; }
.cust-exist-loading { background: var(--bg-app); color: var(--text-muted); }
.cust-src { font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.cust-file {
    margin-top: .7rem;
    padding: .6rem .7rem;
    border-radius: 8px;
    background: var(--bg-app);
    border: 1px solid var(--border);
}
.cust-file-legal {
    background: #fde8e8;
    border: 1px solid #f5a9a9;
}
.cust-file-title {
    font-size: .78rem;
    font-weight: 700;
    margin-bottom: .4rem;
    color: var(--text-primary);
}
.cust-file-row {
    display: flex;
    justify-content: space-between;
    padding: .2rem 0;
    font-size: .82rem;
}

/* עיגול "לא נקרא" על האווטר — מופיע רק בשיחה לא-נקראה, יורד אחרי קריאה */
.conv-unread-dot { background: #EB6025 !important; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }

/* 0.3 team accordion */
.dept-group-head { width: 100%; }
.dept-group-chev { transition: transform .15s; display: inline-block; font-size: .7rem; color: var(--text-muted); }
.dept-group:not(.open) .dept-group-chev { transform: rotate(-90deg); }
.dept-group-body { margin: .1rem 0 .3rem; }
.agent-item-sub { padding-right: 1.5rem; font-size: .88rem; }
.agent-item-sub.active { background: var(--brand-teal-light, #e6f2f0); font-weight: 600; }

/* 0.3 inline dept accordion */
.team-chat-group { display:block; }
.team-dept-row { display:flex; align-items:center; gap:.4rem; cursor:pointer; width:100%; }
.team-chat-group:not(.open) .dept-group-chev { transform: rotate(-90deg); }
.dept-group-chev { font-size:.7rem; color:var(--text-muted); transition:transform .15s; }
.team-dept-openchat { margin-inline-start:auto; opacity:.55; cursor:pointer; font-size:.9rem; }
.team-dept-openchat:hover { opacity:1; }
.dept-agents-acc { margin:.1rem 0 .4rem; padding-inline-start:.6rem; }
.dept-agents-acc .agent-item-sub { padding-inline-start:1.2rem; font-size:.86rem; }
.dept-agents-acc .agent-item-sub.active { background:var(--brand-teal-light,#e6f2f0); font-weight:600; }

/* 2.1 inline group members bar */
.team-members-bar { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; padding:.5rem .8rem; background:var(--bg-app); border-bottom:1px solid var(--border); font-size:.82rem; }
.team-members-label { color:var(--text-muted); font-weight:600; margin-inline-end:.2rem; }
.team-member-chip { display:inline-flex; align-items:center; gap:.3rem; background:#fff; border:1px solid var(--border); border-radius:999px; padding:.15rem .5rem .15rem .25rem; }
.team-member-dot { width:20px; height:20px; border-radius:50%; color:#fff; font-size:.65rem; font-weight:700; display:inline-flex; align-items:center; justify-content:center; }
.team-members-all { color:var(--text-secondary); font-style:italic; }

/* 3.1 my-agents list */
.my-agents-list { margin:.1rem 0 .3rem; padding-inline-start:1rem; }
.sidebar-subitem { display:flex; align-items:center; gap:.4rem; width:100%; background:none; border:none; cursor:pointer; padding:.3rem .6rem; border-radius:8px; font-size:.85rem; color:var(--text-secondary); }
.sidebar-subitem:hover { background:var(--bg-hover,#f0f0f0); }
.sidebar-subitem.active { background:var(--brand-teal-light,#e6f2f0); color:var(--brand-teal); font-weight:600; }
.sidebar-subitem .sidebar-label { flex:1; text-align:start; }
.sidebar-subitem .sidebar-count { color:var(--text-muted); font-size:.78rem; }
