:root {
    --wa-green: #00a884;
    --wa-green-dark: #008069;
    --wa-teal: #128c7e;
    --wa-teal-dark: #075e54;
    --wa-light-bg: #efeae2;
    --bg-main: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --border-color: #e9edef;
    --border-focus: #00a884;
    --hover-bg: #f5f6f6;
    --danger: #ea0038;
    --warning: #ff9800;
    --success: #25d366;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(11, 20, 26, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Noto Sans Arabic", sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.header-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-left .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.whatsapp-icon {
    font-size: 34px;
    color: #25d366;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-text .subtext {
    font-size: 11.5px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    background: #e9edef;
    color: var(--text-secondary);
}

.status-badge .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: #8696a0;
}

.status-badge.connected {
    background: #d9fdd3;
    color: #005c4b;
}
.status-badge.connected .dot {
    background-color: #25d366;
    box-shadow: 0 0 8px #25d366;
}

.status-badge.connecting {
    background: #fff3cd;
    color: #856404;
}
.status-badge.connecting .dot {
    background-color: #ffc107;
}

.status-badge.disconnected {
    background: #ffebe9;
    color: #b00020;
}
.status-badge.disconnected .dot {
    background-color: #ea0038;
}

/* Buttons */
.btn {
    border: none;
    outline: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--wa-green);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--wa-green-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    background: var(--hover-bg);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #ffd0d6;
    color: var(--danger);
}
.btn-danger-outline:hover {
    background: #ffebe9;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-large {
    padding: 12px 28px;
    font-size: 15px;
    width: 100%;
    justify-content: center;
}

/* Layout */
.main-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    padding: 8px 36px 6px 36px;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
}

@media (max-width: 900px) {
    body {
        height: auto;
        max-height: none;
        overflow: auto;
    }
    .main-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    .contacts-sidebar {
        height: 480px !important;
    }
}

/* Sidebar: Contacts */
.contacts-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-row h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: var(--wa-green);
    color: #ffffff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: bold;
}

.badge-info {
    background: #0284c7;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    right: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 8px 36px 8px 30px;
    border: 1px solid var(--border-color);
    background: #f0f2f5;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    background: #ffffff;
    border-color: var(--wa-green);
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.15);
}

.clear-btn {
    position: absolute;
    left: 10px;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 6px;
}

.filter-tab {
    flex: 1;
    background: #f0f2f5;
    border: 1px solid transparent;
    padding: 6px 4px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab.active {
    background: #e8f5e9;
    color: var(--wa-green-dark);
    border-color: #c8e6c9;
}

/* Selection Bar */
.selection-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 4px;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.selection-summary {
    font-size: 13px;
    color: var(--text-secondary);
}

.selection-summary strong {
    color: var(--wa-green-dark);
    font-size: 15px;
}

/* Contacts List */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f5f6f6;
    transition: background 0.15s;
}

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

.contact-item.selected {
    background: #e8f7f2;
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #dfe5e7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #54656f;
    font-size: 16px;
    flex-shrink: 0;
}

.contact-avatar.group-avatar {
    background: #d1e7dd;
    color: #0f5132;
}

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

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

.contact-phone {
    font-size: 12px;
    color: var(--text-secondary);
    direction: ltr;
    text-align: right;
}

/* Checkbox */
.custom-checkbox {
    position: relative;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 2px solid #8696a0;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    transition: all 0.2s;
}

.custom-checkbox:hover input ~ .checkmark {
    border-color: var(--wa-green);
}

.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--wa-green);
    border-color: var(--wa-green);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Content Panel */
.content-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Recipient Banner */
.selection-banner {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.banner-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.banner-icon {
    font-size: 20px;
    color: var(--wa-green);
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-hint {
    font-size: 13px;
    color: #0284c7;
    background: #e0f2fe;
    padding: 4px 10px;
    border-radius: 6px;
}

.template-hint code {
    background: #bae6fd;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
    color: #0369a1;
}

/* Quick Tags */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.quick-chip {
    background: #f0f2f5;
    border: 1px solid #e2e8f0;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.quick-chip:hover {
    background: #e8f5e9;
    border-color: #81c784;
    color: #1b5e20;
}

/* Textarea */
.textarea-wrapper textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
    resize: vertical;
    transition: border 0.2s;
    background: #fafafa;
}

.textarea-wrapper textarea:focus {
    background: #ffffff;
    border-color: var(--wa-green);
    box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.15);
}

