@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --font-ui: "Tajawal", "Manrope", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --color-cosmic-deep: #2b0e5d;
    --color-royal: #5b2dbf;
    --color-soft-violet: #8f6bff;
    --color-lavender-glow: #c7b8ff;
    --color-white: #ffffff;
    --color-bg-dark: #0b0b12;
    --color-surface-dark: #151526;
    --color-surface-elevated: #1a1a2f;
    --color-surface-light: #f7f5ff;
    --color-soft-gray: #e9e9f2;
    --color-medium-gray: #9a9ab0;
    --color-border-dark: #2a2a3d;
    --color-cyan: #41d6ff;
    --color-success: #22c55e;
    --color-alert: #ec4899;
    --color-warning: #f59e0b;
    --gradient-primary: linear-gradient(135deg, #2b0e5d 0%, #6d3ddb 48%, #a98bff 100%);
    --gradient-secondary: linear-gradient(135deg, #3b1a78 0%, #7c53e8 100%);
    --gradient-glow: linear-gradient(120deg, #8f6bff 0%, #c7b8ff 100%);
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --shadow-soft: 0 8px 30px rgba(13, 10, 30, 0.32);
    --shadow-hover: 0 12px 35px rgba(143, 107, 255, 0.24);
    --shadow-glow: 0 0 0 1px rgba(143, 107, 255, 0.38), 0 0 24px rgba(143, 107, 255, 0.28);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: var(--font-ui);
    background:
        radial-gradient(circle at 15% 10%, rgba(143, 107, 255, 0.2), transparent 30%),
        radial-gradient(circle at 85% 18%, rgba(65, 214, 255, 0.1), transparent 30%),
        linear-gradient(180deg, #0a0a12 0%, #111123 70%, #090912 100%);
    color: var(--color-soft-gray);
    padding: 20px;
    direction: rtl;
    line-height: 1.45;
}

body[data-theme="light"] {
    --color-bg-dark: #f7f5ff;
    --color-surface-dark: #ffffff;
    --color-surface-elevated: #f6f2ff;
    --color-soft-gray: #2d2355;
    --color-medium-gray: #6f6595;
    --color-border-dark: #d8cff8;
    background:
        radial-gradient(circle at 15% 10%, rgba(143, 107, 255, 0.15), transparent 30%),
        radial-gradient(circle at 85% 18%, rgba(65, 214, 255, 0.12), transparent 30%),
        linear-gradient(180deg, #faf8ff 0%, #f3eeff 70%, #f7f4ff 100%);
    color: #2d2355;
}

a {
    color: var(--color-lavender-glow);
}

.container {
    max-width: 1240px;
    margin: 0 auto;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 24px rgba(143, 107, 255, 0.5);
}

.brand-logo svg {
    width: 34px;
    height: 34px;
}

.logo-title {
    font-weight: 800;
    letter-spacing: 0.2px;
}

.login-card,
.dashboard-header,
.section,
.tabs {
    border: 1px solid rgba(199, 184, 255, 0.12);
    background: linear-gradient(180deg, rgba(26, 26, 47, 0.92), rgba(18, 18, 34, 0.92));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
}

body[data-theme="light"] .login-card,
body[data-theme="light"] .dashboard-header,
body[data-theme="light"] .section,
body[data-theme="light"] .tabs {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(246, 242, 255, 0.97));
    border-color: rgba(91, 45, 191, 0.18);
}

.login-card {
    padding: 38px 34px;
    max-width: 480px;
    margin: 48px auto;
}

.login-card h1,
.dashboard-header h1 {
    color: var(--color-white);
}

body[data-theme="light"] .login-card h1,
body[data-theme="light"] .dashboard-header h1,
body[data-theme="light"] .login-card h2,
body[data-theme="light"] .section h2,
body[data-theme="light"] .section h3,
body[data-theme="light"] .request-info h4,
body[data-theme="light"] .api-key-info h3,
body[data-theme="light"] .auto-reply-info h3,
body[data-theme="light"] .contact-info h3,
body[data-theme="light"] .phone-info h3 {
    color: #251a4a;
}

.subtitle,
#usernameDisplay,
.section-description,
.phone-number,
.auto-reply-info p,
.api-key-preview,
.contact-phone,
.plan-description {
    color: var(--color-medium-gray);
}

.login-card h2,
.section h2,
.section h3,
.request-info h4,
.api-key-info h3,
.auto-reply-info h3,
.contact-info h3,
.phone-info h3 {
    color: var(--color-white);
}

.dashboard-header {
    padding: 20px 28px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 40;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.section {
    padding: 24px;
}

.section h2 {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border-dark);
}

.section.full-width {
    grid-column: 1 / -1;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-soft-gray);
    font-weight: 600;
}

.form-group small {
    color: var(--color-medium-gray);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    border: 1px solid var(--color-border-dark);
    background: rgba(11, 11, 18, 0.72);
    color: var(--color-soft-gray);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    transition: 0.24s ease;
}

body[data-theme="light"] .form-group input,
body[data-theme="light"] .form-group textarea,
body[data-theme="light"] .form-group select {
    background: rgba(255, 255, 255, 0.95);
    color: #261c4d;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #7d7d94;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-soft-violet);
    box-shadow: var(--shadow-glow);
}

.sender-selects-row,
.manual-recipient-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 20px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.sender-selects-row .form-group,
.manual-recipient-row .form-group {
    flex: 1 1 220px;
    min-width: 0;
    margin-bottom: 0;
}

.send-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--color-medium-gray);
}

