/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #17212b;
    --bg-secondary: #0e1621;
    --bg-tertiary: #1c2936;
    --bg-hover: #202d3b;
    --bg-active: #2b5278;
    --bg-message-in: #182533;
    --bg-message-out: #2b5278;
    --bg-input: #242f3d;
    --text-primary: #f5f5f5;
    --text-secondary: #8b9aab;
    --text-muted: #6b7c8d;
    --text-link: #6ab3f3;
    --accent: #5b9bd5;
    --accent-hover: #6db3e8;
    --green: #4fae4e;
    --red: #e55c5c;
    --border: #1f2f3f;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.2s ease;
}

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

/* === Login Screen === */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #0e1621 0%, #17212b 50%, #1c2936 100%);
}

.login-card {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 48px 40px;
    width: 380px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-logo {
    margin-bottom: 20px;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: border-color var(--transition);
    outline: none;
}

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

.input-group input::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: 8px;
}

.btn-login:hover {
    background: var(--accent-hover);
}

.login-error {
    color: var(--red);
    margin-top: 16px;
    font-size: 13px;
}

/* === App Layout === */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar (Managers) === */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.sidebar-search {
    padding: 8px 12px;
}

.sidebar-search input,
.search-box input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 20px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.sidebar-search input::placeholder,
.search-box input::placeholder {
    color: var(--text-muted);
}

.manager-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.manager-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-left: 3px solid transparent;
}

.manager-item:hover {
    background: var(--bg-hover);
}