/* Composer Options */
.composer-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 18px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.option-item select {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    outline: none;
    background: #ffffff;
}

/* Progress Section */
.progress-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00a884, #25d366);
    transition: width 0.3s ease;
}

.logs-container {
    max-height: 160px;
    overflow-y: auto;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 6px;
    border-radius: 4px;
}

.log-item.success {
    background: #e8f5e9;
    color: #1b5e20;
}

.log-item.fail {
    background: #ffebee;
    color: #c62828;
}

/* Future Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.feature-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    gap: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.feature-icon {
    font-size: 26px;
    color: var(--wa-green);
    background: #ffffff;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    flex-shrink: 0;
}

.feature-details h4 {
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.feature-details p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.feature-tag {
    font-size: 11px;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 20, 26, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999 !important;
    backdrop-filter: blur(4px);
}

/* Ensure Connect Modal is strictly in front of Settings Modal */
#connectModal {
    z-index: 20000000 !important;
}

#connectModal .modal-card {
    z-index: 20000001 !important;
}

.modal-card {
    background: #ffffff;
    width: 90%;
    max-width: 480px;
    border-radius: 16px;
    padding: 24px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #8696a0;
    cursor: pointer;
}

.modal-header .modal-icon {
    font-size: 42px;
    color: #25d366;
    margin-bottom: 10px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.qr-box {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    margin-bottom: 20px;
}

.qr-box img {
    max-width: 220px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.qr-steps {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    color: #334155;
    background: #f1f5f9;
    padding: 14px;
    border-radius: 8px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-num {
    background: var(--wa-green);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    flex-shrink: 0;
}

/* Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--wa-green);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #111b21;
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: transform 0.3s ease-out;
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.delete-contact-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
    opacity: 0.6;
}

.contact-item:hover .delete-contact-btn {
    opacity: 1;
}

.delete-contact-btn:hover {
    color: #ea0038;
    background: #ffebe9;
}

/* ==========================================================================
   Toggle Switch & Auto-Reply Quick Badge
   ========================================================================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--wa-green);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.autoreply-quick-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
}

.autoreply-label {
    color: #1e293b;
    font-size: 12px;
}

.badge-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
}

.badge-tag.on {
    background: #dcfce7;
    color: #15803d;
}

.badge-tag.off {
    background: #f1f5f9;
    color: #64748b;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 50%;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--wa-green-dark);
    background: #e2e8f0;
}

/* ==========================================================================
   Mode Switcher Tabs (Chat vs Broadcast)
   ========================================================================== */
.view-mode-tabs {
    display: flex;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 6px;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.view-mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-mode-tab.active {
    background: #e8f7f2;
    color: var(--wa-green-dark);
    box-shadow: inset 0 0 0 1px rgba(0, 168, 132, 0.25);
}

.counter-pill {
    background: #cbd5e1;
    color: #1e293b;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: bold;
}

.view-mode-tab.active .counter-pill {
    background: var(--wa-green);
    color: #ffffff;
}

/* ==========================================================================
   Chat Window (WhatsApp Web Experience)
   ========================================================================== */
.chat-view-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow);
    position: relative;
}

.broadcast-view-container,
.expenses-view-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 24px;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    background: #f8fafc;
}

.chat-empty-illustration {
    font-size: 72px;
    color: #25d366;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(37, 211, 102, 0.25));
}

.chat-empty-state h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.chat-empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 480px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.active-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.chat-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.chat-user-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #d9fdd3;
    color: #005c4b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid #c8e6c9;
}

.chat-user-text h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.chat-status-line {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    direction: ltr;
    justify-content: flex-end;
}

.online-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25d366;
    display: inline-block;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Chat Messages Canvas */