body[data-theme="light"] .send-hint {
    color: #5c5277;
}

/* CKEditor داخل المودال: قوائم وألوان فوق المحتوى */
.modal .cke,
.modal .cke_panel {
    z-index: 10050;
}

.contact-phone-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    align-items: stretch;
}

.contact-phone-dial {
    flex: 0 1 220px;
    min-width: 160px;
    max-width: 100%;
}

.contact-phone-national {
    flex: 1 1 180px;
    min-width: 0;
}

@media (max-width: 640px) {
    .sender-selects-row,
    .manual-recipient-row {
        flex-direction: column;
    }

    .sender-selects-row .form-group,
    .manual-recipient-row .form-group {
        flex: 1 1 auto;
        width: 100%;
    }

    .contact-phone-row {
        flex-direction: column;
    }

    .contact-phone-dial,
    .contact-phone-national {
        flex: 1 1 auto;
        width: 100%;
    }
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    width: 100%;
    margin-bottom: 10px;
    padding-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.editor-toolbar button {
    border: 1px solid var(--color-border-dark);
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-soft-gray);
    border-radius: var(--radius-xs);
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    flex-shrink: 0;
}

.editor-toolbar button:hover {
    border-color: rgba(199, 184, 255, 0.5);
}

.editor-toolbar .editor-select {
    min-width: 0;
    height: 30px;
    flex-shrink: 0;
    padding: 3px 8px;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-xs);
    background: rgba(11, 11, 18, 0.72);
    color: var(--color-soft-gray);
    font-family: inherit;
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
    transition: 0.2s ease border-color, 0.2s ease box-shadow;
}

#messageFontSize {
    width: 4.35rem;
    min-width: 4.35rem;
    padding-inline: 6px;
    text-align: center;
}

#messageFontFamily {
    width: 6.25rem;
    min-width: 6.25rem;
    max-width: 6.75rem;
    padding-inline-start: 6px;
    padding-inline-end: 4px;
}

.editor-toolbar .editor-select:focus {
    outline: none;
    border-color: var(--color-soft-violet);
    box-shadow: var(--shadow-glow);
}

body[data-theme="light"] .editor-toolbar .editor-select {
    background: rgba(255, 255, 255, 0.95);
    color: #261c4d;
}

.editor-color-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
    margin-inline-start: 4px;
    padding-inline-start: 12px;
    border-inline-start: 1px solid rgba(199, 184, 255, 0.22);
}

.editor-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.editor-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.editor-swatch:hover {
    transform: scale(1.08);
}

body[data-theme="light"] .editor-swatch {
    border-color: rgba(0, 0, 0, 0.18);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.editor-color-custom {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body[data-theme="light"] .editor-color-custom {
    border-color: rgba(0, 0, 0, 0.2);
}

.editor-color-custom input[type="color"] {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    cursor: pointer;
    background: transparent;
}

.rich-editor,
#messageEditor.rich-editor {
    min-height: 180px;
    padding: 14px 18px;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: #111111;
    font-size: 15px;
    line-height: 1.7;
    text-align: right;
    overflow-wrap: anywhere;
}

body[data-theme="light"] .rich-editor,
body[data-theme="light"] #messageEditor.rich-editor {
    border-color: var(--color-border-dark);
}

