:root {
    --bg: #f3f6fb;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-strong: #ffffff;
    --border: rgba(23, 43, 77, 0.08);
    --text: #172b4d;
    --muted: #667085;
    --primary: #0f6cbd;
    --primary-soft: #d9ecff;
    --accent: #14b8a6;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 22px 60px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(20, 184, 166, 0.12), transparent 28%),
        radial-gradient(circle at bottom right, rgba(15, 108, 189, 0.16), transparent 34%),
        var(--bg);
}

.form-control[readonly],
.form-control:disabled,
.form-select:disabled,
textarea.form-control[readonly] {
    background:
        linear-gradient(180deg, rgba(244, 247, 252, 0.98), rgba(237, 242, 248, 0.98));
    border-color: rgba(148, 163, 184, 0.34);
    color: #475467;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
    cursor: not-allowed;
    opacity: 1;
}

.form-control[readonly]:focus,
.form-control:disabled:focus,
.form-select:disabled:focus,
textarea.form-control[readonly]:focus {
    border-color: rgba(148, 163, 184, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.form-control[readonly]::placeholder,
.form-control:disabled::placeholder,
textarea.form-control[readonly]::placeholder {
    color: #98a2b3;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 292px;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(180deg, #0f172a, #132238);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar.collapsed {
    width: 96px;
}

.sidebar.collapsed .brand-copy,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-card,
.sidebar.collapsed .sidebar-subnav {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
}

.sidebar-brand {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #38bdf8, #14b8a6);
    color: #082f49;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.brand-subtitle,
.page-subtitle,
.sidebar-card-text,
.metric-label,
.notification-time,
.table-subtitle {
    color: var(--muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 16px;
    transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-card,
.glass-card,
.chart-card,
.auth-panel {
    background: var(--panel);
    backdrop-filter: blur(18px);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.sidebar-card {
    padding: 1rem;
    margin-top: auto;
}

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: start;
    padding: 1rem 1.5rem;
    background: linear-gradient(180deg, #0f172a, #132238);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    z-index: 30;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f8fafc;
}

.topbar-actions {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    justify-self: end;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    background: rgba(255,255,255,0.12);
    color: #f8fafc;
    display: grid;
    place-items: center;
}

.profile-button {
    height: 42px;
    padding: 0 0.9rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.12);
    color: #f8fafc;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    font-weight: 600;
}

.page-subtitle {
    color: rgba(226, 232, 240, 0.75);
}

.icon-button.danger {
    color: var(--danger);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.1rem 0.38rem;
}

.notification-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 340px;
    background: #fff;
    border-radius: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 25;
}

.notification-panel-header,
.section-title {
    font-weight: 700;
}

.notification-panel-header {
    padding: 1rem 1rem 0.5rem;
}

.notification-list {
    max-height: 360px;
    overflow-y: auto;
}

.notification-item {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(15, 23, 42, 0.05);
}

.content-area {
    padding: 1.5rem;
}

.hero-banner {
    position: relative;
    overflow: hidden;
    padding: 1.6rem;
    background: linear-gradient(135deg, #0f6cbd, #14b8a6);
    color: #fff;
}

.hero-banner::after {
    content: "";
    position: absolute;
    inset: auto -20% -55% auto;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.metric-card,
.toolbar-card,
.table-card,
.form-card,
.chat-card,
.search-results-card {
    padding: 1.2rem;
}

.metric-card {
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
}

.metric-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 999px;
    font-size: 0.78rem;
}

.chart-card,
.toolbar-card,
.table-card,
.form-card,
.chat-card,
.search-results-card {
    padding: 1.25rem;
}

.toolbar-grid {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr) auto;
    gap: 0.85rem;
}

.sidebar-subnav {
    display: grid;
    gap: 0.35rem;
    margin: -0.15rem 0 0.35rem 2.2rem;
}

.subnav-item {
    color: #94a3b8;
    text-decoration: none;
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    font-size: 0.92rem;
}

.subnav-item.active,
.subnav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.pagination-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-link-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 0.45rem 0.8rem;
}

.page-link-btn.active {
    background: var(--primary);
    color: #fff;
}

.comment-thread {
    display: grid;
    gap: 1rem;
}

.comment-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    padding: 1rem;
}

.detail-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.section-title-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title-icon i,
.detail-label i {
    color: var(--primary);
}

.site-visit-list {
    display: grid;
    gap: 1rem;
}

.site-visit-card {
    position: relative;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 255, 0.98));
    padding: 1rem 1rem 1rem 1.25rem;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.site-visit-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1rem;
    bottom: 1rem;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, #0f6cbd, #14b8a6);
}