.chat-messages-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 18px 24px;
    background-color: #efeae2;
    background-image: radial-gradient(#d5cebe 10%, transparent 11%), radial-gradient(#d5cebe 10%, transparent 11%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-day-divider {
    align-self: center;
    margin: 10px 0;
}

.chat-day-divider span {
    background: #ffffff;
    color: #54656f;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(11,20,26,0.1);
}

/* Message Bubbles */
.chat-bubble-row {
    display: flex;
    width: 100%;
}

.chat-bubble-row.outgoing {
    justify-content: flex-end;
}

.chat-bubble-row.incoming {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 72%;
    min-width: 100px;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 1px rgba(11,20,26,0.13);
    position: relative;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.45;
}

.chat-bubble.outgoing {
    background: #d9fdd3;
    color: #111b21;
    border-top-left-radius: 2px;
}

.chat-bubble.incoming {
    background: #ffffff;
    color: #111b21;
    border-top-right-radius: 2px;
}

.bubble-text {
    white-space: pre-wrap;
}

.bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: #667781;
}

.bubble-checks {
    color: #53bdeb;
    font-size: 12px;
}

.bubble-auto-tag {
    background: #e0f2fe;
    color: #0284c7;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: bold;
    margin-left: 4px;
}

/* Chat Footer & Input */
.chat-footer {
    background: #f0f2f5;
    border-top: 1px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-quick-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.quick-chip-sm {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 3px 10px;
    border-radius: 14px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.quick-chip-sm:hover {
    background: #e8f5e9;
    border-color: var(--wa-green);
    color: var(--wa-green-dark);
}

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

.chat-input-row textarea {
    flex: 1;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 20px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-input-row textarea:focus {
    border-color: var(--wa-green);
}

.btn-send-chat {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--wa-green);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 168, 132, 0.3);
}

.btn-send-chat:hover {
    background: var(--wa-green-dark);
    transform: scale(1.05);
}

/* Contact Item Chat Snippet & Active Style */
.contact-item.active-chat {
    background: #e7f7f2 !important;
    border-right: 4px solid var(--wa-green);
}

.contact-header-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.contact-time {
    font-size: 11px;
    color: #8696a0;
    direction: ltr;
}

.contact-last-msg {
    font-size: 12px;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.contact-item.active-chat .contact-last-msg {
    color: #128c7e;
    font-weight: 500;
}

/* Auto-Reply Switch Box in Modal */
.autoreply-switch-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 14px 18px;
    border-radius: 10px;
}

/* ========================================================
   Eng.AlqaisiTech Branding & Footer
   ======================================================== */
.brand-logo-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
    border: 2px solid #0284c7;
    background: #0b1426;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.brand-logo-wrapper:hover {
    transform: scale(1.05);
}

.brand-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-title-row h1 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #0284c7 0%, #00a884 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.brand-verified-badge {
    color: #0284c7;
    font-size: 14px;
}

.designer-badge-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #475569;
    margin-top: 2px;
    flex-wrap: wrap;
}

.brand-phone-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 11px;
    direction: ltr;
    transition: all 0.2s ease;
    border: 1px solid #bae6fd;
}

.brand-phone-tag:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