.rich-editor:focus {
    outline: none;
    border-color: var(--color-soft-violet);
    box-shadow: var(--shadow-glow);
}

.rich-editor:empty::before {
    content: "اكتب الرسالة هنا...";
    color: #9ca3af;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 11px 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--color-white);
    box-shadow: 0 8px 20px rgba(109, 61, 219, 0.45);
}

.btn-primary:hover {
    box-shadow: 0 12px 24px rgba(109, 61, 219, 0.55);
}

form > .btn-primary,
.login-card .btn-primary {
    width: 100%;
}

.btn-secondary {
    background: rgba(231, 231, 255, 0.08);
    color: var(--color-soft-gray);
    border: 1px solid rgba(231, 231, 255, 0.14);
}

.btn-secondary:hover {
    border-color: rgba(199, 184, 255, 0.44);
}

.btn-success {
    background: rgba(34, 197, 94, 0.17);
    color: #7dffc3;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #ffd589;
    border: 1px solid rgba(245, 158, 11, 0.34);
}

.btn-danger {
    background: rgba(236, 72, 153, 0.16);
    color: #ff9fce;
    border: 1px solid rgba(236, 72, 153, 0.33);
}

.btn-small {
    padding: 7px 12px;
    font-size: 13px;
}

.switch-form {
    margin-top: 18px;
    text-align: center;
    color: var(--color-medium-gray);
}

.message {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    display: none;
    font-weight: 600;
}

.message.success {
    background: rgba(34, 197, 94, 0.16);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #86ffc9;
}

.message.error {
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid rgba(236, 72, 153, 0.4);
    color: #ffb0d7;
}

.whatsapp-module-banner {
    margin: 14px 0 18px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(236, 72, 153, 0.45);
    background: rgba(236, 72, 153, 0.1);
    color: var(--color-soft-gray);
    line-height: 1.55;
    text-align: right;
}

body[data-theme="light"] .whatsapp-module-banner {
    border-color: rgba(180, 50, 110, 0.35);
    background: rgba(253, 242, 248, 0.96);
    color: #3d1a30;
}

.whatsapp-module-banner strong {
    display: inline-block;
    margin-bottom: 6px;
}

.whatsapp-module-banner-detail {
    display: block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
    word-break: break-word;
    margin-top: 4px;
    opacity: 0.95;
}

.whatsapp-module-banner-hint {
    display: block;
    line-height: 1.5;
    opacity: 0.92;
}

.status-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 11px;
    font-size: 12px;
    font-weight: 700;
}

.status-connected,
.status-success {
    background: rgba(34, 197, 94, 0.15);
    color: #77ffbd;
}

.status-disconnected,
.status-danger {
    background: rgba(236, 72, 153, 0.16);
    color: #ff9dca;
}

.status-warning,
.status-connecting {
    background: rgba(245, 158, 11, 0.15);
    color: #ffd17d;
}

.phone-card,
.api-key-card,
.auto-reply-card,
.contact-card,
.request-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-dark);
    background: rgba(247, 245, 255, 0.04);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    transition: 0.2s ease;
}

body[data-theme="light"] .phone-card,
body[data-theme="light"] .api-key-card,
body[data-theme="light"] .auto-reply-card,
body[data-theme="light"] .contact-card,
body[data-theme="light"] .request-card {
    background: rgba(255, 255, 255, 0.95);
}

.phone-card:hover,
.api-key-card:hover,
.auto-reply-card:hover,
.contact-card:hover,
.request-card:hover,
.plan-card:hover {
    border-color: rgba(199, 184, 255, 0.6);
    box-shadow: var(--shadow-hover);
}

.phone-actions,
.contact-actions,
.api-key-actions,
.auto-reply-actions,
.request-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    text-align: center;
    color: var(--color-medium-gray);
    padding: 36px 14px;
}

.email-inbox-section {
    margin-top: 8px;
}

.email-inbox-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 10px;
}

.email-inbox-select-wrap {
    margin: 0;
    min-width: 220px;
}