.site-visit-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-visit-identity {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    min-width: 0;
}

.site-visit-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 16px;
    background: linear-gradient(135deg, #d9ecff, #d9fbf4);
    color: var(--primary);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-size: 1rem;
}

.site-visit-meta {
    display: grid;
    gap: 0.45rem;
}

.site-visit-agent {
    font-weight: 700;
    color: var(--text);
}

.site-visit-time {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.site-visit-seq {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.72rem;
    border-radius: 999px;
    background: #eef5ff;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
}

.site-visit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.site-visit-field {
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 16px;
    background: #fff;
    padding: 0.85rem 0.95rem;
}

.site-visit-field.full {
    grid-column: 1 / -1;
}

.site-visit-field-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.76rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.site-visit-field-value {
    color: var(--text);
    font-weight: 600;
    line-height: 1.55;
}

.site-visit-field-value.subtle {
    font-weight: 500;
    color: #475467;
}

.comment-replies {
    margin-left: 1.25rem;
    padding-left: 1rem;
    border-left: 2px solid #e2e8f0;
    display: grid;
    gap: 0.85rem;
    margin-top: 0.85rem;
}

.assignment-results {
    display: grid;
    gap: 0.5rem;
    max-height: 220px;
    overflow: auto;
}

.assignment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}

.autosuggest-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 19rem;
    overflow-y: auto;
    padding: 0;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.autosuggest-item {
    width: 100%;
    border: 0;
    border-radius: 0;
    background: #fff;
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
    text-align: left;
    border-bottom: 1px solid rgba(23, 43, 77, 0.05);
    transition: background-color 0.15s ease;
}

.autosuggest-item:hover {
    background: #f1f5f9;
}

.autosuggest-item.is-selected {
    background: #e9f2ff;
}

.autosuggest-item.is-static {
    grid-template-columns: 1fr;
    cursor: default;
}

.autosuggest-avatar {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #d9ecff, #d9fbf4);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 800;
    object-fit: cover;
    overflow: hidden;
    flex: 0 0 auto;
}

.autosuggest-avatar.ticket-avatar {
    background: linear-gradient(135deg, #eff6ff, #dcfce7);
    color: #0f6cbd;
}

.autosuggest-body {
    min-width: 0;
}

.autosuggest-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.15rem;
}

.autosuggest-title {
    font-weight: 700;
    color: var(--text);
}

.autosuggest-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.autosuggest-meta {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.autosuggest-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: #eef5ff;
    color: var(--primary);
    font-size: 0.74rem;
    font-weight: 700;
}

.autosuggest-badge.neutral {
    background: #f4f6fb;
    color: #475467;
}

.autosuggest-action {
    width: 2.35rem;
    height: 2.35rem;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 108, 189, 0.1);
    color: var(--primary);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.autosuggest-empty {
    padding: 1rem;
    border: 1px dashed rgba(15, 23, 42, 0.12);
    border-radius: 16px;
    text-align: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.7);
}

.autosuggest-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.selected-users {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.selected-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    background: #fff;
}

.conversation-item {
    width: 100%;
    text-align: left;
    border: 0;
    border-radius: 0;
    background: #fff;
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.85rem;
    min-height: 72px;
    border-bottom: 1px solid rgba(23, 43, 77, 0.05);
    transition: background-color 0.15s ease;
}

.conversation-item:last-child {
    border-bottom: 0;
}

.conversation-item:hover {
    background: #f1f5f9;
}

.conversation-item.active {
    background: #e9f2ff;
    position: relative;
}

.conversation-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3.5px;
    background: var(--primary);
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.15rem;
}

.conversation-name {
    font-size: 0.92rem;
    line-height: 1.2;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-body {
    min-width: 0;
}

.conversation-preview {
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 0.22rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.conversation-side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 1.35rem;
}

.conversation-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.55);
}

.unread-badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.4rem;
    padding: 0 0.32rem;
    height: 1.4rem;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 0.7rem;
}

.table thead th {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.78rem;
}