.btn-edit-admin-phone {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
    border-radius: 8px;
    padding: 2px 7px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit-admin-phone:hover {
    background: #16a34a;
    color: #ffffff;
    border-color: #16a34a;
    transform: scale(1.08);
}

.header-controls-stack {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-header-settings {
    border: 1px solid #0284c7;
    color: #0284c7;
    font-weight: 700;
    background: rgba(2, 132, 199, 0.08);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-header-settings:hover {
    background: #0284c7;
    color: #ffffff;
}

.designer-text-col {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.designer-lbl {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.designer-name {
    font-size: 12.5px;
    font-weight: 800;
    color: #1e293b;
    white-space: nowrap;
}

/* App Footer */
.app-footer {
    flex-shrink: 0;
    background: #0b1426;
    color: #cbd5e1;
    padding: 8px 36px;
    margin: 4px 0 0 0;
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    border-top: 1px solid #1e293b;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 50;
    box-sizing: border-box;
}

.footer-content {
    max-width: 100%;
    width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #0284c7;
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.footer-text {
    display: flex;
    flex-direction: column;
}

.footer-text strong {
    color: #ffffff;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.footer-text span {
    color: #94a3b8;
    font-size: 12px;
}

.footer-credit {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    flex-wrap: wrap;
}

.footer-credit strong {
    color: #38bdf8;
}

.footer-contact-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #10b981;
    color: #ffffff;
    padding: 4px 12px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 700;
    font-size: 12px;
    direction: ltr;
    transition: transform 0.2s, background 0.2s;
}

.footer-contact-badge:hover {
    background: #059669;
    transform: translateY(-1px);
}

.footer-contact-badge.phone {
    background: #0284c7;
    direction: rtl;
}

.footer-contact-badge.phone:hover {
    background: #0369a1;
}

/* ==========================================================================
   Auto-Reply Square Modal & Neatly Organized Desktop Layout (Eng.AlqaisiTech)
   ========================================================================== */
.autoreply-square-card {
    background: #ffffff;
    width: min(1260px, 96vw);
    height: min(920px, 94vh);
    max-width: 1300px;
    max-height: 95vh;
    border-radius: 20px;
    padding: 0;
    position: relative;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: right;
    border: 1px solid #cbd5e1;
}

.autoreply-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 16px;
}

.autoreply-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.autoreply-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #e0f2fe;
    color: #0284c7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border: 1px solid rgba(2, 132, 199, 0.2);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.12);
}

.autoreply-header-titles h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

.autoreply-header-titles p {
    margin: 3px 0 0;
    font-size: 0.8rem;
    color: #64748b;
}

.autoreply-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.autoreply-master-toggle-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 30px;
    padding: 6px 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.autoreply-master-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.autoreply-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.autoreply-close-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #ef4444;
    transform: rotate(90deg);
}

.autoreply-nav-bar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 24px;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    overflow-x: auto;
}

.autoreply-tab-btn {
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    padding: 8px 18px;
    border-radius: 12px;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.autoreply-tab-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.autoreply-tab-btn.active {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.25);
}

.autoreply-tab-btn.tab-rules.active {
    background: #059669;
    border-color: #059669;
    box-shadow: 0 3px 8px rgba(5, 150, 105, 0.25);
}

.autoreply-tab-btn.tab-fixed.active {
    background: #0f766e;
    border-color: #0f766e;
    box-shadow: 0 3px 8px rgba(15, 118, 110, 0.25);
}

.autoreply-tab-btn.tab-clinic.active {
    background: #0284c7;
    border-color: #0284c7;
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.25);
}


.autoreply-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
    background: #fdfdfd;
}

.autoreply-content-body::-webkit-scrollbar {
    width: 6px;
}

.autoreply-content-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.autoreply-content-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.autoreply-content-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* AI Mode Official Desktop Layout */
.ai-desktop-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.ai-top-row {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 18px;
}

@media (max-width: 900px) {
    .ai-top-row {
        grid-template-columns: 1fr;
    }
}

.autoreply-subcard {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    margin-bottom: 14px;
}

.autoreply-subcard:last-child {
    margin-bottom: 0;
}

.autoreply-subcard-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.autoreply-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
}