.section-hint {
    font-size: 13px;
    color: var(--color-medium-gray);
    margin: 0 0 16px;
    line-height: 1.5;
}

.email-inbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.email-inbox-row {
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-dark);
    background: rgba(247, 245, 255, 0.04);
    padding: 12px 14px;
    text-align: right;
}

body[data-theme="light"] .email-inbox-row {
    background: rgba(255, 255, 255, 0.95);
}

.email-inbox-row-unread {
    border-inline-end: 3px solid rgba(99, 102, 241, 0.85);
}

.email-inbox-row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.email-inbox-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.email-inbox-badge-seen {
    background: rgba(148, 163, 184, 0.25);
    color: var(--color-medium-gray);
}

.email-inbox-badge-unread {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

body[data-theme="light"] .email-inbox-badge-unread {
    color: #4338ca;
}

.email-inbox-date {
    font-size: 12px;
    color: var(--color-medium-gray);
}

.email-inbox-subject {
    font-weight: 700;
    margin: 4px 0 6px;
    color: var(--color-soft-gray);
}

.email-inbox-from {
    font-size: 13px;
    color: var(--color-medium-gray);
    word-break: break-word;
}

.tabs {
    padding: 6px;
    margin-bottom: 20px;
    display: flex;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    border: none;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-medium-gray);
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    transition: 0.25s ease;
}

.tab-btn:hover {
    color: var(--color-soft-gray);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: var(--color-white);
    background: var(--gradient-secondary);
    box-shadow: inset 0 0 0 1px rgba(199, 184, 255, 0.25), 0 8px 18px rgba(58, 24, 126, 0.42);
}

.settings-menu {
    position: relative;
    z-index: 60;
}

.settings-trigger {
    min-width: 112px;
}

.settings-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(199, 184, 255, 0.28);
    background: linear-gradient(180deg, #17152c, #111122);
    box-shadow: var(--shadow-soft);
    padding: 10px;
    display: none;
    z-index: 80;
}

.settings-dropdown.open {
    display: block;
}

.settings-item {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-soft-gray);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    text-align: right;
    padding: 10px 12px;
    cursor: pointer;
    margin-bottom: 6px;
}

.settings-item:last-child {
    margin-bottom: 0;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(199, 184, 255, 0.25);
}

.settings-item.logout-link {
    text-decoration: none;
    display: block;
}

body[data-theme="light"] .settings-dropdown {
    background: linear-gradient(180deg, #ffffff, #f7f2ff);
    border-color: rgba(91, 45, 191, 0.2);
}

body[data-theme="light"] .settings-item {
    color: #2d2355;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    box-sizing: border-box;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: rgba(6, 6, 12, 0.76);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
}

body[data-theme="light"] .modal {
    background: rgba(36, 28, 68, 0.28);
    backdrop-filter: blur(8px);
}

.modal-content {
    width: min(95%, 560px);
    max-height: min(90vh, calc(100vh - 32px));
    margin: auto;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(199, 184, 255, 0.12);
    padding: 24px;
    position: relative;
    flex-shrink: 0;
    align-self: center;
    background: linear-gradient(180deg, rgba(26, 26, 47, 0.96), rgba(18, 18, 34, 0.96));
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
    color: var(--color-soft-gray);
}

body[data-theme="light"] .modal-content {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 242, 255, 0.98));
    border-color: rgba(91, 45, 191, 0.18);
    color: #2d2355;
    box-shadow: 0 12px 40px rgba(43, 14, 93, 0.12);
}

.modal-content h2 {
    color: var(--color-white);
}

body[data-theme="light"] .modal-content h2 {
    color: #251a4a;
}

.close {
    position: absolute;
    top: 10px;
    left: 14px;
    font-size: 28px;
    cursor: pointer;
    color: var(--color-lavender-glow);
    line-height: 1;
    transition: color 0.15s ease;
}

.close:hover {
    color: var(--color-white);
}

body[data-theme="light"] .close {
    color: #6f6595;
}

body[data-theme="light"] .close:hover {
    color: var(--color-royal);
}

#qrCode {
    padding: 16px;
    background: var(--color-white);
    border-radius: var(--radius-md);
    display: inline-flex;
}

#qrCode img {
    max-width: 290px;
    height: auto;
}