.status-pill,
.priority-pill {
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-pill.OPEN, .status-pill.IN_PROGRESS { background: #dbeafe; color: #1d4ed8; }
.status-pill.ON_HOLD { background: #fef3c7; color: #b45309; }
.status-pill.RESOLVED, .status-pill.CLOSED { background: #dcfce7; color: #15803d; }

.priority-pill.LOW { background: #e0f2fe; color: #0369a1; }
.priority-pill.MEDIUM { background: #e9d5ff; color: #7e22ce; }
.priority-pill.HIGH { background: #fed7aa; color: #c2410c; }
.priority-pill.CRITICAL { background: #fecaca; color: #b91c1c; }

.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.auth-banner {
    background: linear-gradient(160deg, #0f172a 0%, #0f6cbd 55%, #14b8a6 100%);
    color: #fff;
    padding: 4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-panel {
    margin: auto;
    width: min(460px, calc(100% - 2rem));
    padding: 2rem;
}

.banner-chip {
    display: inline-flex;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    margin-bottom: 1rem;
}

.error-wrap .auth-panel {
    width: min(520px, calc(100% - 2rem));
}

.error-code {
    font-size: clamp(3.5rem, 9vw, 5.5rem);
    line-height: 1;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.05em;
    margin-bottom: 0.75rem;
}

.app-alert-host {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1200;
    display: grid;
    gap: 0.75rem;
    width: min(420px, calc(100vw - 2rem));
}

.app-alert {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: start;
    padding: 1rem 1rem 1rem 0.95rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
    border: 1px solid var(--border);
    animation: appAlertIn 0.22s ease;
}

.app-alert.is-leaving {
    opacity: 0;
    transform: translateY(-8px);
    transition: 0.18s ease;
}

.app-alert-danger {
    border-color: rgba(239, 68, 68, 0.18);
}

.app-alert-success {
    border-color: rgba(20, 184, 166, 0.2);
}

.app-alert-warning {
    border-color: rgba(245, 158, 11, 0.22);
}

.app-alert-info {
    border-color: rgba(15, 108, 189, 0.2);
}

.app-alert-icon {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    font-size: 1rem;
}

.app-alert-success .app-alert-icon {
    background: rgba(20, 184, 166, 0.12);
    color: var(--accent);
}

.app-alert-warning .app-alert-icon {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.app-alert-info .app-alert-icon {
    background: rgba(15, 108, 189, 0.12);
    color: var(--primary);
}

.app-alert-title {
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.app-alert-message {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.app-alert-close {
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #64748b;
    display: grid;
    place-items: center;
}

.app-inline-alert {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.85rem;
    align-items: start;
    margin-top: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.app-inline-alert[hidden] {
    display: none;
}

.app-inline-alert-danger {
    border-color: rgba(239, 68, 68, 0.18);
}

.app-inline-alert-success {
    border-color: rgba(20, 184, 166, 0.2);
}

.app-inline-alert-warning {
    border-color: rgba(245, 158, 11, 0.22);
}

.app-inline-alert-info {
    border-color: rgba(15, 108, 189, 0.2);
}

.app-inline-alert-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
}

.app-inline-alert-danger .app-inline-alert-icon {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.app-inline-alert-success .app-inline-alert-icon {
    background: rgba(20, 184, 166, 0.12);
    color: var(--accent);
}

.app-inline-alert-warning .app-inline-alert-icon {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.app-inline-alert-info .app-inline-alert-icon {
    background: rgba(15, 108, 189, 0.12);
    color: var(--primary);
}

.app-inline-alert-title {
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.app-inline-alert-text {
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.92rem;
}

@keyframes appAlertIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-layout {
    display: grid;
    grid-template-columns: 22rem 1fr;
    gap: 1rem;
    align-items: stretch;
}

.chat-sidebar-card,
.chat-card {
    height: calc(100vh - 140px);
    border-radius: 12px;
    background: #fff;
    backdrop-filter: none;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.chat-sidebar-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.chat-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.chat-sidebar-top,
.chat-header,
.chat-composer {
    padding: 1rem 1.25rem;
}

.chat-sidebar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.chat-profile-pill,
.chat-contact {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    background: #e9f2ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-weight: 700;
    flex: 0 0 auto;
    object-fit: cover;
    overflow: hidden;
}

.chat-avatar-lg {
    width: 3rem;
    height: 3rem;
}

.chat-user-results {
    display: grid;
    gap: 0.25rem;
    max-height: 14rem;
    overflow-y: auto;
    padding: 0 0.45rem 0.75rem;
}

.chat-search-panel {
    padding: 1rem 1.25rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.chat-search-box {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.9rem;
    padding: 0 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
}

.chat-search-box i {
    color: #94a3b8;
}

.chat-search-box .form-control {
    border: 0;
    background: transparent;
    box-shadow: none;
    padding-left: 0;
}

.chat-action-btn {
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 999px;
    background: rgba(15, 108, 189, 0.1);
    color: var(--primary);
    font-size: 1rem;
    display: grid;
    place-items: center;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.5rem;
    background:
        radial-gradient(circle at top right, rgba(15, 108, 189, 0.04), transparent 24%),
        linear-gradient(180deg, #fafbff, #f6f8fc);
}

.chat-message-row {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
    animation-duration: 0.34s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    animation-fill-mode: both;
    transform-origin: bottom center;
    will-change: transform, opacity;
}

.chat-message-row.incoming {
    justify-content: flex-start;
    animation-name: chatMessageInLeft;
}

.chat-message-row.outgoing {
    justify-content: flex-end;
    animation-name: chatMessageInRight;
}

.chat-message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: #dbeafe;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 0.76rem;
    font-weight: 700;
    flex: 0 0 auto;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    object-fit: cover;
    overflow: hidden;
}

.chat-message-avatar.mine {
    background: #c7e0ff;
}

.chat-bubble {
    padding: 0.9rem 1rem;
    border-radius: 0.95rem;
    background: #fff;
    border: 1px solid var(--border);
    max-width: 78%;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.chat-bubble.me {
    background: #eaf3ff;
    margin-left: auto;
}

.chat-bubble.them {
    background: #fff;
}

.chat-sidebar-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-sidebar-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.95rem 1.25rem 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
    background: #fff;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.chat-header-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header-btn {
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    display: grid;
    place-items: center;
}

.typing-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    white-space: nowrap;
}

.typing-row {
    margin-top: -0.2rem;
}

.typing-bubble {
    max-width: max-content;
    padding: 0.65rem 0.8rem;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
}

.typing-dots span {
    width: 0.32rem;
    height: 0.32rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.3;
    animation: typingDot 1.1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

.emoji-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.75rem 1.1rem 0;
    background: transparent;
}

.chat-composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 0.6rem;
    align-items: center;
    border-top: 1px solid var(--border);
    background: #fff;
}

.composer-icon {
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    font-size: 1.05rem;
    display: grid;
    place-items: center;
}

.composer-input {
    min-height: 2.85rem;
    border-radius: 999px;
    border-color: #e2e8f0;
    padding-left: 1rem;
}

.composer-send {
    width: 2.85rem;
    height: 2.85rem;
    min-width: 2.85rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    padding: 0;
}

.chat-contacts-section {
    border-top: 1px solid var(--border);
    background: #fff;
    flex: 0 0 290px;
}

.emoji-btn {
    border: 0;
    background: transparent;
    font-size: 1.1rem;
    padding: 0.2rem 0.3rem;
}

.message-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.55rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.empty-state {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--muted);
}

.chat-empty-state {
    display: grid;
    justify-items: center;
    gap: 0.75rem;
    min-height: 100%;
    align-content: center;
}

.chat-empty-icon {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    background: #eef5ff;
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.6rem;
}

@keyframes chatMessageInLeft {
    from {
        opacity: 0;
        transform: translate3d(-18px, 10px, 0) scale(0.985);
    }
    60% {
        opacity: 1;
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes chatMessageInRight {
    from {
        opacity: 0;
        transform: translate3d(18px, 10px, 0) scale(0.985);
    }
    60% {
        opacity: 1;
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    40% {
        transform: translateY(-2px);
        opacity: 1;
    }
}

.conversation-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.chat-user-results::-webkit-scrollbar {
    width: 10px;
}

.conversation-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.chat-user-results::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, 0.12);
    border-radius: 999px;
}

.conversation-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.chat-user-results::-webkit-scrollbar-thumb {
    background: rgba(15, 108, 189, 0.35);
    border-radius: 999px;
}

.conversation-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-user-results::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 108, 189, 0.5);
}

@media (max-width: 1199px) {
    .metric-grid,
    .toolbar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        visibility: hidden;
        pointer-events: none;
    }

    .sidebar.is-open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .topbar {
        grid-template-columns: auto 1fr auto;
    }

    .metric-grid,
    .chat-layout,
    .auth-wrap {
        grid-template-columns: 1fr;
    }

    .chat-sidebar-card,
    .chat-card {
        height: auto;
    }

    .site-visit-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .content-area,
    .topbar {
        padding: 1rem;
    }

    .toolbar-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .notification-panel {
        width: min(92vw, 340px);
    }

    .chat-composer {
        grid-template-columns: auto 1fr;
    }

    .composer-send {
        grid-column: span 2;
    }
}