.autoreply-footer-info {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.autoreply-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Rules Mode 2-Column Desktop Grid */
.rules-desktop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

@media (max-width: 820px) {
    .rules-desktop-grid {
        grid-template-columns: 1fr;
    }
}




/* ==========================================================================
   MOBILE / PHONE RESPONSIVE LAYOUT (<= 768px) - Eng.AlqaisiTech
   Desktop layout is untouched; everything below only applies on phones.
   ========================================================================== */
.mobile-bottom-nav { display: none; }

@media (max-width: 768px) {
    /* Only lock viewport height and overflow on chat/portal pages that have .main-layout or .has-fixed-layout */
    html:has(.main-layout),
    html.has-fixed-layout,
    body:has(.main-layout),
    body.has-fixed-layout {
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
        width: 100% !important;
    }
    body:has(.main-layout),
    body.has-fixed-layout {
        display: flex !important;
        flex-direction: column !important;
    }

    /* ---- Header / navbar (Side-by-side Mobile Layout as requested) ---- */
    .app-header {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 10px !important;
        gap: 6px !important;
        overflow: hidden !important;
    }
    .app-header .header-left {
        width: auto !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        display: flex !important;
        align-items: center !important;
    }
    .app-header .logo {
        gap: 8px !important;
        display: flex !important;
        align-items: center !important;
    }
    .app-header .brand-logo-wrapper {
        width: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;
        cursor: pointer !important;
        flex-shrink: 0 !important;
    }
    .app-header .brand-avatar-img {
        width: 100% !important;
        height: 100% !important;
    }
    .app-header .logo-text {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        min-width: 0 !important;
    }
    .app-header .brand-title-row {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
    }
    .app-header .logo-text h1 {
        font-size: 14px !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }
    .app-header .brand-verified-badge {
        font-size: 12px !important;
    }
    .app-header .designer-badge-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1px !important;
        margin-top: 1px !important;
    }
    .app-header .designer-text-col {
        display: flex !important;
        flex-direction: column !important;
        line-height: 1.15 !important;
    }
    .app-header .designer-lbl {
        font-size: 9.5px !important;
        color: #64748b !important;
        line-height: 1.1 !important;
    }
    .app-header .designer-name {
        font-size: 11.5px !important;
        font-weight: 800 !important;
        color: #1e293b !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }
    .app-header .brand-phone-tag {
        font-size: 10px !important;
        padding: 1px 7px !important;
        margin-top: 2px !important;
        line-height: 1.3 !important;
        border-radius: 10px !important;
        white-space: nowrap !important;
    }

    /* Left Controls Stack: Settings ABOVE Auto Reply */
    .app-header .header-right {
        width: auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: center !important;
        gap: 4px !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
    }
    .header-controls-stack {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 3px !important;
    }
    .btn-header-settings {
        background: transparent !important;
        border: none !important;
        color: #0f172a !important;
        font-size: 11.5px !important;
        font-weight: 800 !important;
        padding: 0 4px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        cursor: pointer !important;
        line-height: 1.2 !important;
    }
    .btn-header-settings i {
        color: #0284c7 !important;
        font-size: 12px !important;
    }
    .btn-header-settings:hover, .btn-header-settings:active {
        color: #0284c7 !important;
    }
    .app-header .autoreply-quick-badge {
        padding: 3px 8px !important;
        gap: 5px !important;
        font-size: 10.5px !important;
        border-radius: 20px !important;
        background: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    }
    .app-header .autoreply-label {
        font-size: 10px !important;
        font-weight: 700 !important;
    }
    .app-header .toggle-switch {
        width: 32px !important;
        height: 17px !important;
    }
    .app-header .toggle-slider::before {
        height: 13px !important;
        width: 13px !important;
        left: 2px !important;
        bottom: 2px !important;
    }
    .app-header .toggle-switch input:checked + .toggle-slider::before {
        transform: translateX(15px) !important;
    }
    .app-header .badge-tag {
        font-size: 9.5px !important;
        padding: 1px 5px !important;
    }
    .app-header .btn-desktop-only,
    .app-header #connectionBadge {
        display: none !important;
    }

    /* ---- Main: one pane at a time (list OR content) ---- */
    .main-layout {
        display: block !important;
        padding: 6px !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: hidden !important;
    }
    .contacts-sidebar {
        height: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        display: flex !important;
    }
    .content-panel {
        height: 100% !important;
        width: 100% !important;
        display: none !important;
    }
    body.m-content .contacts-sidebar { display: none !important; }
    body.m-content .content-panel { display: flex !important; }
    .content-panel .view-mode-tabs { display: none !important; }

    /* Scroll inside panes instead of the page */
    .broadcast-view-container, .clinic-view-container, .expenses-view-container {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        height: 100% !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding-bottom: calc(95px + env(safe-area-inset-bottom)) !important;
    }
    .chat-view-container, .active-chat-container { height: 100% !important; min-height: 0 !important; }
    .chat-header { padding: 8px 10px !important; flex-wrap: nowrap; gap: 6px; }
    .chat-header-actions .btn { padding: 6px 9px !important; font-size: 11px !important; }
    .chat-header-actions .btn:not(:last-child) span { display: none; }
    .chat-footer { padding: 6px 8px !important; }
    .chat-quick-chips { overflow-x: auto; flex-wrap: nowrap !important; scrollbar-width: none; }
    .chat-quick-chips > * { flex-shrink: 0; }
    .chat-messages-canvas { padding: 10px !important; }
    .chat-empty-state { padding: 16px !important; }
    .chat-empty-state p { font-size: 13px; }

    /* Collapse every inline 2/3-column grid into one column */
    [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .clinic-weekly-grid { grid-template-columns: repeat(7, 190px) !important; }
    .clinic-view-container .clinic-weekly-wrap, .clinic-weekly-scroll { overflow-x: auto !important; }
    table { max-width: 100%; }
    .clinic-table { display: block; overflow-x: auto; white-space: nowrap; }

    /* ---- Footer hidden, bottom nav shown ---- */
    .app-footer { display: none !important; }
    .mobile-bottom-nav {
        display: flex;
        flex-shrink: 0;
        background: #ffffff;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
        gap: 2px;
        z-index: 50;
    }
    .mobile-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 46px;
        border: none;
        background: transparent;
        color: #64748b;
        font-family: inherit;
        font-size: 11px;
        font-weight: 700;
        border-radius: 10px;
        cursor: pointer;
    }
    .mobile-bottom-nav button i { font-size: 17px; }
    .mobile-bottom-nav button.active { color: #008069; background: #e8f5e9; }
    .mobile-bottom-nav #mNav_expenses { color: #10b981; font-weight: 800; }
    .mobile-bottom-nav #mNav_expenses:active { background: #dcfce7; }
    .mobile-bottom-nav #mNav_logout { color: #ef4444; font-weight: 800; }
    .mobile-bottom-nav #mNav_logout:active { background: #fee2e2; }

    /* ---- Modals: full-screen sheets ---- */
    .modal-overlay { align-items: stretch !important; justify-content: stretch !important; }
    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        height: auto;
        max-height: 100dvh;
        overflow-y: auto;
        border-radius: 0 !important;
        padding: 16px !important;
    }
    #connectModal { align-items: center !important; justify-content: center !important; }
    #connectModal .modal-card {
        width: 94% !important;
        max-width: 94% !important;
        border-radius: 16px !important;
        max-height: 92dvh;
    }
    .autoreply-square-card {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
    }
    .autoreply-header {
        flex-wrap: wrap !important;
        padding: 10px 12px !important;
        gap: 8px !important;
    }
    .autoreply-header-right { flex: 1 1 100%; }
    .autoreply-header-titles h3 { font-size: 0.92rem !important; }
    .autoreply-header-titles p { display: none; }
    .autoreply-header-left { flex-wrap: wrap; gap: 6px !important; width: 100%; justify-content: space-between; }
    .autoreply-nav-bar {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 6px 8px !important;
    }
    .autoreply-nav-bar::-webkit-scrollbar { display: none; }
    .autoreply-tab-btn { flex-shrink: 0 !important; white-space: nowrap; font-size: 12px !important; padding: 8px 12px !important; }
    .autoreply-content-body { padding: 10px !important; }
    .autoreply-subcard { padding: 12px !important; }
    .autoreply-footer {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) !important;
        gap: 8px !important;
    }
    .autoreply-footer-info { display: none !important; }
    .autoreply-footer-actions { width: 100%; }
    .autoreply-footer-actions .btn { flex: 1; justify-content: center; padding: 11px 8px !important; font-size: 12.5px !important; }

    /* ---- Login / OTP overlay ---- */
    .sub-login-card { width: 94% !important; max-width: 94% !important; padding: 18px !important; }

    /* ---- Touch friendliness ---- */
    input, select, textarea { font-size: 16px !important; }
    .btn { min-height: 38px; }
    .toast { max-width: 92vw; font-size: 13px; }
}

@media (max-width: 380px) {
    .app-header .logo-text h1 { font-size: 13.5px !important; }
    .mobile-bottom-nav button span { font-size: 10px; }
}