.plans-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.plan-card {
    border-radius: var(--radius-md);
    border: 1px solid rgba(199, 184, 255, 0.23);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 244, 255, 0.96) 100%);
    color: #1f173d;
    padding: 20px;
    transition: 0.2s ease;
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(43, 14, 93, 0.15);
}

.plan-header h3,
.plan-limits div,
.plan-description {
    color: #281d4f;
}

.plan-price {
    font-weight: 800;
    color: var(--color-royal);
}

.plan-limits div {
    padding: 6px 0;
    border-bottom: 1px dashed rgba(43, 14, 93, 0.16);
}

.plan-limits div:last-child {
    border-bottom: none;
}

/* سجل الإرسال (واتساب / بريد) */
.activity-load-error {
    margin: 0 0 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 100, 120, 0.45);
    background: rgba(255, 80, 100, 0.12);
    color: #ffb4bc;
    font-size: 14px;
    line-height: 1.45;
}

.activity-section .activity-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 14px;
}

.activity-subtab {
    font-family: var(--font-ui);
    border-radius: 999px;
    padding: 10px 18px;
    border: 1px solid rgba(199, 184, 255, 0.35);
    background: rgba(21, 21, 40, 0.55);
    color: var(--color-soft-gray);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.activity-subtab:hover {
    border-color: rgba(143, 107, 255, 0.55);
    box-shadow: var(--shadow-glow);
}

.activity-subtab.active {
    background: var(--gradient-secondary);
    color: var(--color-white);
    border-color: transparent;
    box-shadow: var(--shadow-hover);
}

.activity-log-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.activity-card {
    border-radius: var(--radius-md);
    border: 1px solid rgba(199, 184, 255, 0.2);
    background: linear-gradient(165deg, rgba(32, 32, 56, 0.95), rgba(18, 18, 34, 0.92));
    padding: 18px 20px;
    box-shadow: 0 6px 22px rgba(8, 6, 20, 0.35);
}

.activity-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.activity-kind {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-lavender-glow);
    background: rgba(143, 107, 255, 0.12);
    padding: 4px 10px;
    border-radius: 999px;
}

.activity-card time {
    font-size: 13px;
    color: var(--color-medium-gray);
}

.activity-preview {
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-soft-gray);
    margin-bottom: 8px;
    word-break: break-word;
}

.activity-meta {
    font-size: 13px;
    color: var(--color-medium-gray);
    margin-bottom: 10px;
}

.activity-meta-label {
    color: var(--color-lavender-glow);
    margin-inline-end: 6px;
}

.activity-overall {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--color-cyan);
}

.activity-overall-label {
    color: var(--color-medium-gray);
    margin-inline-end: 6px;
}

.activity-channel-block {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.activity-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
}

.activity-pill-wa {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.activity-pill-em {
    background: rgba(65, 214, 255, 0.12);
    color: var(--color-cyan);
    border: 1px solid rgba(65, 214, 255, 0.35);
}

.activity-pill-status.activity-pill-success {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.activity-pill-status.activity-pill-failed {
    background: rgba(220, 38, 38, 0.18);
    color: #fca5a5;
}

.activity-pill-status.activity-pill-partial {
    background: rgba(245, 158, 11, 0.18);
    color: #fcd34d;
}

.activity-pill-status.activity-pill-sending,
.activity-pill-status.activity-pill-pending {
    background: rgba(65, 214, 255, 0.14);
    color: var(--color-cyan);
    animation: activity-pulse 1.4s ease-in-out infinite;
}

@keyframes activity-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.65;
    }
}

.activity-counts {
    font-size: 13px;
    color: var(--color-medium-gray);
}

.activity-batch {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-lavender-glow);
}

.activity-fail-list {
    margin-top: 10px;
    padding-inline-start: 18px;
    font-size: 13px;
    color: #fecaca;
}

.activity-fail-list code {
    font-size: 12px;
    background: rgba(0, 0, 0, 0.25);
    padding: 2px 6px;
    border-radius: 6px;
}

.activity-cross-hint {
    margin-top: 10px;
    font-size: 13px;
    color: var(--color-soft-violet);
    border-inline-start: 3px solid var(--color-soft-violet);
    padding-inline-start: 10px;
}

