:root {
    --primary: #4F46E5;
    --primary-light: #6366F1;
    --primary-dark: #4338CA;
    --primary-bg: #EEF2FF;
    --success: #10B981;
    --success-bg: #ECFDF5;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --info: #3B82F6;
    --info-bg: #EFF6FF;
    --body-bg: #F1F5F9;
    --card-bg: #FFFFFF;
    --sidebar-bg: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border-color: #E2E8F0;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .3s;
}
.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px;
}
.sidebar-brand h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.sidebar-brand small {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav .nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 8px 12px 4px;
    margin-top: 8px;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--primary-bg); color: var(--primary); }
.sidebar-nav a.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.sidebar-nav a i { width: 20px; text-align: center; font-size: 16px; }
.sidebar-nav .badge-count {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}
.sidebar-footer .user-info {
    display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .user-avatar {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--primary-bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary); font-weight: 700; font-size: 14px;
}
.sidebar-footer .user-name { font-size: 13px; font-weight: 600; }
.sidebar-footer .user-role { font-size: 11px; color: var(--text-muted); }

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 28px;
    display: flex; align-items: center; justify-content: space-between;
}
.topbar h4 { margin: 0; font-size: 20px; font-weight: 700; }
.topbar .breadcrumb { margin: 0; font-size: 13px; }
.content-area { padding: 28px; }

/* ---- Cards ---- */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin: 0; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin: 4px 0 0; }

.icon-primary { background: var(--primary-bg); color: var(--primary); }
.icon-success { background: var(--success-bg); color: var(--success); }
.icon-warning { background: var(--warning-bg); color: var(--warning); }
.icon-danger { background: var(--danger-bg); color: var(--danger); }
.icon-info { background: var(--info-bg); color: var(--info); }

/* ---- Table ---- */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}
.table-card .card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600; font-size: 15px;
    display: flex; align-items: center; justify-content: space-between;
}
.table-card table { margin: 0; }
.table-card th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
    background: #F8FAFC;
    border: none;
    padding: 12px 20px;
}
.table-card td {
    padding: 14px 20px;
    font-size: 14px;
    vertical-align: middle;
    border-color: var(--border-color);
}

/* ---- Contacts (mobile: toolbar + scroll tabel) ---- */
body.page-contacts .content-area {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}
body.page-contacts .contacts-toolbar {
    box-sizing: border-box;
}
body.page-contacts .contacts-search {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}
@media (min-width: 576px) {
    body.page-contacts .contacts-search {
        width: 220px;
        max-width: min(220px, 100%);
        flex: 0 1 auto;
    }
}
@media (max-width: 991.98px) {
    body.page-contacts .contacts-btn-add {
        width: 100%;
    }
}
body.page-contacts .contacts-table-card {
    max-width: 100%;
    min-width: 0;
}
body.page-contacts .contacts-table-responsive {
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}
body.page-contacts #contactsTable {
    min-width: 720px;
    margin-bottom: 0;
}
body.page-contacts #contactsTable th.contacts-col-actions,
body.page-contacts #contactsTable td.contacts-actions-cell {
    width: 1%;
    min-width: 118px;
    text-align: right;
    vertical-align: middle;
}
body.page-contacts .contacts-actions-cell {
    white-space: nowrap;
}
body.page-contacts .contacts-action-btns {
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
}
body.page-contacts .contacts-action-btns .btn {
    flex-shrink: 0;
}
body.page-contacts .contacts-action-btns form {
    display: inline-flex;
    margin: 0;
    align-items: center;
}
@media (max-width: 768px) {
    body.page-contacts .table-card th,
    body.page-contacts .table-card td {
        padding: 10px 12px;
        font-size: 13px;
    }
    body.page-contacts #contactsTable {
        min-width: 640px;
    }
}

