/* ===== email_modal (inline styles) ===== */
.email-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.email-modal.active { display: flex; }
.email-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}
.email-modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 16px;
    width: 90vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    animation: emailModalIn 0.2s ease-out;
}
@keyframes emailModalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.email-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.email-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
    font-weight: 600;
}
.email-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
.email-modal-close:hover { color: var(--danger); }
.email-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 500px;
}
.email-form {
    width: 500px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}
.email-recipient {
    background: var(--bg-hover);
    padding: 16px;
    border-radius: 12px;
}
.email-recipient .name {
    font-size: 16px;
    font-weight: 600;
    color: #d4af37;
    margin-bottom: 4px;
}
.email-recipient .details {
    font-size: 13px;
    color: var(--text-secondary);
}
.email-template-selector {
    display: flex;
    gap: 8px;
    align-items: center;
}
.email-template-selector select {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}
.email-template-selector select:focus { outline: none; border-color: #d4af37; }
.email-template-actions { display: flex; gap: 4px; }
.template-btn {
    background: var(--bg-hover);
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.template-btn:hover { background: var(--bg-hover); }
.template-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.template-btn.modified { background: #065f46; }
.template-btn-danger:hover:not(:disabled) { background: #7f1d1d; }
.email-form-group { display: flex; flex-direction: column; gap: 8px; }
.email-form-group label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.email-form-group textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 280px;
    flex: 1;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
}
.email-form-group textarea:focus {
    outline: none;
    border-color: #d4af37;
}
.email-hint {
    font-size: 11px;
    color: var(--text-muted);
}
.email-test-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.email-test-row input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
}
.email-test-row input:focus {
    outline: none;
    border-color: #d4af37;
}
.email-btn-test {
    background: var(--info-bg);
    color: var(--info);
    padding: 8px 16px;
    font-size: 13px;
}
.email-btn-test:hover { background: var(--info-bg); }
.email-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.email-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.email-btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
}
.email-btn-secondary:hover { background: var(--bg-hover); }
.email-btn-primary {
    background: linear-gradient(135deg, #d4af37 0%, #f4e4ba 50%, #d4af37 100%);
    color: #0f0f0f;
}
.email-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212,175,55,0.3);
}
.email-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
/* Email preview - rendered HTML content, keep white backgrounds */
.email-preview {
    flex: 1;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-preview-headers {
    background: #f8fafc;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    color: #334155;
}
.email-header-row {
    display: flex;
    margin-bottom: 6px;
}
.email-header-row:last-child { margin-bottom: 0; }
.email-header-row .label {
    font-weight: 600;
    width: 50px;
    color: #64748b;
}
.email-preview-frame {
    flex: 1;
    border: none;
    background: #fff;
}
@media (max-width: 1000px) {
    .email-modal-body { flex-direction: column; }
    .email-form { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
    .email-preview { min-height: 300px; }
}

/* ===== batch_email_modal (inline styles) ===== */
.batch-email-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.batch-email-modal.active { display: flex; }
.batch-email-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
}
.batch-email-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 16px;
    width: 95vw;
    height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    animation: batchModalIn 0.2s ease-out;
}
@keyframes batchModalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.batch-email-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}
.batch-email-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.batch-email-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}
.batch-count-badge {
    background: var(--bg-hover);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}
.batch-email-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
.batch-email-close:hover { color: var(--danger); }
.batch-email-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.batch-email-list {
    width: 280px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}