.activity-empty-channel {
    font-size: 14px;
    color: var(--color-medium-gray);
    margin-top: 8px;
}

.activity-summary-channels {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.activity-inline-ch {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.activity-inline-muted {
    color: var(--color-medium-gray);
    font-size: 13px;
}

body[data-theme="light"] .activity-card {
    background: linear-gradient(165deg, #ffffff, #f6f2ff);
    border-color: var(--color-border-dark);
    box-shadow: 0 6px 20px rgba(43, 14, 93, 0.08);
}

body[data-theme="light"] .activity-preview {
    color: #2d2355;
}

body[data-theme="light"] .activity-subtab {
    background: #fff;
    color: #3b2a6e;
    border-color: var(--color-border-dark);
}

body[data-theme="light"] .activity-subtab.active {
    color: #fff;
}

body[data-theme="light"] .activity-fail-list {
    color: #b91c1c;
}

body[data-theme="light"] .activity-load-error {
    color: #7f1d1d;
    background: #fef2f2;
    border-color: #fecaca;
}

#apiKeyResult {
    background: rgba(247, 245, 255, 0.06);
    border: 1px solid rgba(199, 184, 255, 0.4);
    border-radius: var(--radius-sm);
    padding: 14px;
}

#generatedApiKey {
    font-family: "Consolas", "Monaco", monospace;
}

.requests-list,
.phone-numbers-list,
.contacts-list,
.auto-replies-list,
.api-keys-list {
    margin-top: 18px;
}

.table-like-box {
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-dark);
    background: rgba(247, 245, 255, 0.03);
    padding: 12px;
}

@media (max-width: 900px) {
    .dashboard-content {
        grid-template-columns: 1fr;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 14px;
    }

    .login-card {
        margin: 20px auto;
        padding: 24px;
    }

    .tabs {
        flex-direction: column;
    }

    .phone-card,
    .api-key-card,
    .auto-reply-card,
    .contact-card,
    .request-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* —— إرسال: اختيار المستقبلين من جهات الاتصال —— */
.recipient-picker-wrap {
    position: relative;
    width: 100%;
}

.recipient-picker-controls {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.recipient-picker-controls .recipient-picker-trigger {
    flex: 1;
    min-width: 0;
    width: auto;
}

.recipient-picker-clear {
    flex-shrink: 0;
    align-self: stretch;
    white-space: nowrap;
    padding-left: 14px;
    padding-right: 14px;
}

.recipient-picker-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(199, 184, 255, 0.22);
    background: rgba(247, 245, 255, 0.05);
    color: var(--color-soft-gray);
    font-family: inherit;
    font-size: 15px;
    cursor: pointer;
    text-align: right;
}

.recipient-picker-trigger:hover {
    border-color: rgba(199, 184, 255, 0.4);
}

.recipient-picker-chevron {
    flex-shrink: 0;
    opacity: 0.7;
    font-size: 12px;
}

.recipient-picker-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 80;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(199, 184, 255, 0.28);
    background: linear-gradient(180deg, #1a1a2f 0%, #141425 100%);
    box-shadow: var(--shadow-soft);
    max-height: min(380px, 70vh);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recipient-picker-panel[hidden] {
    display: none !important;
}

.recipient-picker-search {
    width: 100%;
    padding: 9px 11px;
    border-radius: var(--radius-xs);
    border: 1px solid rgba(199, 184, 255, 0.22);
    background: rgba(247, 245, 255, 0.06);
    color: var(--color-soft-gray);
    font-family: inherit;
    font-size: 14px;
}

.recipient-picker-actions {
    display: flex;
    justify-content: flex-start;
}

.recipient-picker-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    max-height: 220px;
    border-radius: var(--radius-xs);
    border: 1px solid rgba(199, 184, 255, 0.12);
}

.recipient-picker-item + .recipient-picker-item {
    border-top: 1px solid rgba(199, 184, 255, 0.1);
}

/* تمييز مقطع البحث داخل النص (دايلوغ الجهات + منتقي المستقبل) */
.text-search-highlight {
    background: rgba(65, 214, 255, 0.22);
    color: var(--color-cyan);
    font-weight: 700;
    padding: 0 0.08em;
    border-radius: 3px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

body[data-theme="light"] .text-search-highlight {
    background: rgba(91, 45, 191, 0.2);
    color: var(--color-royal);
}

.recipient-picker-item-btn {
    width: 100%;
    text-align: right;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: var(--color-soft-gray);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    line-height: 1.35;
}

.recipient-picker-item-btn:hover {
    background: rgba(143, 107, 255, 0.12);
}

.recipient-picker-empty {
    padding: 12px;
    color: var(--color-medium-gray);
    font-size: 14px;
}

.modal-content-wide {
    width: min(calc(100vw - 24px), 1240px);
}

.bulk-recipients-modal {
    box-sizing: border-box;
    padding: 28px 32px 26px;
    height: 700px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bulk-recipients-modal > h2,
.bulk-recipients-modal > .bulk-modal-hint,
.bulk-recipients-modal > .bulk-filter-toolbar {
    flex-shrink: 0;
}

.bulk-recipients-modal > .modal-actions-row {
    flex-shrink: 0;
    margin-top: 16px;
}

.bulk-modal-hint {
    font-size: 14px;
    color: var(--color-medium-gray);
    margin-bottom: 16px;
    line-height: 1.5;
}

.bulk-filter-toolbar {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
    gap: 10px 12px;
    align-items: end;
    margin-bottom: 14px;
}

.bulk-filter-toolbar > .form-group {
    margin-bottom: 0;
    min-width: 0;
}

.bulk-filter-toolbar .form-group label {
    font-size: 13px;
    line-height: 1.3;
    margin-bottom: 6px;
}

.bulk-toolbar-actions {
    display: flex;
    align-items: flex-end;
    padding-bottom: 1px;
}

.bulk-toolbar-search-btn {
    padding: 12px 18px;
    white-space: nowrap;
}

.bulk-combobox-anchor {
    position: relative;
}

.bulk-combobox-row {
    position: relative;
    display: flex;
    align-items: stretch;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-sm);
    background: rgba(11, 11, 18, 0.72);
}

.bulk-combobox-row:focus-within {
    border-color: rgba(143, 107, 255, 0.55);
    box-shadow: 0 0 0 2px rgba(143, 107, 255, 0.2);
}

.bulk-combobox-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--color-soft-gray);
    padding: 10px 12px;
    padding-inline-end: 76px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
}