/* ---- Chat / Inbox ---- */
.inbox-container {
    display: flex;
    height: calc(100vh - 73px);
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.conv-list {
    width: 340px;
    min-width: 340px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: #FAFBFC;
}
.conv-list-header {
    padding: 18px;
    border-bottom: 1px solid var(--border-color);
}
.conv-list-header h5 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.conv-search {
    width: 100%;
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 12px center no-repeat;
    outline: none;
    transition: border .15s;
}
.conv-search:focus { border-color: var(--primary); }
.conv-items { flex: 1; overflow-y: auto; }
.conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background .1s;
    text-decoration: none;
    color: inherit;
}
.conv-item:hover, .conv-item.active { background: var(--primary-bg); }
.conv-item .avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
    flex-shrink: 0;
}
.conv-item .conv-info { flex: 1; min-width: 0; }
.conv-item .conv-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.conv-item .conv-preview {
    font-size: 12px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item .conv-meta { text-align: right; flex-shrink: 0; }
.conv-item .conv-time { font-size: 11px; color: var(--text-muted); }
.conv-item .conv-unread {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    margin-top: 4px;
    margin-left: auto;
}

/* Chat area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 12px;
    background: #fff;
}
.chat-header .avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px;
}
.chat-header .chat-name { font-weight: 600; font-size: 15px; }
.chat-header .chat-phone { font-size: 12px; color: var(--text-muted); }
.chat-header-identity {
    flex: 1;
    min-width: 0;
}
.chat-header-toolbar {
    justify-content: flex-end;
    flex-wrap: nowrap !important;
    min-width: 0;
    gap: 6px !important;
}
.chat-header-toolbar .btn {
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    flex-shrink: 0;
}
.chat-header-toolbar .chat-label-toggle {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-more-btn {
    width: 38px;
    padding-left: 0;
    padding-right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chat-header-mobile-menu {
    max-height: min(75vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-width: min(calc(100vw - 24px), 300px);
}
.chat-header-mobile-menu .dropdown-item {
    white-space: normal;
    font-size: 13px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}
.chat-header-mobile-menu .dropdown-item.active {
    background: var(--primary-bg);
    color: var(--primary-dark, #1d4ed8);
    font-weight: 600;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #F0F2F5;
}
.chat-empty {
    height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted);
}
.chat-empty i { font-size: 64px; margin-bottom: 16px; opacity: .3; }
.chat-empty p { font-size: 15px; }
.msg-bubble {
    max-width: 65%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}
.msg-incoming {
    background: #fff;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.msg-outgoing {
    background: var(--primary-bg);
    border: 1px solid #C7D2FE;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.msg-outgoing.bot-msg {
    background: var(--success-bg);
    border-color: #A7F3D0;
}
.msg-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
}
.msg-incoming .msg-sender { color: var(--primary); }
.msg-outgoing .msg-sender { color: var(--success); }
.msg-time-inline {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 10px;
    margin-left: 6px;
}
.msg-time {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}
.msg-image {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
}
.msg-file-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,.05);
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--primary);
}
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: #fff;
    display: flex; align-items: flex-end; gap: 12px;
}
.chat-input-area .attach-btn {
    width: 40px; height: 40px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: all .15s;
    flex-shrink: 0;
}
.chat-input-area .attach-btn:hover { border-color: var(--primary); color: var(--primary); }
.chat-input-area textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    font-family: inherit;
    transition: border .15s;
}
.chat-input-area textarea:focus { border-color: var(--primary); }
.chat-input-area .send-btn {
    width: 40px; height: 40px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: background .15s;
    flex-shrink: 0;
}
.chat-input-area .send-btn:hover { background: var(--primary-dark); }
.chat-input-area .send-btn:disabled { background: var(--text-muted); cursor: not-allowed; }
.attachment-preview {
    padding: 8px 24px 0;
    border-top: 1px solid var(--border-color);
    background: #fff;
    display: none;
}
.attachment-preview.show { display: block; }
.att-preview-item {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: var(--primary-bg);
    border-radius: 8px;
    font-size: 12px;
    margin-right: 8px;
}
.att-preview-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.att-preview-item .remove-att {
    cursor: pointer; color: var(--danger); font-size: 14px;
    border: none; background: none; padding: 0;
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #EEF2FF 0%, #F1F5F9 50%, #ECFDF5 100%);
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.login-card .brand { text-align: center; margin-bottom: 32px; }
.login-card .brand-icon {
    width: 56px; height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 24px;
    margin-bottom: 16px;
}
.login-card h3 { margin: 0; font-weight: 700; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ---- Settings ---- */
.settings-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 24px;
}
.settings-section .section-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}
.settings-section .section-header h6 {
    margin: 0; font-size: 15px; font-weight: 600;
}
.settings-section .section-body { padding: 24px; }