.batch-email-list-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.batch-email-list-actions { display: flex; gap: 4px; }
.batch-list-btn {
    background: var(--bg-hover);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.batch-list-btn:hover { background: var(--bg-hover); color: var(--text); }
.batch-email-list-items {
    flex: 1;
    overflow-y: auto;
}
.batch-email-list-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.batch-email-list-item:hover { background: var(--bg-hover); }
.batch-email-list-item.active { background: var(--bg-hover); }
.batch-email-list-item.sent { opacity: 0.6; }
.batch-email-list-item .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.status-pending { background: var(--text-muted); }
.status-dot.status-modified { background: var(--warning); }
.status-dot.status-sent { background: var(--success); }
.status-dot.status-warning { background: var(--danger); }
.status-dot.status-error { background: #dc2626; }
.batch-email-list-item .contact-info {
    flex: 1;
    min-width: 0;
}
.batch-email-list-item .contact-name {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.batch-email-list-item .contact-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.batch-email-list-item .contact-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #7f1d1d;
    color: #fca5a5;
}
.batch-email-list-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.batch-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 10px;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.batch-email-editor {
    width: 400px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}
.batch-email-recipient {
    background: var(--bg-hover);
    padding: 14px 16px;
    border-radius: 10px;
}
.batch-email-recipient .name {
    font-size: 15px;
    font-weight: 600;
    color: #d4af37;
    margin-bottom: 2px;
}
.batch-email-recipient .details {
    font-size: 12px;
    color: var(--text-secondary);
}
.batch-email-template-row {
    display: flex;
    gap: 8px;
}
.batch-email-template-row select {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}
.batch-email-template-row select:focus { outline: none; border-color: #d4af37; }
.batch-email-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.batch-email-form-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.batch-email-form-group textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    flex: 1;
    min-height: 200px;
    resize: none;
    font-family: inherit;
    transition: border-color 0.15s;
}
.batch-email-form-group textarea:focus { outline: none; border-color: #d4af37; }
.batch-email-form-group textarea.modified { border-color: var(--warning); }
.batch-email-hint {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted);
}
.modified-indicator {
    color: var(--warning);
    font-weight: 500;
}
.batch-email-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.batch-nav-btn {
    background: var(--bg-hover);
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.batch-nav-btn:hover:not(:disabled) { background: var(--bg-hover); }
.batch-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#batchNavPosition {
    font-size: 12px;
    color: var(--text-secondary);
}
.batch-email-test-row {
    display: flex;
    gap: 8px;
}
.batch-email-test-row input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
}
.batch-email-test-row input:focus { outline: none; border-color: #d4af37; }
.batch-btn-test, .batch-btn-test-all {
    background: var(--info-bg);
    color: var(--info);
    white-space: nowrap;
}
.batch-btn-test:hover, .batch-btn-test-all:hover { background: var(--info-bg); }
/* Batch email preview - rendered HTML content, keep white backgrounds */
.batch-email-preview {
    flex: 1;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.batch-email-preview-headers {
    background: #f8fafc;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    color: #334155;
}
.batch-email-preview-headers .email-header-row {
    display: flex;
    margin-bottom: 4px;
}
.batch-email-preview-headers .email-header-row:last-child { margin-bottom: 0; }
.batch-email-preview-headers .label {
    font-weight: 600;
    width: 45px;
    color: #64748b;
}
.batch-email-preview-frame {
    flex: 1;
    border: none;
    background: #fff;
}
.batch-email-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.batch-email-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 400px;
}
.batch-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.batch-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37, #f4e4ba);
    width: 0%;
    transition: width 0.3s ease;
}
#batchProgressText {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.batch-email-actions {
    display: flex;
    gap: 10px;
}
.batch-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.batch-btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
}
.batch-btn-secondary:hover { background: var(--bg-hover); }
.batch-btn-primary {
    background: linear-gradient(135deg, #d4af37 0%, #f4e4ba 50%, #d4af37 100%);
    color: #0f0f0f;
}
.batch-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212,175,55,0.3);
}
.batch-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.batch-btn-pause {
    background: var(--bg-hover);
    color: var(--text);
}
.batch-btn-pause.paused {
    background: #065f46;
    color: #6ee7b7;
}
.batch-btn-warning {
    background: #dc2626;
    color: #fff;
}
.batch-btn-warning:hover { background: #b91c1c; }
.batch-alert-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    align-items: center;
    justify-content: center;
}
.batch-alert-modal.active { display: flex; }
.batch-alert-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}
.batch-alert-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.batch-alert-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.batch-alert-header .alert-icon { color: var(--warning); }
.batch-alert-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text);
}
.batch-alert-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
}
.batch-alert-body ul {
    margin: 8px 0 0;
    padding-left: 20px;
}
.batch-alert-body li {
    margin-bottom: 4px;
    color: #fca5a5;
}
.batch-alert-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.batch-email-list-items::-webkit-scrollbar,
.batch-email-editor::-webkit-scrollbar {
    width: 6px;
}
.batch-email-list-items::-webkit-scrollbar-track,
.batch-email-editor::-webkit-scrollbar-track {
    background: transparent;
}
.batch-email-list-items::-webkit-scrollbar-thumb,
.batch-email-editor::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.batch-email-list-items::-webkit-scrollbar-thumb:hover,
.batch-email-editor::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}