.bulk-combobox-input:focus {
    outline: none;
}

.bulk-combobox-inline-actions {
    position: absolute;
    inset-inline-end: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0;
    pointer-events: none;
}

.bulk-combobox-inline-actions .bulk-combobox-inline-btn {
    pointer-events: auto;
}

.bulk-combobox-inline-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--color-medium-gray);
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    font-family: inherit;
}

.bulk-combobox-inline-btn:hover {
    color: var(--color-lavender-glow);
    background: rgba(143, 107, 255, 0.12);
}

.bulk-combobox-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(199, 184, 255, 0.28);
    background: linear-gradient(180deg, #1a1a2f 0%, #141425 100%);
    box-shadow: var(--shadow-soft);
}

.bulk-combobox-list li[role="option"] {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-soft-gray);
}

.bulk-combobox-list li[role="option"]:hover {
    background: rgba(143, 107, 255, 0.16);
}

.bulk-combobox-list li[role="option"][hidden] {
    display: none;
}

.bulk-combobox-empty {
    padding: 10px 12px;
    color: var(--color-medium-gray);
    font-size: 13px;
    cursor: default;
}

body[data-theme="light"] .bulk-combobox-row {
    background: #f9f7ff;
    border-color: var(--color-border-dark);
}

body[data-theme="light"] .bulk-combobox-input {
    color: #2d2355;
}

body[data-theme="light"] .bulk-combobox-inline-btn {
    color: #6f6595;
}

body[data-theme="light"] .bulk-combobox-inline-btn:hover {
    color: var(--color-royal);
    background: rgba(91, 45, 191, 0.1);
}

body[data-theme="light"] .bulk-combobox-list {
    background: #ffffff;
    border-color: var(--color-border-dark);
}

body[data-theme="light"] .bulk-combobox-list li[role="option"] {
    color: #2d2355;
}

body[data-theme="light"] .bulk-combobox-list li[role="option"]:hover {
    background: rgba(91, 45, 191, 0.1);
}