/* ---- Badges ---- */
.badge-status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.badge-open { background: var(--success-bg); color: var(--success); }
.badge-closed { background: #F1F5F9; color: var(--text-muted); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: #F1F5F9; color: var(--text-muted); }

/* ---- Form ---- */
.form-control, .form-select {
    border-color: var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    padding: 10px 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    padding: 10px 20px;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Sidebar Toggle & Backdrop ---- */
.sidebar-toggle {
    display: none;
    border: none; background: none;
    font-size: 20px; cursor: pointer;
    color: var(--text-primary);
    padding: 4px 6px;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-toggle:hover { background: var(--body-bg); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
}
.sidebar-backdrop.show { display: block; }

/* ---- Topbar brand (mobile) ---- */
.topbar-brand {
    display: none;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}
.topbar h4 {
    display: block;
}

/* ---- Responsive: Tablet ---- */
/* ---- Global overflow guard ---- */
body { overflow-x: hidden; }
.main-content { overflow-x: hidden; }

/* ---- Responsive width utility ---- */
@media (min-width: 576px) {
    .w-sm-auto { width: auto !important; }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        box-shadow: none;
        transition: transform .25s ease, box-shadow .25s ease;
    }
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.12);
    }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; align-items: center; }
    .topbar-brand { display: block; }
    .topbar h4 { display: none; }
    .conv-list { width: 300px; min-width: 300px; }
    .topbar { padding: 14px 20px; }
    .content-area { padding: 20px; }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 768px) {
    .content-area { padding: 12px; }
    .topbar { padding: 12px 16px; }
    .topbar h4 { font-size: 16px; }

    /* Stats grid: 2 cols on mobile */
    .stat-card .stat-value { font-size: 22px; }

    /* Table card: horizontal scroll */
    .table-card .card-header { padding: 14px 16px; font-size: 14px; }
    .table-card th, .table-card td { padding: 10px 14px; }

    /* Settings */
    .settings-section .section-body { padding: 16px; }
    .settings-section .input-group .form-control { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

    /* Page header bar on mobile */
    .page-actions { flex-direction: column; align-items: stretch !important; }
    .page-actions .btn { width: 100%; justify-content: center; }

    /* Logs table compact */
    .logs-table td, .logs-table th { padding: 8px 10px !important; font-size: 12px !important; }

    /* Inbox: full-screen mobile panel layout */
    .inbox-container {
        flex-direction: row;
        height: calc(100dvh - 56px);
        height: calc(100vh - 56px);
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        position: relative;
        overflow: hidden;
    }

    .chat-header {
        padding: 10px 12px;
        gap: 8px;
        align-items: center;
        flex-wrap: nowrap;
    }
    .chat-header .avatar {
        flex-shrink: 0;
    }
    .chat-header .chat-name {
        font-size: 14px;
        line-height: 1.25;
    }
    .chat-header .chat-phone {
        font-size: 11px;
    }

    /* Banner di bawah header chat — tidak overflow horizontal */
    .chat-area > div[id="unreadBanner"],
    .chat-area > div[id="ignoreBanner"] {
        padding-left: 12px !important;
        padding-right: 12px !important;
        font-size: 12px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .chat-area > div[id="unreadBanner"] .btn,
    .chat-area > div[id="ignoreBanner"] a {
        margin-left: 0 !important;
    }

    .conv-list-header {
        padding: 12px 14px;
    }
    .conv-list-header h5 {
        font-size: 15px;
        margin-bottom: 10px !important;
    }

    /* Conv list: absolute, full width, slides left when chat active */
    .conv-list {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: 100%;
        height: 100%;
        border-right: none;
        z-index: 10;
        transition: transform .25s ease;
    }
    .conv-list.slide-out {
        transform: translateX(-100%);
    }

    /* Chat area: full width */
    .chat-area {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        transform: translateX(100%);
        transition: transform .25s ease;
    }
    .chat-area.slide-in {
        transform: translateX(0);
    }

    /* Mobile back button in chat header */
    .btn-back-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px; height: 36px;
        border: none;
        background: none;
        border-radius: 8px;
        color: var(--text-secondary);
        font-size: 18px;
        cursor: pointer;
        transition: background .15s;
        flex-shrink: 0;
        margin-right: 4px;
    }
    .btn-back-mobile:hover { background: var(--body-bg); }

    /* Bubble width on mobile */
    .msg-bubble { max-width: 82%; }

    /* Login page */
    .login-card { padding: 32px 24px; margin: 16px; max-width: 100%; }
}

@media (max-width: 1400px) {
    .chat-header {
        gap: 8px;
        padding-left: 14px;
        padding-right: 14px;
    }
    .chat-header-identity {
        max-width: 210px;
    }
    .chat-header-toolbar .btn {
        min-width: 32px;
        padding-left: 7px;
        padding-right: 7px;
    }
    .chat-header-toolbar .chat-label-toggle {
        max-width: 48px;
    }
}

@media (max-width: 480px) {
    .content-area { padding: 8px; }
    .topbar { padding: 10px 12px; }
    .stat-card { padding: 16px; }
    .msg-bubble { max-width: 88%; }
    .chat-input-area {
        padding: 10px 12px;
        gap: 8px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
    .chat-messages { padding: 16px 12px; }
    .inbox-container {
        height: calc(100dvh - 52px);
        height: calc(100vh - 52px);
    }
}

/* ---- Image lightbox ---- */
.lightbox-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    cursor: pointer;
}
.lightbox-overlay img {
    max-width: 90%; max-height: 90%;
    border-radius: 8px;
}

/* ---- Image lightbox ---- */
.lightbox-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    cursor: pointer;
}
.lightbox-overlay img {
    max-width: 90%; max-height: 90%;
    border-radius: 8px;
}