.manager-item.active {
    background: var(--bg-active);
    border-left-color: var(--accent);
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.manager-info {
    margin-left: 12px;
    flex: 1;
    min-width: 0;
}

.manager-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.manager-username {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.manager-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: 8px;
}

.manager-status.online {
    background: var(--green);
    box-shadow: 0 0 6px rgba(79,174,78,0.5);
}

.manager-status.offline {
    background: var(--text-muted);
}

.badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* === Chat List Panel === */
.chat-list-panel {
    width: 340px;
    min-width: 340px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-box {
    flex: 1;
    margin-left: 12px;
    max-width: 200px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-active);
}

.chat-item-info {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
}

.chat-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.chat-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-item-unread {
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* === Messages Panel === */
.messages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
    position: relative;
}

.messages-header {
    gap: 12px;
}

.btn-back {
    display: none;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-name {
    font-size: 15px;
    font-weight: 600;
}

.chat-username {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 60px;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
    display: flex;
    flex-direction: column;
}

.date-separator {
    text-align: center;
    margin: 16px 0;
}

.date-separator span {
    background: rgba(0,0,0,0.3);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
}

.message {
    max-width: 65%;
    margin-bottom: 4px;
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.45;
}

.message.incoming {
    background: var(--bg-message-in);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.outgoing {
    background: var(--bg-message-out);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

.message-text {
    font-size: 14px;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.message-media {
    margin: 4px 0;
    max-width: 320px;
}

.message-media img,
.message-media video {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}

.message-media-placeholder {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.message-media-placeholder svg {
    flex-shrink: 0;
}

.message-caption {
    font-size: 14px;
    color: var(--text-primary);
    margin-top: 4px;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 2px;
}

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

.message-edited {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

/* === Send Form === */
.send-form {
    padding: 8px 60px 16px;
    background: var(--bg-primary);
}

.send-form-inner {
    display: flex;
    align-items: flex-end;
    background: var(--bg-input);
    border-radius: 20px;
    padding: 4px 4px 4px 16px;
    gap: 8px;
}

.send-form-inner textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    padding: 8px 0;
    line-height: 1.4;
}

.send-form-inner textarea::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition), transform 0.1s;
}

.btn-send:hover {
    background: var(--accent-hover);
}

.btn-send:active {
    transform: scale(0.95);
}

.send-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
    min-height: 18px;
}

.send-status.error {
    color: var(--red);
}

.send-status.success {
    color: var(--green);
}

/* === Empty States === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

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

.empty-state p {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 8px;
}

.empty-state small {
    color: var(--text-muted);
    font-size: 12px;
    max-width: 240px;
    line-height: 1.4;
}

/* === Buttons === */
.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 13px;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s;
    border-left: 4px solid var(--accent);
    max-width: 360px;
}

.toast.error {
    border-left-color: var(--red);
}

.toast.success {
    border-left-color: var(--green);
}

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* === Scrollbars === */
::-webkit-scrollbar {
    width: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === Avatar Colors === */
.avatar-color-0 { background: #5b9bd5; }
.avatar-color-1 { background: #e57373; }
.avatar-color-2 { background: #81c784; }
.avatar-color-3 { background: #ffb74d; }
.avatar-color-4 { background: #ba68c8; }
.avatar-color-5 { background: #4db6ac; }
.avatar-color-6 { background: #f06292; }
.avatar-color-7 { background: #aed581; }

/* === Loading === */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* === No-reply indicator === */
/* === Media preview === */
.media-preview {
    padding: 8px 60px 0;
}

.media-preview-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 10px 14px;
}

.media-preview-inner img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
}

.media-preview-inner span {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-remove-media {
    flex-shrink: 0;
}

.btn-attach {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.btn-attach:hover {
    color: var(--accent);
}

.media-preview + .send-form-inner {
    border-radius: 0 0 20px 20px;
}

/* === AI Panel (4th column) === */
.ai-panel {
    width: 300px;
    min-width: 300px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.ai-panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
}

.ai-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
}

.ai-section {
    margin-bottom: 20px;
}

.ai-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.ai-stage-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: var(--text-muted);
}

.ai-score {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.ai-score.good { color: var(--green); }
.ai-score.medium { color: #ffd54f; }
.ai-score.bad { color: var(--red); }

.ai-summary {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.ai-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-suggestion-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    line-height: 1.4;
}

.ai-suggestion-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.ai-warnings {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-warning-item {
    background: rgba(229,92,92,0.1);
    border-left: 3px solid var(--red);
    padding: 8px 12px;
    font-size: 12px;
    color: #ff8a8a;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.4;
}

/* === Stage badge in header === */
.stage-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-left: auto;
    flex-shrink: 0;
}

/* === Chat item stage dot === */
.chat-item-stage {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 8px;
}

/* === Notification badge === */
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* === Notification dropdown === */
.notif-dropdown {
    position: fixed;
    top: 50px;
    left: 200px;
    width: 360px;
    max-height: 400px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.notif-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-read-all {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.notif-list {
    overflow-y: auto;
    max-height: 340px;
}

.notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.notif-item:hover {
    background: var(--bg-hover);
}

.notif-item.unread {
    background: rgba(91,155,213,0.08);
}

.notif-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.notif-dot.info { background: var(--accent); }
.notif-dot.warning { background: #ffb74d; }
.notif-dot.critical { background: var(--red); }

.notif-text {
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.3;
}

.notif-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.notif-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* === AI Loading spinner === */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px 0;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === Manager Top Bar === */
.manager-topbar {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.manager-topbar h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

/* === Chat Timer & Urgency === */
.chat-timer {
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 6px;
    white-space: nowrap;
}

.chat-item.urgency-yellow {
    border-left: 3px solid #ffd54f;
}

.chat-item.urgency-orange {
    border-left: 3px solid #ffb74d;
    background: rgba(255, 183, 77, 0.05);
}

.chat-item.urgency-red {
    border-left: 3px solid #ef5350;
    background: rgba(239, 83, 80, 0.08);
    animation: urgencyPulse 2s ease-in-out infinite;
}

@keyframes urgencyPulse {
    0%, 100% { background: rgba(239, 83, 80, 0.08); }
    50% { background: rgba(239, 83, 80, 0.15); }
}

/* === Attention Banner === */
.attention-banner {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    border-left: 4px solid #ffb74d;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: none;
    align-items: center;
    gap: 8px;
}

.attention-icon {
    font-size: 16px;
}

.attention-icon.pulse {
    animation: iconPulse 1s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.no-reply-banner {
    background: rgba(229,92,92,0.15);
    color: var(--red);
    text-align: center;
    padding: 8px;
    font-size: 12px;
    border-top: 1px solid rgba(229,92,92,0.2);
}

/* === Responsive === */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
    }
    .chat-list-panel {
        width: 300px;
        min-width: 300px;
    }
    .messages-container {
        padding: 16px 20px;
    }
    .send-form {
        padding: 8px 20px 16px;
    }
}

/* ============================================
   MOBILE — Complete Rewrite
   ============================================ */

/* Bottom nav hidden on desktop */
.bottom-nav { display: none; }
.mobile-ai-btn { display: none !important; }

@media (max-width: 768px) {
    /* === Base Reset === */
    .app {
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    /* === Hide all panels by default === */
    .sidebar,
    .chat-list-panel,
    .messages-panel,
    .ai-panel {
        position: fixed !important;
        top: env(safe-area-inset-top, 0px);
        left: 0;
        right: 0;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        display: none !important;
        border: none !important;
        z-index: 10;
        overflow-y: auto;
        background: var(--bg-primary);
    }

    /* === Show active panel === */
    .sidebar.mob-active,
    .chat-list-panel.mob-active,
    .messages-panel.mob-active,
    .ai-panel.mob-active {
        display: flex !important;
    }

    /* === Chat & AI take full screen (no bottom bar) === */
    .messages-panel.mob-active {
        bottom: 0 !important;
        z-index: 20;
    }
    .ai-panel.mob-active {
        bottom: 0 !important;
        z-index: 25;
    }

    /* === Sidebar (Managers) === */
    .sidebar.mob-active {
        flex-direction: column;
        background: var(--bg-primary);
    }

    .sidebar .sidebar-header {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
        display: flex !important;
    }

    .sidebar .sidebar-header h2 {
        display: block !important;
        font-size: 20px;
    }

    .sidebar .sidebar-search {
        display: block !important;
        padding: 8px 16px;
    }

    .sidebar .manager-list {
        flex: 1;
        overflow-y: auto;
    }

    .sidebar .manager-item {
        padding: 14px 16px;
        border-left: none;
        display: flex !important;
    }

    .sidebar .manager-info {
        display: block !important;
        margin-left: 12px;
    }

    .sidebar .manager-status {
        display: block !important;
    }

    /* === Chat List Panel === */
    .chat-list-panel.mob-active {
        flex-direction: column;
        background: var(--bg-primary);
    }

    .chat-list-panel .panel-header {
        padding: 12px 16px;
        min-height: 50px;
    }

    .chat-list-panel .chat-list {
        flex: 1;
        overflow-y: auto;
    }

    .chat-item {
        padding: 12px 16px;
        min-height: 60px;
    }

    /* === Manager Topbar (for manager role) === */
    .manager-topbar {
        padding: 12px 16px;
    }

    /* === Messages Panel — Messenger style === */
    .messages-panel.mob-active {
        flex-direction: column;
        background: var(--bg-primary);
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 100% !important;
        width: 100% !important;
        overflow: hidden;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .messages-panel .messages-header {
        padding: 8px 12px !important;
        min-height: 48px;
        gap: 8px;
        flex-shrink: 0;
    }

    .messages-panel .btn-back {
        display: flex !important;
    }

    .messages-panel .messages-container {
        flex: 1;
        padding: 8px 12px !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .messages-panel .message {
        max-width: 85%;
        font-size: 15px;
    }

    .messages-panel.mob-active .send-form,
    .messages-panel .send-form[style] {
        display: block !important;
        padding: 6px 10px !important;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
        flex-shrink: 0;
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
    }

    .messages-panel .send-form-inner {
        border-radius: 24px;
        padding: 2px 4px 2px 12px;
    }

    .messages-panel .send-form-inner textarea {
        font-size: 16px !important;
        min-height: 36px;
        padding: 8px 0;
    }

    .messages-panel .btn-send {
        width: 36px;
        height: 36px;
    }

    .messages-panel .media-preview {
        padding: 6px 8px 0;
        flex-shrink: 0;
    }

    /* === Mobile AI Button in header === */
    .mobile-ai-btn {
        display: flex !important;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--accent);
        color: white;
        border: none;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }

    /* === AI Panel === */
    .ai-panel.mob-active {
        flex-direction: column;
        background: var(--bg-primary);
        overflow-y: auto;
    }

    .ai-panel .ai-panel-header {
        position: sticky;
        top: 0;
        background: var(--bg-secondary);
        z-index: 5;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
    }

    .ai-panel .ai-panel-header .btn-back {
        display: flex !important;
    }

    .ai-panel .ai-panel-content {
        padding: 16px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    /* === Stage badge === */
    .stage-badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    /* === Bottom Navigation Bar === */
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .bottom-nav.mob-hidden {
        display: none !important;
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 500;
        border: none;
        background: none;
        cursor: pointer;
        font-family: inherit;
        padding: 4px 2px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }

    .bottom-nav-item.active {
        color: var(--accent);
    }

    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .bottom-nav-badge {
        position: absolute;
        top: 2px;
        right: calc(50% - 18px);
        background: var(--red);
        color: white;
        font-size: 9px;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }

    /* === Attention Banner === */
    .attention-banner {
        padding: 8px 12px;
        font-size: 12px;
    }

    /* === Notification Dropdown === */
    .notif-dropdown {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: 60px;
        top: auto;
        width: auto;
        max-height: 60vh;
    }

    /* === Media === */
    .message-media {
        max-width: 240px;
    }

    /* === Chat timer === */
    .chat-timer {
        font-size: 11px;
    }

    /* === Search inputs — prevent iOS zoom === */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }

    /* === Urgency animations === */
    .chat-item.urgency-red {
        animation: urgencyPulse 2s ease-in-out infinite;
    }
}