@media (max-width: 1050px) {
    .bulk-filter-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .bulk-toolbar-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 640px) {
    .bulk-filter-toolbar {
        grid-template-columns: 1fr;
    }
}

.bulk-recipient-panel {
    margin-top: 4px;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(199, 184, 255, 0.15);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.14);
}

body[data-theme="light"] .bulk-recipient-panel {
    border-color: rgba(91, 45, 191, 0.16);
    background: rgba(255, 255, 255, 0.55);
}

.bulk-modal-list-search {
    flex-shrink: 0;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(199, 184, 255, 0.12);
    background: rgba(11, 11, 18, 0.35);
}

.bulk-modal-list-search input[type="search"] {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--color-border-dark);
    border-radius: var(--radius-sm);
    background: rgba(11, 11, 18, 0.72);
    color: var(--color-soft-gray);
    font-family: inherit;
    font-size: 14px;
}

.bulk-modal-list-search input[type="search"]:focus {
    outline: none;
    border-color: rgba(143, 107, 255, 0.55);
    box-shadow: 0 0 0 2px rgba(143, 107, 255, 0.2);
}

body[data-theme="light"] .bulk-modal-list-search {
    background: #f3f0ff;
}

body[data-theme="light"] .bulk-modal-list-search input[type="search"] {
    background: #f9f7ff;
    color: #2d2355;
    border-color: var(--color-border-dark);
}

body[data-theme="light"] .bulk-modal-list-search input[type="search"]:focus {
    border-color: rgba(91, 45, 191, 0.45);
    box-shadow: 0 0 0 2px rgba(91, 45, 191, 0.14);
}

body[data-theme="light"] .bulk-filter-toolbar .form-group label {
    color: #4a3f6e;
}

body[data-theme="light"] .bulk-combobox-row:focus-within {
    border-color: rgba(91, 45, 191, 0.45);
    box-shadow: 0 0 0 2px rgba(91, 45, 191, 0.12);
}

.bulk-recipient-panel .bulk-recipient-list {
    margin-top: 0;
    flex: 1;
    min-height: 0;
    max-height: none;
    border: none;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .bulk-recipient-panel .bulk-recipient-list {
    background: rgba(246, 242, 255, 0.72);
}

.bulk-recipient-list {
    margin-top: 16px;
    max-height: min(440px, 54vh);
    overflow-y: auto;
    border: 1px solid rgba(199, 184, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 8px 0;
}

.bulk-recipient-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(199, 184, 255, 0.08);
}

.bulk-recipient-row:last-child {
    border-bottom: none;
}

body[data-theme="light"] .bulk-recipient-row {
    border-bottom-color: rgba(91, 45, 191, 0.1);
}

body[data-theme="light"] .bulk-recipient-name {
    color: #251a4a;
}

.bulk-recipient-row.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.bulk-recipient-row input[type="checkbox"] {
    margin-top: 4px;
    flex-shrink: 0;
}

.bulk-recipient-row-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    min-width: 0;
}

.bulk-recipient-name-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
    min-width: 0;
}

.bulk-recipient-name {
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.bulk-recipient-name-line .bulk-recipient-meta {
    color: var(--color-medium-gray);
    font-size: 12px;
    font-weight: 400;
    min-width: 0;
}

.bulk-recipient-contact-line {
    min-width: 0;
}

.bulk-recipient-contact-line .bulk-recipient-meta {
    color: var(--color-medium-gray);
    font-size: 12px;
    font-weight: 400;
    word-break: break-word;
}

.bulk-recipient-meta {
    color: var(--color-medium-gray);
    font-size: 12px;
}

.modal-actions-row {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

body[data-theme="light"] .recipient-picker-panel {
    background: #ffffff;
    border-color: var(--color-border-dark);
}

body[data-theme="light"] .recipient-picker-trigger {
    background: #fff;
    border-color: var(--color-border-dark);
    color: #2d2355;
}

body[data-theme="light"] .recipient-picker-search {
    background: #f9f7ff;
    border-color: var(--color-border-dark);
    color: #2d2355;
}

body[data-theme="light"] .recipient-picker-item-btn {
    color: #2d2355;
}

body[data-theme="light"] .recipient-picker-item-btn:hover {
    background: rgba(91, 45, 191, 0.08);
}

